Class ModuleLoader.ModulePath

  • Enclosing class:
    ModuleLoader

    public class ModuleLoader.ModulePath
    extends java.lang.Object
    A path to a module. Provides access to the module's closurized name and a way to resolve relative paths.
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equalsIgnoreLeadingSlash

        public boolean equalsIgnoreLeadingSlash​(ModuleLoader.ModulePath other)
        Determines if this path is the same as another path, ignoring any potential leading slashes on both.
      • toModuleName

        public java.lang.String 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.
      • resolveJsModule

        @Nullable
        public ModuleLoader.ModulePath resolveJsModule​(java.lang.String moduleAddress)
        Find a JS module requireName. See https://nodejs.org/api/modules.html#modules_all_together
        Returns:
        The normalized module URI, or null if not found.
      • resolveJsModule

        @Nullable
        public ModuleLoader.ModulePath resolveJsModule​(java.lang.String moduleAddress,
                                                       java.lang.String sourcename,
                                                       int lineno,
                                                       int colno)
        Find a JS module requireName. See https://nodejs.org/api/modules.html#modules_all_together
        Returns:
        The normalized module URI, or null if not found.
      • resolveModuleAsPath

        public ModuleLoader.ModulePath resolveModuleAsPath​(java.lang.String moduleAddress)
        Treats the module address as a path and returns the name of that module. Does not verify that there is actually a JS file at the provided URI.

        Primarily used for per-file ES6 module transpilation