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

Intent to replace terser with esbuild #9693

Closed

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Nov 5, 2021

Draft PR to test things out.

Todos:

  • acquire better package name from @alexlafroscia <3
    • (or rename to ember-cli-esbuild-minification, since this effort is minification focused to improve the build speed of production builds)
    • (or merge with @alexlafroscia's package, and only use a newly added minification api / addition)
  • find & replace @nullvoxpopuli/ember-cli-esbuild with whatever that new package is
  • see if expected source map behaviors are defined anywhere and ensure they still work
  • ember-cli to drop support for node 12? EOL is 2022-04-30... so... I wonder what it would take for ember-cli-esbuild to support node 12 πŸ€”

Related PRs:

Stats from a pretty-largeβ„’ app internally:

Instead of looking at total build time, I remembered that it'd be better to look at total time spent minifying.
These stats came from the results of:

DEBUG="*terser*" ember build --environment=production # in the terser / default branch
DEBUG="*esbuild*" ember build --environment=production # in the esbuild branch

Stats Collection: https://docs.google.com/spreadsheets/d/1Q1Lhkt_N8LjfRFkrH06AXN3mxn5L2CGh4SW8tNSy720/edit#gid=0

  • assets/chunk.some-chunk.js (~382KB)
    • 92% faster (took 8% of the time terser did)
    • final size 373.25 KB vs terser's 372.52 KB
  • assets/app-name.js (~1078KB)
    • 90% faster (took 10% of the time terser did)
    • final size 681.8KB vs terser's 656.72KB
  • assets/vendor.js (~18MB)
    • 95% faster (took 5% of the time terser did)
    • final size 9.39MB vs terser's 9.08MB

using esbuild@0.13.12
minification benchmark comparison between tools

NOTE: final size is not gzipped or brotli'd. just post-minification

@alexlafroscia
Copy link
Contributor

I'm happy to donate the package name or something, if you can find a way to make it useful 😬 I never got around the fact that decorators would need Babel still, so esbuild was unable to replace Babel, which was my original goal.

If you can find some other useful thing that esbuild can do for the community, I'm happy to let you take the package name and run with it πŸ€·β€β™‚οΈ

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Nov 6, 2021

looks like they've recentlyish added support for decorators? evanw/esbuild#104

but, we have a bunch of other custom plugins, like, debug macros. But maybe if we can do all our custom stuff in babel, which is pretty light on cpu, compared to what's happening today), we'll still get some good perf gains?

I'm going to investigate this on monday

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Nov 15, 2021

More stats

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            (index)             β”‚    time    β”‚    Ξ”t     β”‚ app   .js β”‚ app    Ξ”.js β”‚ app   .js.br β”‚ app    Ξ”.js.br β”‚ app   .js.gz β”‚ app    Ξ”.js.gz β”‚ vendor.js  β”‚ vendor Ξ”.js β”‚ vendor.js.br β”‚ vendor Ξ”.js.br β”‚ vendor.js.gz β”‚ vendor Ξ”.js.gz β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Default Terser         β”‚ '5m 7.9s'  β”‚ '+87.12%' β”‚ '2.13 MB' β”‚    '+0%'    β”‚ '148.81 kB'  β”‚     '+0%'      β”‚ '214.77 kB'  β”‚     '+0%'      β”‚ '13.11 MB' β”‚    '+0%'    β”‚  '1.71 MB'   β”‚     '+0%'      β”‚  '2.37 MB'   β”‚     '+0%'      β”‚
β”‚ Terser w/ sequences/semicolons β”‚ '4m 35.4s' β”‚ '+67.36%' β”‚ '2.13 MB' β”‚    '+0%'    β”‚ '148.81 kB'  β”‚     '+0%'      β”‚ '214.77 kB'  β”‚     '+0%'      β”‚ '13.11 MB' β”‚    '+0%'    β”‚  '1.71 MB'   β”‚     '+0%'      β”‚  '2.37 MB'   β”‚     '+0%'      β”‚
β”‚        Default ESBuild         β”‚ '2m 44.5s' β”‚   '+0%'   β”‚ '2.16 MB' β”‚  '+1.41%'   β”‚ '150.82 kB'  β”‚    '+1.35%'    β”‚ '220.99 kB'  β”‚    '+2.9%'     β”‚ '13.61 MB' β”‚  '+3.85%'   β”‚  '1.81 MB'   β”‚    '+6.14%'    β”‚  '2.54 MB'   β”‚    '+6.95%'    β”‚
β”‚          Default SWC           β”‚ '3m 56.9s' β”‚  '+44%'   β”‚ '2.25 MB' β”‚  '+5.52%'   β”‚  '150.3 kB'  β”‚     '+1%'      β”‚ '218.29 kB'  β”‚    '+1.64%'    β”‚ '13.24 MB' β”‚  '+1.06%'   β”‚  '1.78 MB'   β”‚    '+4.19%'    β”‚  '2.44 MB'   β”‚    '+2.95%'    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

New tools:

Yet another new minifier:

@patocallaghan
Copy link
Contributor

@NullVoxPopuli what's the status on this prototype? are you using it anywhere?

@NullVoxPopuli
Copy link
Contributor Author

yeah, I don't think it makes sense to replace terser with esbuild at this time as the tradeoffs aren't so easy to make, and will vary depending on your app's needs.
Like, my company's many many apps are all using this, but we're favoring speed over minification -- if you're favoring minification, terser is hard to beat -- only SWC would be an option, I think -- there are some perf benefits with SWC used for the same purpose, and that's demonstrated here: https://github.com/NullVoxPopuli/ember-cli-swc-minifier
But, it's slower than ESBuild for minification (because ESBuild does less) -- I think this is kinda shown by the benchmarking done earlier -- but I haven't re-ran any of that since both SWC and ESBuild have been so actively developed -- would be interested to re-run the benches.

I think it may make sense to provide a minifier as an option to folks -- and all of these libraries can be used today -- folks need only be informed of the tradeoffs they're making.

@patocallaghan
Copy link
Contributor

Interesting, thanks for the response. I might give this a run over our app, curious to see how it holds up. We're trying to improve deploy times and the production build is a major bottleneck. Be interesting to see the difference in payload size between ESBuild and Terser for us.

@bertdeblock
Copy link
Contributor

Closing for now if that's okay!

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

4 participants