Class JavaScriptModuleConfiguration


  • public final class JavaScriptModuleConfiguration
    extends Object
    Used to define a module shim, used to adapt non-AMD JavaScript libraries to operate like proper modules. This information is used to build up a list of dependencies for the contributed JavaScript module, and to identify the resource to be streamed to the client. Instances of this class are contributed to the ModuleManager service; the contribution key is the module name (typically, a single word). In some cases, an instance may be created and contributed to override a default module; if the module has no dependencies, exports, or initExpression (that is, if it is a proper AMD module, where such dependencies are provided inside the module itself), then no client-side shim configuration will be written for the module, but requests for the module will be satisfied by the resource.'
    Since:
    5.4
    See Also:
    AMDWrapper
    • Field Detail

    • Method Detail

      • dependsOn

        public JavaScriptModuleConfiguration dependsOn​(String... moduleNames)
        A list of other module names the shim depends on.
        Parameters:
        moduleNames -
        Returns:
        this JavaScriptModuleConfiguration for further configuration
      • exports

        public JavaScriptModuleConfiguration exports​(String exports)
        The name of a global variable exported by the module. This will be the value injected into modules that depend on the shim.
        Returns:
        this JavaScriptModuleConfiguration for further configuration
      • initializeWith

        public JavaScriptModuleConfiguration initializeWith​(String expression)
        Used as an alternative to exports(String), this allows a short expression to be specified; the expression is used to initialize, clean up, and (usually) return the module's export value. For Underscore, this would be "_.noConflict()". If the expression returns null, then the exports value is used. In RequireJS 2.1.1 (the version shipped with Tapestry, currently), an init function is not invoked unless the shim also defines an exports. See RequireJS issue 517. At this time, you should specify exports even if you provide a initializeWith(String)}.
        Parameters:
        expression - initialization expression
        Returns:
        this JavaScriptModuleConfiguration, for further configuration
      • getNeedsConfiguration

        public boolean getNeedsConfiguration()
        Returns true if the module contains any additional configuration beyond its Resource.