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

After switching to SWC in a project with a large number of components the build freezes #10011

Open
s1owjke opened this issue Nov 17, 2024 · 0 comments

Comments

@s1owjke
Copy link

s1owjke commented Nov 17, 2024

🐛 bug report

After switching to optimizer SWC if both shouldOptimize and shouldScopeHoist is true building a specific project with a large number of components freezes. On other projects either by disabling these options or by using Terser everything works as before.

🎛 Configuration (.babelrc, package.json, cli command)

.env

NODE_ENV=production

.parcelrc

{
  bundler: '@parcel/bundler-default',
  transformers: {
    'types:*.{ts,tsx}': ['@parcel/transformer-typescript-types'],
    '*.{js,jsx,mjs,ts,tsx}': ['@parcel/transformer-babel', '@parcel/transformer-js'],
    'url:*': ['...', '@parcel/transformer-raw'],
  },
  namers: ['@parcel/namer-default'],
  runtimes: ['@parcel/runtime-js'],
  optimizers: {
    '*.{js,mjs,cjs}': ['@parcel/optimizer-swc'],
  },
  packagers: {
    '*.{js,mjs,cjs}': '@parcel/packager-js',
    '*.ts': '@parcel/packager-ts',
    '*': '@parcel/packager-raw',
  },
  compressors: {
    '*': ['@parcel/compressor-raw'],
  },
  resolvers: ['@parcel/resolver-default'],
  reporters: [],
}

Parcel options

{
  mode: 'production',
  defaultTargetOptions: {
    shouldOptimize: true,
    shouldScopeHoist: true,
    sourceMaps: false,
  },
}

🤔 Expected Behavior

The build must be complete without errors.

😯 Current Behavior

The build freezes for a long time, after many runs I was able to get 2 different errors:

1. illegal hardware instruction
2. interrupted by signal 4:SIGILL

💁 Possible Solution

Looks like a bug on the edge of SWC and Parcel. Maybe it's just an incorrect input for SWC during the build in that specific case that causes freeze, I don't rule out that it is also a bug in SWC itself.

🔦 Context

I have a project to compare the performance of popular javascript bundlers, I tried to update the configuration for Parcel to match the latest one and use SWC instead of Terser.

I started taking measurements and everything is working fine with all projects except last one, which is a project with 5000 small generated components (BTW: other bundlers that use SWC don't have such problems).

To be sure, I also checked another amd64 architecture on which everything is also reproduced.

The last mention of a bug with a similar message was here, it was on a different CPU architecture and solved by changing the build flags.

💻 Code Sample

Use to parcel-swc branch from js-bundler-benchmark repository, here are the steps to reproduce it:

npm i
cd projects/react-synthetic && npm i && cd ../..
npm run build:parcel -- --project react-synthetic --entrypoint src/index.tsx

🌍 Your Environment

Type Version(s)
Parcel 2.13.0
Node 20.17.0, 20.18.0
npm 10.8.2
Operating System Mac Os 15.1 (24B83), Ubuntu 24.04 (20240927)
CPU Apple M2 Pro, Intel Xeon E5-2686 v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant