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:

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