Skip to content

Use Google Closure Compiler instead of UglifyJS2#4

Merged
wildlyinaccurate merged 1 commit intomasterfrom
closure-compiler
Oct 16, 2016
Merged

Use Google Closure Compiler instead of UglifyJS2#4
wildlyinaccurate merged 1 commit intomasterfrom
closure-compiler

Conversation

@wildlyinaccurate
Copy link
Copy Markdown
Owner

@wildlyinaccurate wildlyinaccurate commented Oct 16, 2016

With webpack -p

Bundle size: 59K / 15K gzipped

uglify

With webpack --optimize-occurence-order and GCC

Bundle size: 41K / 13K gzipped 30% / 13% smaller

gcc

@wildlyinaccurate
Copy link
Copy Markdown
Owner Author

Comparison with be66655

Bundle size: 290K / 78K gzipped

old

This changeset consists of several parts.

First, in order to get the most out of GCC's advanced optimisations, I need to
make use of its ability to parse ES6 (`language_in=ECMASCRIPT6`). This means
that the es2015 Babel transformations are not only superfluous, but are
detrimental to GCC's optimiser. After trying Rollup and the
`transform-es2015-modules-commonjs` Babel transformer, I decided that was using
CommonJS was the path of least resistance.

Next, GCC's advanced optimisations rename object properties. This is especially
for this codebase not only because of the interoperation with other libraries,
but also because of the consumption of remote JSON files. To work around this,
much of the object property notation has been converted to use `obj['prop']`
rather than `obj.prop` notation.

Finally, Webpack's default minimize optimisation is disabled. Since `-p`
implies `--optimize-minimize --optimize-occurence-order`, I now run
`webpack --optimize-occurence-order` and allow the GCC Webpack plugin to
perform its own minimize optimisations.
@wildlyinaccurate wildlyinaccurate merged commit bfd8fc7 into master Oct 16, 2016
@wildlyinaccurate wildlyinaccurate deleted the closure-compiler branch October 16, 2016 22:48
wildlyinaccurate added a commit that referenced this pull request Oct 19, 2016
Use Google Closure Compiler instead of UglifyJS2
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.

1 participant