Package com.google.javascript.jscomp
Class ProcessCommonJSModules
java.lang.Object
com.google.javascript.jscomp.ProcessCommonJSModules
- All Implemented Interfaces:
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Process the JS with root node root.static String
toModuleName
(String filename) Turns a filename into a JS identifier that is used for moduleNames in rewritten code.static String
toModuleName
(String requiredFilename, String currentFilename) Turn a filename into a moduleName with support for relative addressing with ./ and ../ based on currentFilename;
-
Field Details
-
DEFAULT_FILENAME_PREFIX
- See Also:
-
-
Method Details
-
process
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
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
Turn a filename into a moduleName with support for relative addressing with ./ and ../ based on currentFilename;
-