Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression] SyntaxError when calling require() on a JSON file since 4.13.0 #587

Closed
4 of 6 tasks
geotry opened this issue Jun 12, 2024 · 1 comment
Closed
4 of 6 tasks
Labels

Comments

@geotry
Copy link

geotry commented Jun 12, 2024

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I am reporting a confirmed bug (not seek debugging help)
  • I understand this is a collaborative project and relies on my contributions
  • I read and understood the Contribution guide

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 (v4.12.1...v4.13.0)

Reproduction steps

Tested on node v20.12.2

Outputs the JSON object

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

  • I'm willing to offer financial support
@geotry geotry added bug Something isn't working pending triage labels Jun 12, 2024
@privatenumber
Copy link
Owner

🎉 This issue has been resolved in v4.15.3

If you rely on this project, please consider making a donation ❤️ 🙏

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants