org.apache.tapestry5.services.javascript

## Class JavaScriptModuleConfiguration

- java.lang.Object
- - org.apache.tapestry5.services.javascript.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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `Resource` | `resource` The resource for this shim module.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaScriptModuleConfiguration(Resource resource)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JavaScriptModuleConfiguration` | `dependsOn(String... moduleNames)` A list of other module names the shim depends on.
    `JavaScriptModuleConfiguration` | `exports(String exports)` The name of a global variable exported by the module.
    `List<String>` | `getDependencies()`
    `String` | `getExports()`
    `String` | `getInitExpression()`
    `boolean` | `getNeedsConfiguration()` Returns true if the module contains any additional configuration beyond its `Resource`.
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### resource

          public final Resource resource

      The resource for this shim module.

  - ### Constructor Detail

    - #### JavaScriptModuleConfiguration

          public JavaScriptModuleConfiguration(Resource resource)

  - ### 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

    - #### getDependencies

          public List<String> getDependencies()

    - #### 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

    - #### getExports

          public String getExports()

    - #### 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

    - #### getInitExpression

          public String getInitExpression()

    - #### getNeedsConfiguration

          public boolean getNeedsConfiguration()

      Returns true if the module contains any additional configuration beyond its `Resource`.

5.6.0 - Copyright © 2003-2020 The Apache Software Foundation.