Frage

I am currently using Closure/Plovr advanced mode to compile javascript.

I want to add some custom functionality, such as string replacements and variable renaming. The important thing is that it requires parsed syntax.

Is it possible to add this functionality? Is there an API for this or do I have to dive into the Closure code (which I don't really want to do).

War es hilfreich?

Lösung

There are no plugins for Closure-compiler. If the optimization does not exist, you would need to write it as a custom pass for the compiler.

Andere Tipps

Mike Bolin's book the Closure Definitive Guide has a chapter on this but it is a little dated. Adding a custom compiler pass is done via the Java API. Beware however, while the internal AST is stable it is subject to change without notice and when ES6 support is added you can certainly expect changes.

However, if you pass is generally useful, you might consider contributing it to the main tree.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top