Skip to content

Reproduce performance regression of terser --compress collapse_vars=true on module with 1,000 var defs and complex object values.

Notifications You must be signed in to change notification settings

mlwilkerson/terser-collapse-vars-perf-regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Reproduce performance regression of terser --compress collapse_vars=true on module with 1,000 var defs and complex object values.

Steps to Reproduce

  1. yarn or npm install

  2. ./node_modules/.bin/terser --compress collapse_vars=true --output output.js index.js

This will produce a tree-shaken output bundle in about 30 seconds, depending on hardware.

Uses a current version of terser, the performance of which--in this scenario--is similar to [email protected], which is the package version that webpack 4.11.0 depends upon.

  1. ./node_modules/.bin/terser --compress collapse_vars=false --output output.js index.js

This will produce a tree-shaken output bundle in <1 second, depending on hardware.

Same version of terser.

  1. ./node_modules/.bin/uglifyjs --compress collapse_vars=true --output output.js index.js

This will produce a tree-shaken output bundle in <1 second, depending on hardware.

This uses [email protected], which is the package version that webpack 3.12.0 depends upon.

Conclusions

Something has changed in the processing of the collapse_vars option such that the performance in this scenario has slowed down by some 60x. I have seen real-world build times up to 80 seconds under [email protected] that would have taken 0.5 seconds under [email protected].

Associated GitHub Issues:

Background

This repro is designed to simulate a bundle produced by webpack after importing icon objects from Font Awesome 5 icon packages. Our icon packages each contain hundreds of var defs with object assignments where each object represents an icon's SVG definition. Users expect to be able to import a subset of icons from multiple icon packs and have the unused icons eliminated from the final production bundles. They also expect a fast build time.

About

Reproduce performance regression of terser --compress collapse_vars=true on module with 1,000 var defs and complex object values.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published