System Info
System:
OS: Windows 11 10.0.26200
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13800H
Memory: 15.39 GB / 63.67 GB
Binaries:
Node: 22.19.0 - C:\Program Files\nodejs\node.EXE
Yarn: 4.12.0 - C:\Program Files\nodejs\yarn.CMD
npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
bun: 1.3.2 - ~.bun\bin\bun.EXE
Browsers:
Edge: Chromium (140.0.3485.54)
Internet Explorer: 11.0.26100.7309
Details
Trying to import a JSON file containing a key that starts with !, like "!top", results in a JavaScript parse error: Unexpected token !. Expected identifier or string error when minifying via SWC or using the bundled code in other projects.
rslib (non bundled) generates the export key as export { __webpack_exports___top as !top, ... } instead of export { __webpack_exports___top as "!top", ... }.
I would expect rspack to use "!top" instead of !top.
Reproduce link
Link
Reproduce Steps
- Import the relevant JSON file via
import fileName from './file-name.json';
- Make sure that minification is enabled and run rslib build with format configured to esm
Example JSON:
{ "!top": [] }
System Info
System:
OS: Windows 11 10.0.26200
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13800H
Memory: 15.39 GB / 63.67 GB
Binaries:
Node: 22.19.0 - C:\Program Files\nodejs\node.EXE
Yarn: 4.12.0 - C:\Program Files\nodejs\yarn.CMD
npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
bun: 1.3.2 - ~.bun\bin\bun.EXE
Browsers:
Edge: Chromium (140.0.3485.54)
Internet Explorer: 11.0.26100.7309
Details
Trying to import a JSON file containing a key that starts with
!, like "!top", results in aJavaScript parse error: Unexpected token!. Expected identifier or stringerror when minifying via SWC or using the bundled code in other projects.rslib (non bundled) generates the export key as
export { __webpack_exports___top as !top, ... }instead ofexport { __webpack_exports___top as "!top", ... }.I would expect rspack to use
"!top"instead of!top.Reproduce link
Link
Reproduce Steps
import fileName from './file-name.json';Example JSON:
{ "!top": [] }