question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

investigate Terser use for minification

See original GitHub issue

In a nutshell:

  • Webpack v4 uses uglifyjs-webpack-plugin for minification, which is actually based on uglify-es
  • We had to stop using that and instead use babel-minify-webpack-plugin a while ago because of minification issues #4871
  • babel-minify is still marked as beta on the website and last had an update ~3 months ago
  • babel-minify-webpack-plugin has not had an update in ~10 months
  • uglify-es is now no longer maintained and was eventually forked as Terser
  • Webpack plans to use Terser by default in v5 (next major release, still in development): https://github.com/webpack/webpack/pull/8036 and terser-webpack-plugin can be used in the interim

The webpack history itself is summarized neatly in this commit https://github.com/edmorley/webpack/commit/79910c6ba5c773aa5eeb4bb31aca12d405247067

I’m opening this issue up to explore whether there are benefits to switching over to using terser in our bundling before v5:

  • speed - is there a noticeable speed up when doing yarn build:prod?
  • bundle size - is it a smaller bundle compared to babel-minify? how much?
  • features - we need sourcemaps to help with getting sensible stack traces - are they still supported?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
brendonbribeirocommented, Jan 18, 2019

I ran some quick tests with terser by running yarn build: prod:

| Build time | Output Size – | – | – babel-minify | 85.36s | 43.401.373 bytes (45,9 MB) terser | 73.57s | 43.381.135 bytes (45,9 MB)

I recently switched from Uglify to Terser in another project, and it has considerably shortened our build time.

1reaction
shiftkeycommented, Mar 1, 2019

Thanks for the input @brendonbarreto and @j-f1.

For the moment I’d like to leave things as-is in here, and potentially revisit when Webpack 5 drops to see what benefits there might be to upgrade then (e.g. https://github.com/webpack/webpack/pull/8609).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minification: Wrestling with Terser and Webpack - YouTube
I hit an issue where minified code in production is breaking how I save page state because it depends on consistent class names....
Read more >
Reduce minified code size by property mangling | Tan Li Hau
This behavior of renaming variable name to compress JavaScript code is called Mangle. Terser has several Mangle options, that allows you to ...
Read more >
Minify JavaScript Using Terser - DEV Community ‍ ‍
Terser is a javascript compressor and mangler supporting ES6+ specification. In this tutorial, you will get to know how to use terser to...
Read more >
Fixing Overly Aggressive Optimization with Terser | by Omri Lavi
It looks like TerserPlugin was minifying too aggressively, and reducing functions with 1-character-length-names to 0-character-length-names.
Read more >
Using terser or alternative to minify and uglify js files
Terser did mangle your function and variable names, for more you need to use more Terser settings: github.com/terser/terser.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found