3 ms·
The title of this submission omits the best part; closure provides static type checking. That is more valuable to me than the dead code removal & minification.
by dahart 11y ago
The title of this submission omits the best part; closure provides static type checking. That is more valuable to me than the dead code removal & minification.
I just discovered an amazing and nearly undocumented feature of the Closure Compiler: the --module flag.
One of the most inconvenient parts of using closure is having to compile each page separately. That's what the Closure docs say to do: https://developers.google.com/closure/compiler/docs/api-tutorial3#separately https://developers.google.com/closure/compiler/docs/api-tuto...
That means if you have 10 pages, you have 10 compile passes, even if 95% of your code is shared. But, it turns out you can run a compile pass and output multiple compiled .js files simultaneously! This has cut my build times by 10x.
So, anyone with long build times due to multiple separate builds, poke around and find out how to use --module!
- nickik 11y agoIn ClojureScript there is a attempted going to make Closure Compiler Modules work with other modules: https://github.com/clojure/clojurescript/wiki/Google-Summer-of-Code-2015 https://github.com/clojure/clojurescript/wiki/Google-Summer-...
- swannodette 11y agoThe Google Summer of Code project is unrelated to code splitting which is what --modules is referring to in this context. The ClojureScript GSoC project was about integrating the variety of JS module formats (CommonJS, AMD, ES2015) found in the wild as well as supporting preprocessing phases (React's JSX).
- sgrove 11y agoI think it's likely that long-term, the approach FB took with Flow (or more general Abstract Interpretation methods) should be able to handle more cases with less effort on the developer's side (albeit with increased computational costs). The modules/"code motion" is a bit strange at first glance, but definitely a huge boon for building debuggers/admin interfaces/etc. that you don't want included in your main application. David Nolen wrote about this earlier this year when support started landing in ClojureScript http://swannodette.github.io/2015/04/07/in-stillness-movement/ http://swannodette.github.io/2015/04/07/in-stillness-movemen... Edit: wrt Flow, specifically referring to FB's approach to retrofitting type-checking into a largely dynamic language. Thanks to swannodette for pointing out the ambiguity.
- swannodette 11y agoIt's not clear what you're referring to wrt. "the approach FB took with Flow" and Abstract Interpretation. Type checking? Dead code elimination? In anycase, Google Closure Compiler also leverages Abstract Interpretation.
- sgrove 11y agoThanks for pointing out the ambiguity. Closure would probably be the most interesting (or close to the most interesting) project to work on inside of Google-proper, for me personally. That said, Google's approach is very much on the opposite side of FB's, in that Google expects the vast majority of code to be written for it. FB is dealing with a legacy codebase and has fewer engineers, so has to strike a different set of tradeoffs - less up-front work to integrate their tooling for potentially less benefit than something like Closure can deliver. It's interesting to see the two different approaches. Anyway, this thread is about Closure, which enables ClojureScript, which is my go to language these days. The developers working on the compiler and the stdlib (which is amazing) should feel proud about all the people they've enabled.
- yclept 11y agoCheck out plovr http://plovr.com/ http://plovr.com/
- dang 11y ago> The title of this submission omits the best part We reverted the submitted title ("Closure Compiler parses JavaScript, removes dead code, minimizes what's left"). Submitters: please don't use the titles of HN stories to editorialize. If you want to say what you think is important about an article, please do so in the thread, where all commenters are equal.