public final class ProcessCommonJSModules extends java.lang.Object implements CompilerPass
Modifier and Type | Field and Description |
---|---|
static DiagnosticType |
SUSPICIOUS_EXPORTS_ASSIGNMENT |
static DiagnosticType |
UNKNOWN_REQUIRE_ENSURE |
Constructor and Description |
---|
ProcessCommonJSModules(Compiler compiler)
Creates a new ProcessCommonJSModules instance which can be used to
rewrite CommonJS modules to a concatenable form.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getCommonJsImportPath(Node requireCall) |
static boolean |
isCommonJsExport(NodeTraversal t,
Node export)
Recognize if a node is a module export.
|
static boolean |
isCommonJsImport(Node requireCall)
Recognize if a node is a module import.
|
void |
process(Node externs,
Node root)
Module rewriting is done a on per-file basis prior to main compilation.
|
void |
process(Node externs,
Node root,
boolean forceModuleDetection) |
public static final DiagnosticType UNKNOWN_REQUIRE_ENSURE
public static final DiagnosticType SUSPICIOUS_EXPORTS_ASSIGNMENT
public ProcessCommonJSModules(Compiler compiler)
compiler
- The compilerpublic void process(Node externs, Node root)
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treepublic static boolean isCommonJsImport(Node requireCall)
- require("something"); - __webpack_require__(4); // only when the module resolution is WEBPACK
public static java.lang.String getCommonJsImportPath(Node requireCall)
public static boolean isCommonJsExport(NodeTraversal t, Node export)
- module.exports = something; - module.exports.something = something; - exports.something = something; - __webpack_exports__["something"] = something; // only when the module resolution is WEBPACK
In addition, we only recognize an export if the base export object is not defined or is defined in externs.
Copyright © 2009-2017 Google. All Rights Reserved.