GeezerVison is showing github.com — using `--import ./instrument.mjs` and `tsx` fails · Issue #12357 · getsentry/sentry-javascript
using --import ./instrument.mjs and tsx fails #12357
Description
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.7.0
Framework Version
Node v20.14.0
Link to Sentry event
No response
SDK Setup
Sentry.init({ dsn, tracesSampleRate: 1.0 });
Steps to Reproduce
"NODE_OPTIONS='--import ./instrument.mjs' doppler run -- tsx src/index.ts"
Discord thread: https://discord.com/channels/621778831602221064/1247628587176034324/1247628587176034324
Expected Result
Does not cause an error
Actual Result
> NODE_OPTIONS='--import ./instrument.mjs' doppler run -- tsx watch src/index.ts
SyntaxError [Error]: Unexpected token (5:9)
at pp$4.raise (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:3573:15)
at pp$9.unexpected (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:772:10)
at pp$9.expect (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:766:28)
at pp$7.parseBindingList (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2077:19)
at pp$8.parseFunctionParams (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:1386:24)
at pp$8.parseFunction (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:1375:10)
at Parser.parseExport (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected][email protected]/node_modules/acorn-import-attributes/lib/index.js:172:35)
at pp$8.parseStatement (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:948:76)
at pp$8.parseTopLevel (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:829:23)
at Parser.parse (/Users/ollebergkvist/Documents/dev/projects/alpha-securities/api-crons/node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:601:17) {
pos: 179,
loc: { line: 5, column: 9 },
raisedAt: 180
}
Happens even when we pin import-in-the-middle to 1.8.0
Activity
timfish commented on Jun 5, 2024
This appears to be because the tsx and import-in-the-middle loaders are registered in the wrong order. import-in-the-middle is being passed TypeScript which it was never designed to parse.
timfish commented on Jun 5, 2024
Reacted by Anthony Dugarte
timfish commented on Jun 15, 2024
This should hopefully have been fixed by the numerous PRs recently merged at import-in-the-middle.
Specifically for tsx, import-in-the-middle now gracefully handles source code it can't parse by falling back to the parent loader. This does mean that iitm won't be able to hook TypeScript files but that's likely not much of a concern for now.
While we wait for this to be released, there is a patch available that combines all the fixes. If anyone can confirm this patch fixes this issue that would be super helpful!
AbhiPrasad commented on Jul 8, 2024
ContributorAuthor
More actions
Metadata
Metadata
Development
No branches or pull requestsIssue actions