Class ModuleLoader.ModulePath

java.lang.Object
com.google.javascript.jscomp.deps.ModuleLoader.ModulePath
Enclosing class:
ModuleLoader

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

    • toString

      public String toString()
      Overrides:
      toString in class 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 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

      public @Nullable ModuleLoader.ModulePath resolveJsModule(String moduleAddress, 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(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