Closure compiler?

Anyone managed to get the closure compiler to remove dead code from Elm-generated JS?

This generates valid JS:
$ closure-compiler --language_in ECMASCRIPT5 --compilation_level ADVANCED_OPTIMIZATIONS main.js > main_min.js
but it still has unused code in there.

Looking at closure-compiler --help it mentions --closure_entry_point which needs goog.provide. Maybe that is the right direction? I would prefer not to go into JS module land, so this is where it stops being funny.

I’m not looking for minifiation or bundling or anything else, I’m only after removing dead code stuff (and even then mostly to stop bundling unused icons from http://package.elm-lang.org/packages/jystic/elm-font-awesome/3.0.0 ).
Thoughts?

2 Likes

Assets management is the primary focus of 0.19 and, as far as I understand, this will also extend the level of DCE.

In the mean time maybe take a look at this thread. Maybe elm-pre-minify might help in your scenario.

Thanks. That thread indeed explains why the unused variables are not removed, and I see no {easy|0.18} way around that… Ohwell, too bad.

But taking things out when code is already compiled to JS is much more roundabout then not putting it in the JS in first place. Are there any improvements planned on that side? In this case it’s about the dozens of functions provided by http://package.elm-lang.org/packages/jystic/elm-font-awesome/3.0.0/FontAwesome-Solid where you’d only use a handful.

Yes, I believe this is planned for 0.19. In 0.18 an entire module can be included/excluded but not more fine grained than that.