Package com.google.javascript.jscomp
Class ProcessCommonJSModules
- java.lang.Object
-
- com.google.javascript.jscomp.ProcessCommonJSModules
-
- All Implemented Interfaces:
CompilerPass
public class ProcessCommonJSModules extends java.lang.Object implements CompilerPass
Rewrites a CommonJS module http://wiki.commonjs.org/wiki/Modules/1.1.1 into a form that can be safely concatenated. Does not add a function around the module body but instead adds suffixes to global variables to avoid conflicts. Calls to require are changed to reference the required module directly. goog.provide and goog.require are emitted for closure compiler automatic ordering.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FILENAME_PREFIX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(Node externs, Node root)
Process the JS with root node root.static java.lang.String
toModuleName(java.lang.String filename)
Turns a filename into a JS identifier that is used for moduleNames in rewritten code.static java.lang.String
toModuleName(java.lang.String requiredFilename, java.lang.String currentFilename)
Turn a filename into a moduleName with support for relative addressing with ./ and ../ based on currentFilename;
-
-
-
Field Detail
-
DEFAULT_FILENAME_PREFIX
public static final java.lang.String DEFAULT_FILENAME_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
process
public void process(Node externs, Node root)
Description copied from interface:CompilerPass
Process the JS with root node root. Can modify the contents of each Node tree- Specified by:
process
in interfaceCompilerPass
- Parameters:
externs
- Top of external JS treeroot
- Top of JS tree
-
toModuleName
public static java.lang.String toModuleName(java.lang.String filename)
Turns a filename into a JS identifier that is used for moduleNames in rewritten code. Removes leading ./, replaces / with $, removes trailing .js and replaces - with _. All moduleNames get a "module$" prefix.
-
toModuleName
public static java.lang.String toModuleName(java.lang.String requiredFilename, java.lang.String currentFilename)
Turn a filename into a moduleName with support for relative addressing with ./ and ../ based on currentFilename;
-
-