metadata
- typedef
{Object}
An object that is passed between Loader
hooks. Any values can be set. These are the ones that steal.js
recognize.
Object
Properties
-
format
{String}
Specifies what type of Syntax is used. This can be specified like:
"format amd";
-
deps
{Array<moduleName>}
OptionalDependencies of this module. If the module is a global but implicitly depends on another, like jQuery, add that dependency here.
"meta": { "jquery-cookie": { "deps": ["jquery"] } }
-
exports
{String}
OptionalThe global property that is exported as this module's default export.
-
init
{function(Module...)}
OptionalAllows for calling noConflict and for other cleanup.
this
will be the global object.-
{Module}
-
-
sideBundle
=false
{Boolean}
OptionalCreate a bundle for this module and exclude it from StealTool's bundle optimization algorithm. This is useful for modules that are infrequently used, like a page for your app that users rarely visit.
"meta": { "moduleA": { "sideBundle": true } }
-
bundle
=false
{Boolean}
OptionalExclude a module from being bundled.
"meta": { "MODULENAME": { "bundle": false } }
If you exclude a module from the bundled file, you have to make sure, that in the production environment configuration the module is:
... mapped to the pseudo-module @empty
"envs": { "window-production": { "map": { "MODULENAME': "@empty" } } }
... configured to the right location of the module e.g. a CDN
"envs": { "production": { "paths": { "jquery': "//code.jquery.com/jquery-2.2.1.min.js" } } }
-
useLocalDeps
=false
{Boolean}
OptionalInclude module dependencies in the development bundle.
"meta": { "MODULENAME": { "useLocalDeps": true } }
In this example all dependencies imported by
MODULENAME
will be included in the bundle during build.This option can be used alongside environment dependant configuration to make sure a specific version of a module is used during build time but the original (local) module dependencies are included in the development bundle.
"steal": { "meta": { "steal-less/less": { "useLocalDeps: true } }, "envs": { "bundle-build": { "map" { "steal-less/less-engine": "steal-less/less-engine-node" } } } }
The configuration above makes it so the NodeJS version of less is loaded while the application is built but
useLocalDeps
forces the local dependencies ofsteal-less#less
to be included in the bundle. -
eval
=function
{String}
OptionalSpecify the type of eval that should be applied to this module.
Most modules are evaled using the Function constructor like:
new Function(source).call(context)
. However, if you have a global module that looks like:var Foo = function(){ };
Where
Foo
is the exported value in your configuration:"steal": { "meta": { "foo": { "format": "global", "exports": "Foo" } } }
In this situation, the default
new Function
method of evaluation will not work and theFoo
variable will not be set on the window. In this case we want to update our eval configuration toscript
:"steal": { "meta": { "foo": { "format": "global", "exports": "Foo", "eval": "script" } } }
This will use
<script>
elements for evaluation and theFoo
property will be set. -
globals
{Object}
A map of globals to module names expected to be present for the execution of this module.
This is useful for legacy code that relies on globals being defined during execution; the module names referenced are automatically turned into dependencies of this module.
If you have a global module
foo
, that looks like this:var something = $$$;
Use the following configuration to make sure the global variable
$$$
is defined beforefoo
is executed:"steal": { "meta": { "foo": { "format": "global", "globals": { "$$$": "bar" } } } }