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

Add swc optimizer #7212

Merged
merged 2 commits into from Nov 2, 2021
Merged

Add swc optimizer #7212

merged 2 commits into from Nov 2, 2021

Conversation

mischnic
Copy link
Member

This just adds the plugin, I didn't change the config (so similar to the esbuild optimizer)

Essentially using @swc/core instead of terser.

@height
Copy link

height bot commented Oct 29, 2021

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

parcel-benchmark commented Oct 29, 2021

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 2.17s +99.00ms
Cached 272.00ms +6.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 692.00ms +48.00ms ⚠️
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 693.00ms +48.00ms ⚠️
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 693.00ms +49.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/index.html 826.00b +0.00b 1.15s +76.00ms ⚠️
dist/modern/index.html 749.00b +0.00b 1.15s +77.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 10.72s +371.00ms
Cached 446.00ms -15.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.15m +3.00ms
Cached 1.59s -72.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Three.js ✅

Timings

Description Time Difference
Cold 7.13s +23.00ms
Cached 375.00ms +32.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@devongovett
Copy link
Member

Have you tested it on anything? Any early results?

@mischnic
Copy link
Member Author

mischnic commented Oct 29, 2021

ak-editor (total size of distdir with 98 JS bundles)

time parcel2c build . --no-source-maps | cat

swc:  8.530mb
24.535s

terser: 8.484mb
40s

esbuild: 9.027mb
18.3s

without an optimizer: 22.639mb
15.706s

Errors I ran into when trying to minify swc:

@mischnic
Copy link
Member Author

mischnic commented Nov 1, 2021

I've updated the timings with the actual values now.

Merging this would make testing easier, you can then easily add it into any existing project. And because it uses @swc/core from npm, any bugs that are fixed upstream in swc can be pulled in by bumping the project's lockfile.

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to merge as an experimental plugin. A little disappointed that the perf difference vs terser isn't more though...

@devongovett devongovett merged commit 012380f into v2 Nov 2, 2021
@devongovett devongovett deleted the swc-optimizer branch November 2, 2021 16:23
lettertwo added a commit that referenced this pull request Nov 15, 2021
* v2: (68 commits)
  Fix RangeError in `not export` error with other file type (#7295)
  Apply sourcemap in @parcel/transformer-typescript-tsc (#7287)
  Fix side effects glob matching (#7288)
  Fix changelog headings
  v2.0.1
  Changelog for v2.0.1
  Resolve GLSL relative to the importer, not the asset (#7263)
  fix: add @parcel/diagnostic as dependency of @parcel/transformer-typescript-types (#7248)
  Fixed missing "Parcel" export member in Module "@parcel/core" (#7250)
  Add script to sync engines with core version (#7207)
  Bump swc (#7216)
  Make Webpack loader detection regex dramatically faster (#7226)
  swc optimizer (#7212)
  Update esbuild in optimizer (#7233)
  Properly visit member expressions (#7228)
  Update to prettier 2 (#7209)
  Fix serve mode with target override and target source fields (#7187)
  Update package.json to include the repository (#7184)
  fix #6730: add transformer-raw as dependency of config-webextension (#7193)
  Log warning instead of crash if image optimizer fails (#7119)
  ...
lettertwo added a commit that referenced this pull request Nov 15, 2021
* v2: (68 commits)
  Fix RangeError in `not export` error with other file type (#7295)
  Apply sourcemap in @parcel/transformer-typescript-tsc (#7287)
  Fix side effects glob matching (#7288)
  Fix changelog headings
  v2.0.1
  Changelog for v2.0.1
  Resolve GLSL relative to the importer, not the asset (#7263)
  fix: add @parcel/diagnostic as dependency of @parcel/transformer-typescript-types (#7248)
  Fixed missing "Parcel" export member in Module "@parcel/core" (#7250)
  Add script to sync engines with core version (#7207)
  Bump swc (#7216)
  Make Webpack loader detection regex dramatically faster (#7226)
  swc optimizer (#7212)
  Update esbuild in optimizer (#7233)
  Properly visit member expressions (#7228)
  Update to prettier 2 (#7209)
  Fix serve mode with target override and target source fields (#7187)
  Update package.json to include the repository (#7184)
  fix #6730: add transformer-raw as dependency of config-webextension (#7193)
  Log warning instead of crash if image optimizer fails (#7119)
  ...
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.

None yet

3 participants