rtfeldman / elm-spa-example

A Single Page Application written in Elm
https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
MIT License
3.29k stars 531 forks source link

Use uglifyjs `--no-rename` flag to compress and mangle in one step with `pure_funcs` #54

Closed kzc closed 6 years ago

kzc commented 6 years ago
$ uglifyjs elm.js --no-rename --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --mangle --output=elm.js

It's neccessary to disable the internal Uglify rename pass with --no-rename when you use the pure_funcs flag, because if you enable both --compress and --mangle at the same time, the pure_funcs argument will have no effect; Uglify will rename symbols first and then not recognize them when encountered later. Using two uglify commands works of course, but it invokes the parser twice which makes it a bit slower.

Doc update assumes the use of uglify-js@3.x.

The lesser known internal Uglify rename pass runs before compress and should not be confused with mangle which runs after compress.

kzc commented 6 years ago

Feel free to close unmerged. Just an FYI.