All Superinterfaces:
JSBundleAsset, JSBundleObject, JSResolvableBundleAsset

@ProviderType public interface JSModule extends JSResolvableBundleAsset
Represents an NPM module inside a JSBundle.

JSModules belong to a JSPackage and JSPackages belong to a JSBundle.

You can have several copies of the same JSModule in different modules of the portal. For example, suppose you have a module named p@1.0.0/m (the module m residing in package p with version 1.0.0) containing three OSGi bundles: b1.jar, b2.jar, and b3.jar. In this scenario, you would have three JS modules in the NPMRegistry (one per bundle) and one JS resolved module (depending on the algorithm used, points to one of the three JS modules). The JS module is served to the browser using its JS resolved module (i.e., a virtual entity passed to the browser to avoid using any of the other three JS modules).

The modules would look something like this:

Modules:
  • b1.jar:p@1.0.0/m with URL .../b1.jar/p@1.0.0/m
  • b2.jar:p@1.0.0/m with URL .../b2.jar/p@1.0.0/m
  • b3.jar:p@1.0.0/m with URL .../b3.jar/p@1.0.0/m
Resolved Module:
  • p@1.0.0/m with URL .../p@1.0.0/m

The URL of the resolved module does not show any reference to a bundle. Also, when the resolved module is requested, it's internally resolved to one of the other three modules. Therefore, the requester would receive something like .../b2.jar/p@1.0.0/m, but wouldn't notice it since it's transparent to the requester.

  • Method Details

    • getDependencies

      Collection<String> getDependencies()
      Returns the module dependencies declared by the NPM module.
      Returns:
      the module names
    • getDependencyPackageNames

      Collection<String> getDependencyPackageNames()
      Returns the packages that contain all the NPM module's dependencies.
      Returns:
      the NPM package names
    • getFlagsJSONObject

      com.liferay.portal.kernel.json.JSONObject getFlagsJSONObject()
      Get the metadata that describe the module.
    • getJSPackage

      JSPackage getJSPackage()
      Returns the module's NPM package.
      Returns:
      the NPM package
    • getSourceMapInputStream

      InputStream getSourceMapInputStream() throws IOException
      Returns the module's source map.
      Returns:
      an InputStream that allows reading the bytes inside the source map
      Throws:
      IOException - if an IO exception occurred