Class BaseTranspiler.CompilerSupplier
- java.lang.Object
-
- com.google.javascript.jscomp.transpile.BaseTranspiler.CompilerSupplier
-
- Enclosing class:
- BaseTranspiler
public static class BaseTranspiler.CompilerSupplier extends java.lang.Object
Wraps the Compiler into a more relevant interface, making it easy to test the Transpiler without depending on implementation details of the Compiler itself. Also works around the fact that the Compiler is not thread-safe (since we may do multiple transpiles concurrently), so we supply a fresh instance each time when we're in single-file mode.
-
-
Field Summary
Fields Modifier and Type Field Description protected ModuleLoader.ResolutionMode
moduleResolution
protected com.google.common.collect.ImmutableList<java.lang.String>
moduleRoots
protected FeatureSet
outputFeatureSet
protected com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>
prefixReplacements
-
Constructor Summary
Constructors Constructor Description CompilerSupplier()
CompilerSupplier(FeatureSet outputFeatureSet)
CompilerSupplier(FeatureSet outputFeatureSet, ModuleLoader.ResolutionMode moduleResolution, com.google.common.collect.ImmutableList<java.lang.String> moduleRoots, com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> prefixReplacements)
Accepts commonly overridden options for ES6 modules to avoid needed to subclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BaseTranspiler.CompileResult
compile(java.net.URI path, java.lang.String code)
protected Compiler
compiler()
protected SourceFile
createEmptySource()
protected SourceFile
createTrivialExterns()
protected CompilerOptions
options()
java.lang.String
runtime(java.lang.String library)
protected void
setOptions(CompilerOptions options)
-
-
-
Field Detail
-
moduleResolution
protected final ModuleLoader.ResolutionMode moduleResolution
-
moduleRoots
protected final com.google.common.collect.ImmutableList<java.lang.String> moduleRoots
-
prefixReplacements
protected final com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> prefixReplacements
-
outputFeatureSet
protected final FeatureSet outputFeatureSet
-
-
Constructor Detail
-
CompilerSupplier
public CompilerSupplier()
-
CompilerSupplier
public CompilerSupplier(FeatureSet outputFeatureSet)
-
CompilerSupplier
public CompilerSupplier(FeatureSet outputFeatureSet, ModuleLoader.ResolutionMode moduleResolution, com.google.common.collect.ImmutableList<java.lang.String> moduleRoots, com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> prefixReplacements)
Accepts commonly overridden options for ES6 modules to avoid needed to subclass.- Parameters:
moduleResolution
- module resolution for resolving import pathsprefixReplacements
- prefix replacements for when moduleResolution isModuleLoader.ResolutionMode.BROWSER_WITH_TRANSFORMED_PREFIXES
-
-
Method Detail
-
compile
public BaseTranspiler.CompileResult compile(java.net.URI path, java.lang.String code)
-
runtime
public java.lang.String runtime(java.lang.String library)
-
compiler
protected Compiler compiler()
-
options
protected CompilerOptions options()
-
setOptions
protected void setOptions(CompilerOptions options)
-
createTrivialExterns
protected SourceFile createTrivialExterns()
-
createEmptySource
protected SourceFile createEmptySource()
-
-