npm i tsx@4.12.1
node -e 'console.log(require("tsx/cjs/api").require("./package.json", "."))'
Throws a SyntaxError
npm i tsx@4.13.0
node -e 'console.log(require("tsx/cjs/api").require("./package.json", "."))'
***/package.json:2
"name": "***",
^
SyntaxError: Unexpected token ':'
at internalCompileFunction (node:internal/vm:128:18)
at wrapSafe (node:internal/modules/cjs/loader:1280:20)
at Module._compile (node:internal/modules/cjs/loader:1332:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Object.transformer [as .js] (***/node_modules/tsx/dist/register-BPRJR7M6.cjs:2:589)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at Object.require (node:internal/modules/helpers:179:18)
at Function.scopedRequire [as require] (***/node_modules/tsx/dist/register-BPRJR7M6.cjs:2:1770)
Bugs are expected to be fixed by those affected by it
[ ] I'm interested in working on this issue
Compensating engineering work financially will speed up resolution
Acknowledgements
Minimal reproduction URL
See below
Problem & expected behavior (under 200 words)
Calling
tsx.require()
on a JSON file from module"tsx/cjs/api"
throws a SyntaxError since 4.13.0, and worked in previous version 4.12.1 (https://github.com/privatenumber/tsx/compare/v4.12.1...v4.13.0)Reproduction steps
Tested on node v20.12.2
Outputs the JSON object
Throws a
SyntaxError
Bugs are expected to be fixed by those affected by it
Compensating engineering work financially will speed up resolution