swc
swc copied to clipboard
Huge memory usage when compiling a particular JS library
Describe the bug
When I compile code that imports react-ziggeo with webpack or spack, it makes the Node process run out of memory. This happens only on Windows. When I do the same inside WSL or on Linux for example, compilation finishes successfully.
Example:
$ npx webpack
memory allocation of 23124316044 bytes failed
/c/Program Files/nodejs/npx: line 35: 3789 Segmentation fault "$NODE_EXE" "$NPX_CLI_JS" "$@"
Example screenshot of RAM usage from Process Explorer:

Input code
import ReactZiggeo from 'react-ziggeo';
export default function MyComponent() {
return <ReactZiggeo/>
}
See the attached archive (test.zip) for the full code (package.json, etc).
Config
.swcrc:
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true,
"classProperty": true,
"dynamicImport": false
}
},
"env": {
"mode": "entry",
"coreJs": 3
}
}
spack.config.js:
module.exports = {
entry: {
web: __dirname + "/test.js",
},
output: {
path: __dirname + "/dist",
},
};
Playground link
No response
Expected behavior
Expected to compile successfully and produce a bundle
Actual behavior
Fails to allocate memory and exits
Version
1.2.194, 1.2.196
Additional context
the problem is react-ziggeo includes a minified ziggeo-client-sdk which has about 2328342 characters in one line and 2866 with keyword which cause swc raised same number of WithInStrict error. After I change it to only emit part of error it works fine.
relative issues:
https://github.com/Ziggeo/ziggeo-client-sdk/issues/60
https://github.com/Ziggeo/react-ziggeo/pull/39#issuecomment-1104084682
btw, can we only print the code near the error happen? print the whole 2328342 characters in one line in console, looks really crazy.
Yeah I think so, thank you for investigating!