Class ModuleLoader
- java.lang.Object
-
- com.google.javascript.jscomp.deps.ModuleLoader
-
public final class ModuleLoader extends java.lang.Object
Provides 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 class
ModuleLoader.ModulePath
A path to a module.static interface
ModuleLoader.ModuleResolverFactory
An enum used to specify what algorithm to use to locate non path-based modulesstatic class
ModuleLoader.PathEscaper
Indicates whether to escape characters in paths.static class
ModuleLoader.PathResolver
An enum indicating whether to absolutize paths.static class
ModuleLoader.ResolutionMode
Standard path base resolution algorithms that are accepted as a command line flag.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FILENAME_PREFIX
The default module root, the current directory.static ModuleLoader
EMPTY
A trivial module loader with no roots.static DiagnosticType
INVALID_MODULE_PATH
static java.lang.String
JSC_BROWSER_SKIPLISTED_MARKER
static DiagnosticType
LOAD_WARNING
static DiagnosticType
MODULE_CONFLICT
static java.lang.String
MODULE_SLASH
According 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 ErrorHandler
getErrorHandler()
java.util.Map<java.lang.String,java.lang.String>
getPackageJsonMainEntries()
static boolean
isAbsoluteIdentifier(java.lang.String name)
Whether this is absolute to the compilation.static boolean
isAmbiguousIdentifier(java.lang.String name)
Whether this is neither absolute or relative.static boolean
isPathIdentifier(java.lang.String name)
Whether name is a path-based identifier (has a '/' character)static boolean
isRelativeIdentifier(java.lang.String name)
Whether this is relative to the current file, or a top-level identifier.static java.lang.String
relativePathFrom(java.lang.String fromUriPath, java.lang.String toUriPath)
ModuleLoader.ModulePath
resolve(java.lang.String path)
Resolves a path into aModuleLoader.ModulePath
.void
setErrorHandler(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)
-
relativePathFrom
public static java.lang.String relativePathFrom(java.lang.String fromUriPath, java.lang.String toUriPath)
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
-
getErrorHandler
public ErrorHandler getErrorHandler()
-
-