Class JavaScriptModuleConfiguration
java.lang.Object
org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration
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:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionA list of other module names the shim depends on.The name of a global variable exported by the module.boolean
Returns true if the module contains any additional configuration beyond itsResource
.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.
-
Field Details
-
resource
The resource for this shim module.
-
-
Constructor Details
-
JavaScriptModuleConfiguration
-
-
Method Details
-
dependsOn
A list of other module names the shim depends on.- Parameters:
moduleNames
-- Returns:
- this JavaScriptModuleConfiguration for further configuration
-
getDependencies
-
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
-
initializeWith
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 specifyexports
even if you provide ainitializeWith(String)
}.- Parameters:
expression
- initialization expression- Returns:
- this JavaScriptModuleConfiguration, for further configuration
-
getInitExpression
-
getNeedsConfiguration
Returns true if the module contains any additional configuration beyond itsResource
.
-