Interface Transpiler
-
- All Known Implementing Classes:
BaseTranspiler
,CachingTranspiler
public interface Transpiler
Common interface for a transpiler.There are a number of considerations when implementing this interface. Specifically,
- Which compiler and options to use, including language mode and any
specific Compiler subclass. This is handled by
BaseTranspiler
accepting aCompilerSupplier
. - Whether or not to generate external or embedded source maps. This
is handled by returning a
TranspileResult
, which is able to return any combination of embedded or external source map. - Specification of a
sourceURL
, handling ofgoog.module
, or other postprocessing, such as wrapping the script ineval
. This is left to other collaborators. - Caching. This is handled by a
CachingTranspiler
that decorates an existingTranspiler
with caching behavior.
-
-
Field Summary
Fields Modifier and Type Field Description static Transpiler
NULL
Null implementation that does no transpilation at all.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
runtime()
Returns any necessary runtime code as a string.TranspileResult
transpile(java.net.URI path, java.lang.String code)
Transforms the given chunk of code.
-
-
-
Field Detail
-
NULL
static final Transpiler NULL
Null implementation that does no transpilation at all.
-
-
Method Detail
-
transpile
TranspileResult transpile(java.net.URI path, java.lang.String code)
Transforms the given chunk of code. The input should be an entire file worth of code.
-
runtime
java.lang.String runtime()
Returns any necessary runtime code as a string. This should include everything that could possibly be required at runtime, regardless of whether it's actually used by any of the code that will be transpiled.
-
-