public class RewritePolyfills extends java.lang.Object implements HotSwapCompilerPass
Also runs if polyfill isolation is enabled, even if polyfill injection is disabled, in order to prevent deletion of a required library function by dead code elimination.
TODO(b/120486392): consider merging this pass with InjectRuntimeLibraries
and InjectTranspilationRuntimeLibraries
.
Constructor and Description |
---|
RewritePolyfills(AbstractCompiler compiler,
boolean injectPolyfills,
boolean isolatePolyfills) |
Modifier and Type | Method and Description |
---|---|
void |
hotSwapScript(Node scriptRoot,
Node originalRoot)
Process the JS with root node root.
|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
public RewritePolyfills(AbstractCompiler compiler, boolean injectPolyfills, boolean isolatePolyfills)
injectPolyfills
- if true, injects $jscomp.polyfill initializations into the first input.
if false, no polyfills are injected.isolatePolyfills
- if true, adds externs for library functions used by IsolatePolyfills
to prevent their deletion.public void hotSwapScript(Node scriptRoot, Node originalRoot)
HotSwapCompilerPass
hotSwapScript
in interface HotSwapCompilerPass
scriptRoot
- Root node corresponding to the file that is modified,
should be of type Token.SCRIPT
.originalRoot
- Root node corresponding to the original version of the
file that is modified. Should be of type token.SCRIPT
.public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treeCopyright © 2009-2020 Google. All Rights Reserved.