org.mozilla.javascript.commonjs.module

## Interface ModuleScriptProvider

- All Known Implementing Classes:
    CachingModuleScriptProviderBase, MultiModuleScriptProvider, SoftCachingModuleScriptProvider, StrongCachingModuleScriptProvider

      public interface ModuleScriptProvider

  Should be implemented by Rhino embeddings to allow the require() function to obtain `ModuleScript` objects. We provide two default implementations, but you can of course roll your own if they don't suit your needs.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `ModuleScript` | `getModuleScript(Context cx, java.lang.String moduleId, java.net.URI moduleUri, java.net.URI baseUri, Scriptable paths)` Returns a module script.

- - ### Method Detail

    - #### getModuleScript

          ModuleScript getModuleScript(Context cx,
                                       java.lang.String moduleId,
                                       java.net.URI moduleUri,
                                       java.net.URI baseUri,
                                       Scriptable paths)
                                throws java.lang.Exception

      Returns a module script. It should attempt to load the module script if it is not already available to it, or return an already loaded module script instance if it is available to it.
      Parameters:
        `cx` - current context. Can be used to compile module scripts.
        `moduleId` - the ID of the module. An implementation must only accept an absolute ID, starting with a term.
        `moduleUri` - the URI of the module. If this is not null, resolution of `moduleId` is bypassed and the script is directly loaded from `moduleUri`
        `baseUri` - the module path base URI from which `moduleUri` was derived.
        `paths` - the value of the require() function's "paths" attribute. If the require() function is sandboxed, it will be null, otherwise it will be a JavaScript Array object. It is up to the provider implementation whether and how it wants to honor the contents of the array.
      Returns:
        a module script representing the compiled code of the module. Null should be returned if the script could not found.
      Throws:
        `java.lang.Exception` - if there was an unrecoverable problem obtaining the script
        `java.lang.IllegalArgumentException` - if the module ID is syntactically not a valid absolute module identifier.