ExportObject

  • typedef
steal-tools.export.object {Object}  

An object that specifies the modules to load and their outputs. This is used by export and [steal-tools.grunt.export].

Object

Properties

  1. steal {StealConfig}

    Specifies the config values used to load modules. At a minimum, some set of main, baseURL, or configPath must be specified.

    steal: {
      main: ['mymodule'],
      config: __dirname+"/config.js"
    }
    
  2. options {Object}

    Options that configure the following:

    • [debug=false] true turns on debug messages. Defaults to false.
    • [quiet=false] No logging. Defaults to false.
  3. outputs {Object<String,ExportOutput>}

    Configures output files to be written.

Use

Each ExportObject task is configured by three values:

  • steal - Describes the config values used to load modules; this is passed to transformImport.
  • options - Configures special behavior of the loader such as logging.
  • outputs - Configures the modules that should be written out, how they should be written out, and where they should be written.

steal

A StealConfig object that is used to load modules. Typically, you will want to specify at least the config and main options, like so:

steal: {
  config: __dirname + "/config.js",
  main: ["math/add", "math/subtract"]
}

options

Options configures logging. Example:

options: { verbose: true }

or

options: { quiet: true }

outputs

outputs specifies different ways the modules loaded by steal are written out. It's an object of ExportOutput objects. Each ExportOutput supports the following options:

And the options available to TransformOptions.

  • ignore {Array<RegExp | String | function(String, Load)>}
  • removeDevelopmentCode {Boolean}
  • format {String}
  • noGlobalShim {Boolean}
  • exports {Object<moduleName,String>}
  • useNormalizedDependencies {Boolean}
  • normalize {function(depName, depLoad, curName, curLoad)}
  • minify {Boolean}
  • ignoreAllDependencies {Boolean}
  • includeTraceurRuntime {Boolean}
  • sourceMaps {Boolean}
  • sourceMapsContent {Boolean}

Only one of modules, eachModule, or graphs should be specified.

Example:

outputs: {
  "global first and second together without jQuery": {
    modules: ["first","second"],
    ignore: ["jquery"],
    format: "global"
  },
  "first and second seperately without jQuery": {
    eachModule: ["first","second"],
    ignore: ["jquery"],
    format: "global"
  },
  "first and second and their dependencies individually converted to amd": {
    graphs: ["first","second"],
    format: "amd"
  }
}

output names

An output name can mixin default output options of an Export Helper, like [steal-tools/lib/build/helpers/cjs], by including a "+", followed by the name of the export helper. For example:

outputs: {
  "+amd": {},
  "+cjs": {dist: __dirname+"cjs"},
  "+global-js": {},
  "+global-css": {}
}

The given output ExportObject's value will overwrite or modify the behavior of the Export Helper. For example, {dist: __dirname+"/cjs"} will change the output destination of "+cjs".

Help us improve StealJS by taking our community survey