TransformOptions
- typedef
{Object}
Specify the behavior of a transform.
Object
Properties
-
ignore
{Array<RegExp | String | function(String, Load)>}
OptionalAn Array of regular expressions, or strings that specify moduleNames that should not be included in the output.
Module names that match the regular expressions are not included. The following ignores everything in can/util/.
transform("can/construct",{ignore: [/^can\/util\/]});
Module names and their dependencies that match the strings in the array are not included. The following will not include "can/construct", and all of its dependencies:
transform("can/component",{ignore: ["can/construct"]});
-
removeDevelopmentCode
=true
{Boolean}
OptionalBy default, removes code in between comments, like:
//!steal-remove-start REMOVE.THIS; //!steal-remove-end
If removeDevelopmentCode is
false
, this code is not removed. -
format
='global'
{String}
OptionalWhat format the output will be transpiled to. By default the format is
"global"
."global"
means the code will be transpiled to work standalone. Module dependencies that are not included should be mapped to their name on the global object in exports.The other possible format values are "steal","amd", and "cjs".
-
noGlobalShim
=false
{Boolean}
OptionalBy default, if options.format is
"global"
then a global shim will be applied. This is so that the script can be run standalone. Setting noGlobalShim totrue
prevents adding the shim. Excluding the shim means it will have to be run with an AMD loader like requirejs. -
exports
{Object<moduleName,String>}
OptionalA mapping of module names to their name on the global object (such as the
window
). For example, if an output depends on jQuery, but does not include it, you should include:transform("mywidget",{exports: {"jquery": "jQuery"}})
Conversely you can also use exports to set values that should be exported from your module. For example, if you have a module foo that exports a value like:
module.exports = "foo bar";
You can specify where this module should be set on the window:
transform("mywidget", { exports: { "foo": "foo.bar" } });
Which, when the script runs will result in:
window.foo.bar === "foo bar";
-
useNormalizedDependencies
=true
{Boolean}
OptionalUse normalized dependency names instead of relative module names. For example "foo/bar" will be used instead of "./bar".
-
normalize
{function(depName, depLoad, curName, curLoad)}
OptionalAn optional function that will normalize all module names written out. Use this for custom normalization behavior.
-
depName
{String}
The dependency name to normalize.
-
depLoad
{Load}
The load object for the dependency to normalize.
-
curName
{String}
The moduleName of the module whose dependencies are being normalized.
-
curLoad
{Load}
The load object of the module whose dependencies are being normalized.
-
-
minify
=false
{Boolean}
OptionalBy default, the output is not minified. Set to
true
to minify the result. -
ignoreAllDependencies
=false
{Boolean}
OptionalBy default, the dependencies of the module specified are included, unless they are explicitly ignored. Setting ignoreAllDependencies to
true
only results in returning that individual module as the output. -
includeTraceurRuntime
=true
{Boolean}
OptionalBy default, if an ES6 module is found and the
transpiler
config is set totraceur
(the default), the @traceur runtime is packaged with the output. Setting this tofalse
prevents that behavior. -
sourceMaps
=false
{Boolean}
OptionalTo generate source maps alongside your transformed source, set this option to true.
-
sourceMapsContent
=false
{Boolean}
OptionalInclude the original source contents in the generated source maps.