Class ModuleLoader
- java.lang.Object
-
- com.google.javascript.jscomp.deps.ModuleLoader
-
public final class ModuleLoader extends java.lang.ObjectProvides compile-time locate semantics for ES6 and CommonJS modules.- See Also:
- "https://tc39.github.io/ecma262/#sec-module-semantics", "http://wiki.commonjs.org/wiki/Modules/1.1"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModuleLoader.ModulePathA path to a module.static interfaceModuleLoader.ModuleResolverFactoryAn enum used to specify what algorithm to use to locate non path-based modulesstatic classModuleLoader.PathEscaperIndicates whether to escape characters in paths.static classModuleLoader.PathResolverAn enum indicating whether to absolutize paths.static classModuleLoader.ResolutionModeStandard path base resolution algorithms that are accepted as a command line flag.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FILENAME_PREFIXThe default module root, the current directory.static ModuleLoaderEMPTYA trivial module loader with no roots.static DiagnosticTypeINVALID_MODULE_PATHstatic java.lang.StringJSC_BROWSER_SKIPLISTED_MARKERstatic DiagnosticTypeLOAD_WARNINGstatic DiagnosticTypeMODULE_CONFLICTstatic java.lang.StringMODULE_SLASHAccording to the spec, the forward slash should be the delimiter on all platforms.
-
Constructor Summary
Constructors Constructor Description ModuleLoader(ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory)ModuleLoader(ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory, ModuleLoader.PathResolver pathResolver)ModuleLoader(ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory, ModuleLoader.PathResolver pathResolver, ModuleLoader.PathEscaper pathEscaper)Creates an instance of the module loader which can be used to locate ES6 and CommonJS modules.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorHandlergetErrorHandler()java.util.Map<java.lang.String,java.lang.String>getPackageJsonMainEntries()static booleanisAbsoluteIdentifier(java.lang.String name)Whether this is absolute to the compilation.static booleanisAmbiguousIdentifier(java.lang.String name)Whether this is neither absolute or relative.static booleanisPathIdentifier(java.lang.String name)Whether name is a path-based identifier (has a '/' character)static booleanisRelativeIdentifier(java.lang.String name)Whether this is relative to the current file, or a top-level identifier.ModuleLoader.ModulePathresolve(java.lang.String path)Resolves a path into aModuleLoader.ModulePath.voidsetErrorHandler(ErrorHandler errorHandler)
-
-
-
Field Detail
-
MODULE_CONFLICT
public static final DiagnosticType MODULE_CONFLICT
-
MODULE_SLASH
public static final java.lang.String MODULE_SLASH
According to the spec, the forward slash should be the delimiter on all platforms.- See Also:
- Constant Field Values
-
DEFAULT_FILENAME_PREFIX
public static final java.lang.String DEFAULT_FILENAME_PREFIX
The default module root, the current directory.- See Also:
- Constant Field Values
-
JSC_BROWSER_SKIPLISTED_MARKER
public static final java.lang.String JSC_BROWSER_SKIPLISTED_MARKER
- See Also:
- Constant Field Values
-
LOAD_WARNING
public static final DiagnosticType LOAD_WARNING
-
INVALID_MODULE_PATH
public static final DiagnosticType INVALID_MODULE_PATH
-
EMPTY
public static final ModuleLoader EMPTY
A trivial module loader with no roots.
-
-
Constructor Detail
-
ModuleLoader
public ModuleLoader(@Nullable ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory, ModuleLoader.PathResolver pathResolver, ModuleLoader.PathEscaper pathEscaper)Creates an instance of the module loader which can be used to locate ES6 and CommonJS modules.- Parameters:
moduleRoots- path prefixes to strip from module pathsinputs- all inputs to the compilation process. Used to ensure that resolved paths references an valid input.factory- creates a module resolver, which determines how module identifiers are resolvedpathResolver- determines how to sanitize paths before resolvingpathEscaper- determines if / how paths should be escaped
-
ModuleLoader
public ModuleLoader(@Nullable ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory, ModuleLoader.PathResolver pathResolver)
-
ModuleLoader
public ModuleLoader(@Nullable ErrorHandler errorHandler, java.lang.Iterable<java.lang.String> moduleRoots, java.lang.Iterable<? extends DependencyInfo> inputs, ModuleLoader.ModuleResolverFactory factory)
-
-
Method Detail
-
getPackageJsonMainEntries
public java.util.Map<java.lang.String,java.lang.String> getPackageJsonMainEntries()
-
resolve
public ModuleLoader.ModulePath resolve(java.lang.String path)
Resolves a path into aModuleLoader.ModulePath.
-
isRelativeIdentifier
public static boolean isRelativeIdentifier(java.lang.String name)
Whether this is relative to the current file, or a top-level identifier.
-
isAbsoluteIdentifier
public static boolean isAbsoluteIdentifier(java.lang.String name)
Whether this is absolute to the compilation.
-
isAmbiguousIdentifier
public static boolean isAmbiguousIdentifier(java.lang.String name)
Whether this is neither absolute or relative.
-
isPathIdentifier
public static boolean isPathIdentifier(java.lang.String name)
Whether name is a path-based identifier (has a '/' character)
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
-
getErrorHandler
public ErrorHandler getErrorHandler()
-
-