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,

    1. Which compiler and options to use, including language mode and any specific Compiler subclass. This is handled by BaseTranspiler accepting a CompilerSupplier.
    2. 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.
    3. Specification of a sourceURL, handling of goog.module, or other postprocessing, such as wrapping the script in eval. This is left to other collaborators.
    4. Caching. This is handled by a CachingTranspiler that decorates an existing Transpiler with caching behavior.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Transpiler NULL
      Null implementation that does no transpilation at all.
    • 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.