public final class ES6ModuleLoader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_FILENAME_PREFIX
The default module root, the current directory.
|
(package private) static DiagnosticType |
LOAD_ERROR |
(package private) static java.lang.String |
MODULE_SLASH
According to the spec, the forward slash should be the delimiter on all platforms.
|
private java.util.List<URI> |
moduleRootUris
The root URIs that modules are resolved against.
|
private java.util.Set<URI> |
moduleUris
The set of all known input module URIs (including trailing .js), after normalization.
|
Constructor and Description |
---|
ES6ModuleLoader(java.util.List<java.lang.String> moduleRoots,
java.lang.Iterable<CompilerInput> inputs)
Creates an instance of the module loader which can be used to locate ES6 and CommonJS modules.
|
Modifier and Type | Method and Description |
---|---|
private static URI |
createUri(java.lang.String input) |
(package private) static boolean |
isRelativeIdentifier(java.lang.String name)
Whether this is relative to the current file, or a top-level identifier.
|
private URI |
locate(java.lang.String name,
CompilerInput referrer) |
(package private) URI |
locateCommonJsModule(java.lang.String requireName,
CompilerInput context)
Find a CommonJS module
requireName relative to context . |
(package private) URI |
locateEs6Module(java.lang.String moduleName,
CompilerInput context)
Find an ES6 module
moduleName relative to context . |
private URI |
normalizeAddress(URI uri)
Normalizes the URI for the given
uri by resolving it against the known
moduleRootUris . |
(package private) URI |
normalizeInputAddress(CompilerInput input)
Normalizes the address of
input and resolves it against the module roots. |
private static java.lang.String |
stripJsExtension(java.lang.String fileName) |
static java.lang.String |
toModuleName(URI filename)
Turns a filename into a JS identifier that is used for moduleNames in
rewritten code.
|
static final java.lang.String MODULE_SLASH
public static final java.lang.String DEFAULT_FILENAME_PREFIX
static final DiagnosticType LOAD_ERROR
private final java.util.List<URI> moduleRootUris
private final java.util.Set<URI> moduleUris
public ES6ModuleLoader(java.util.List<java.lang.String> moduleRoots, java.lang.Iterable<CompilerInput> inputs)
moduleRoots
- The root directories to locate modules in.inputs
- All inputs to the compilation process.URI locateCommonJsModule(java.lang.String requireName, CompilerInput context)
requireName
relative to context
.null
if not found.URI locateEs6Module(java.lang.String moduleName, CompilerInput context)
moduleName
relative to context
.null
if not found.private URI locate(java.lang.String name, CompilerInput referrer)
URI normalizeInputAddress(CompilerInput input)
input
and resolves it against the module roots.private URI normalizeAddress(URI uri)
uri
by resolving it against the known
moduleRootUris
.private static URI createUri(java.lang.String input)
private static java.lang.String stripJsExtension(java.lang.String fileName)
static boolean isRelativeIdentifier(java.lang.String name)
public static java.lang.String toModuleName(URI filename)