You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
import.meta is left unshimmed by the CJS transform when comments or newlines split the tokens #828
Requiring an ESM file through the CJS hook crashes when a comment or newline sits between the import and .meta tokens:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object,
file URL string, or absolute path string. Received undefined
at createRequire (node:internal/modules/cjs/loader:2025:11)
The failing form is createRequire(import /*::(_)*/.meta.url) — valid syntax, and plain node entry.cjs (native require(esm), Node 20.19+) loads it fine. Under tsx, import.meta lowers to an empty object and .url is undefined.
Cause: transformSync in src/utils/transform/index.ts only passes the import.meta define to esbuild when code.includes('import.meta'). Comments or newlines between the tokens defeat the textual search. esbuild's define itself handles those forms correctly once configured.
This is hit in the wild: @babel/helper-define-polyfill-provider@1.x ships exactly that form (a preserved Flow type-comment — source at the 1.0.0 tag), so any CJS code that pulls in @babel/preset-env 8 under the hook crashes — e.g. @angular-devkit/build-angular 22.1, found via cypress-io/cypress#34461.
Reproduced on 4.22.4 through 4.23.8.
Bugs are expected to be fixed by those affected by it
I'm interested in working on this issue
Compensating engineering work will speed up resolution and support the project
Activity
privatenumber commentedon Aug 10, 2026
This issue is now resolved in v4.23.12.
If you're able to, your sponsorship would be very much appreciated.
fix: shim `import.meta` when tokens are split by comments or newlines (…
Update tsx (4.21.0 -> 4.23.12)