-
Notifications
You must be signed in to change notification settings - Fork 663
Description
Reproduction link or steps
foo.json:
{
"eval": "ok"
}index.ts:
import json from "./foo.json";
console.log(json)What is expected?
I expect no errors to be thrown.
What is actually happening?
This is the resulting code after passing it through rolldown:
//#region foo.json
var eval = "ok";
var foo_default = { eval };
//#endregion
//#region index.ts
console.log(foo_default);
//#endregionAnd this happens when you run it.
node ./foo.mjs
file:///Users/marvinh/dev/rolldown-json-bug/foo.mjs:2
var eval = "ok";
^^^^
SyntaxError: Unexpected eval or arguments in strict mode
at compileSourceTextModule (node:internal/modules/esm/utils:351:16)
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:107:18)
at #translate (node:internal/modules/esm/loader:546:12)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:593:27)
at async #link (node:internal/modules/esm/module_job:172:19)System Info
System:
OS: macOS 15.6.1
CPU: (10) arm64 Apple M2 Pro
Memory: 104.50 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.2.0 - ~/.nvm/versions/node/v24.2.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 11.3.0 - ~/.nvm/versions/node/v24.2.0/bin/npm
pnpm: 10.15.1 - ~/Library/pnpm/pnpm
Watchman: 2025.05.26.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 139.0.7258.157
Safari: 18.6Any additional comments?
No response
Metadata
Metadata
Assignees
Labels
No labels