About one year ago, I talked with +Hajime Morrita and I said "The closure-compiler is very cool. But writing pass in Java & construct own compiler require a lot of time... If we can write pass in JS and re-construct own JS compiler by script, this is very exciting".
After that, I dreamed creating minimum modules and constructing JS AOT compiler with them.

At the end of last year, #Esprima   was created by +Ariya Hidayat 

And I created #Escodegen  , ECMAScript code generator as backend.
GitHub is a very interesting spot... Thanks to contributions by a lot of ECMAScripters, #Escodegen   has a minifying option.

Now above tools are used widely as ECMAScript transpiler infrastructure. For example,

- LLJS: new language targeting JS from Mozilla

- sweet.js: macro system on JS from Mozilla

- istanbul: code coverage tool from Yahoo

- CoffeeScriptRedux: new coffee-script compiler project

use #Escodegen   as their ECMAScript backend.
NOTE: blog entry about writing new programming language on the top of them (entry written in Japanese) http://blog.64p.org/entry/2012/09/08/090729

And thanks to Michael Ficarra, #Escodegen  can recognize location information attached to AST and generate source-map.
As the result, new coffee-script compiler using #Escodegcan  as backend can generate source-map.

Finally, I created #Esmangle  : ECMAScript mangler, minifier & optimizer.
This consists of a lot of simple passes applied to AST.
We can easily write new original pass and apply it to JS AST.
Optimizer resolves fixed point of AST by iterative approach.
Because #Esmangle   preserves location information correctly, we can get source-map from mangled & optimized script to original code, such as coffee-script.

And I also created #Doctrine   JSDoc parser to parse JSDoc structurally. It is necessary to recognize JSDoc in AST.
I'm planning to create advanced optimization passes or type warning pass by using it.

We almost reach JS AOT compiler written in JS. It's time to construct your own compiler in JS!
Shared publiclyView activity