Don't argue dead code elimination VS. AMD: Implement cross module code motion support for AMD (or CJS modules if you prefer) instead and you can have the best of both worlds: http://www.google.com/codesearch#l5BkQmivP-Y/trunk/src/com/google/javascript/jscomp/CrossModuleCodeMotion.java&q=codemotion%20package:http://closure-compiler%5C.googlecode%5C.com

The strategy: Source code is moved to the lowest level of the module hierarchy so that it becomes available just before it is needed. Implementing this should be relatively easy: Just emit goog.require/goog.provide statements for every define and things should work quite smoothly. There is one primary invariant that code has to keep: There must be a AST transformation for any given module that makes execution of the module without the surrounding closure result in semantically equivalent code. This should usually be possible by e.g. prepending the names of all module global variables with the name of the module.
CC +Alex Sexton +Paul Irish
Shared publiclyView activity