5 ms·
Tools like acorn[1] and Esprima[2] can parse the JavaScript source and output an ESTree compliant syntax tree. Then you can traverse it and modify it like any
by concise_unicorn 10y ago
Tools like acorn[1] and Esprima[2] can parse the JavaScript source and output an ESTree compliant syntax tree.
Then you can traverse it and modify it like any other AST.
[1] https://github.com/ternjs/acorn https://github.com/ternjs/acorn
[2] http://esprima.org/ http://esprima.org/
[3] https://github.com/estree/estree https://github.com/estree/estree