Skip to content

Switch to SWC minifier by default#8860

Merged
devongovett merged 3 commits into
v2from
swc-optimizer
Mar 3, 2023
Merged

Switch to SWC minifier by default#8860
devongovett merged 3 commits into
v2from
swc-optimizer

Conversation

@devongovett

Copy link
Copy Markdown
Member

This replaces Terser with the SWC minifier by default. In testing large real-world apps, we see a significant performance improvement of 15-20% with slightly smaller output as well. Since SWC supports the same configuration options as terser, it is a drop in replacement. Next.js recently enabled it by default as well, so it seems stable at this point.

Aside from switching the default config over, this also fixes a few tests that now have slightly different output, and converts errors to Parcel diagnostics.

@danieltroger

Copy link
Copy Markdown
Contributor

FYI I had to switch back since my .terserrc is not supported:

{
  "mangle": {
    "eval": true,
    "properties": {
      "regex": "^(?!__core-js_shared__).*_$"
    }
  },
  "compress": {
    "unsafe": true,
    "arguments": true,
    "ecma": "2020",
    "passes": 4,
    "unsafe_arrows": true
  },
  "format": {
    "ecma": 2020
  }
}

@mischnic

mischnic commented Aug 4, 2023

Copy link
Copy Markdown
Member

@danieltroger Please open a new issue with the actual error message about which property isn't supported. Ideally in the swc repo
swc already made some changes to support all terserrcs in the past: #9174, #9041

@danieltroger

Copy link
Copy Markdown
Contributor

-> swc-project/swc#7754

lettertwo added a commit that referenced this pull request Nov 6, 2023
* upstream/v2: (128 commits)
  [webextension] Add support for `chrome_style` (#8867)
  Switch to SWC minifier by default (#8860)
  Use BitSet for bundler intersections (#8862)
  best key logic truncating package names (#8865)
  Add support for loadConfig to resolver plugins (#8847)
  Missing edge for multiple targets (#8854)
  Split large runtime manifest into separate bundles (#8837)
  Improvements to new resolver (#8844)
  Fix published files for resolver
  New resolver implementation in Rust (#8807)
  Update yarn.lock (#8843)
  Bump napi-rs to latest (#8838)
  Support .proxyrc.cjs  (#8833)
  Sort global deps before injecting imports (#8818)
  Sort CSS module exports (#8817)
  fix: add extra information to unique bundles (#8784)
  Don't blow up HMR when <link />s don't have hrefs (#8800)
  v2.8.3
  Changelog for v2.8.3
  Address bug by updating an asset reference and merge conditions (#8762)
  ...
@jboler

jboler commented Nov 12, 2023

Copy link
Copy Markdown

When building my app with parcel 2.10.2 vs 2.8, my bundle is ~15% larger. I inspected the minified bundle and found that no comments were being removed at all.

I added this to a .terserrc and it removed most of the comments except some copyright comments:

{
  "format": {
    "comments": "some"
  }
}

Whereas parcel 2.8 would leave only the copyright/license comments by default. Is the intention to default to leaving comments in the minified bundle in parcel 2.10?

@devongovett

Copy link
Copy Markdown
Member Author

Looks like there was a regression in SWC minifier recently. But appears to be fixed in the latest nightly version of @swc/core (in swc-project/swc#8257).

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

Successfully merging this pull request may close these issues.

5 participants