Node: Feature request: add support for the Google Closure Compiler

Created on 25 Dec 2016  Â·  4Comments  Â·  Source: nodejs/node

When used with -O=ADVANCED, the Google Closure Compiler can apply known optimizations to the code to improve performance. It seems that some performance fixes are as simple as inlining a function (eg. #5127), and the Closure Compiler could automate these with a build step.

Thoughts?

feature request lib / src

Most helpful comment

Assuming we're talking about running the Closure Compiler on the JavaScript code in Node core, what would the upside be to automating things? It should be pretty easy to run the compiler against Node, see what optimisations it suggests, and then open PRs to add them to Node. That way we can make sure we trust the proposed optimisations (and not have to rerun the compiler all the time).

All 4 comments

The problem with this is that you end up with unreadable and possibly incorrect output (if dead code elimination made bad assumptions). At the very least this would affect stack traces.

The problem of lack of readability would be fixed by using source maps, which however aren't supported in Node.js (I couldn't find why, though); the problem of incorrect output relies on the solidity of the Closure Compiler, the correctness of manual type hints, and having complete coverage in regression tests.

Assuming we're talking about running the Closure Compiler on the JavaScript code in Node core, what would the upside be to automating things? It should be pretty easy to run the compiler against Node, see what optimisations it suggests, and then open PRs to add them to Node. That way we can make sure we trust the proposed optimisations (and not have to rerun the compiler all the time).

I’m going to close this as question that was answered by the last comment … if you feel there’s more to be done here, opening a PR that adds support for this might be the best idea. Feel free to reopen or ask follow-up questions, if you have any. :)

Was this page helpful?
0 / 5 - 0 ratings