A micro, over-simplified compiler that turns ES6 import
statement into CommonJS require
statement.
Go ahead, clone the repo, npm install
, edit code in try.js
and run with node try.js
to see the compiler in action.
In order to better understand the parts of compiler, you shall edit code to check and see how different parts, at different stages generate different outputs.
You may love to read the concepts in more detail over here. Although, that explains for compiling call expression from Lisp-like to C-like statements. But should do to explain you a lot. :)
The super tiny compiler by James Kyle
MIT © yatharthk