The idea is to have a nicely packaged solution that can be optimized and maintained separately, instead of having people maintain their own scripts with instructions to, for example, Uglify.js.
I built this for myself, but I hope it’s something you will want to use, contribute to, etc.
I am not a very experienced developer, so guidance and instructions of any kind from more senior community-members would be much appreciated!
This is definitely a good idea, better to have one tool that gives you the optimal uglifyjs set up out of the box than having to configure it yourself for every project.
It says in the elm docs that you have to do compress and then mangle in separate calls to uglfyjs for the pure_funcs optimisation to take effect:
Note 1:uglifyjs is called twice there. First to --compress and second to --mangle . This is necessary! Otherwise uglifyjs will ignore our pure_funcs flag.
But once this issue is resolved I think this would a very useful tool!
Thank you! I’d appreciate issues submitted directly on Github, so I can follow up there
EDIT:
I tried reconfiguring the implementation to “mangle” in a separate call, but got the same output. I’m not sure if this is related to the version of Uglify.js I’m using or something else.
I definitely want to have this optimized to run fast and produce the smallest possible output while maintaining Elms runtime guarantees, so I’ll investigate further on Github!
After npm install -g elm-minify, I cd'd to a directory with an elm.js output of elm make and did elm-minify elm.js. It created a new file, elm.min.js, about half the size of the original, with a single line of minified JS, but no compression that I could see. The new file works. But I got the error below. Missing dependency?
$ elm-minify elm.js
/usr/local/lib/node_modules/elm-minify/src/cli.js:37
console.table({
^
TypeError: console.table is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/elm-minify/src/cli.js:37:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3