google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.17k stars 580 forks source link

Setup module.exports first #2129

Closed arv closed 8 years ago

arv commented 8 years ago

This gives some much needed love to the CommonJS module output.

Most importantly it mutates the module.exports object before the code is executed which allows some cyclic dependencies to work (function declarations).

This also changes the transformer to work on the original code instead of the already transformed code (from ModuleTransformer).

Things have been refactored so that more code is shared between CommonJsModuleTransformer and ModuleTransformer.

Also, the require variable binding (with __esModule) has changed so that we do not need temp variables (outside what is needed for destructuring).

arv commented 8 years ago

@johnjbarton PTAL

johnjbarton commented 8 years ago

LGTM