export

  • function
steal-tools.export  

Export a project's modules to other forms and formats declaratively.

stealTools.export( exportTask, defaults, modules )

Parameters

  1. exportTask {ExportObject}

    An ExportObject with the following properties:

    • Steal {StealConfig}

      config data needed to load all the modules for export.

    • options {Object}

      Options that configure logging.

    • outputs {Object<String,ExportOutput>}

      Configures output files to be written.

  2. defaults {Object<String,ExportOutput>}Optional

    An object of names and default ExportOutput values.

  3. modules {Array<Object>}Optional

    An array of module data that an ExportOutput's modules, eachModule, graphs, or ignore can be filtered against.

Returns

{Promise}

A promise that resolves when all outputs have been written out.

Use

stealTools.export is used to declaratively describe multiple transformations that take place on an application's modules to make it distributable. The amd, cjs, and global Export Helpers can be used to export censible versions of your project in those formats.

The basic use of stealTools export is to provide a "steal" that is able to load your project's modules, and several "outputs" that write out those modules in a new form:

var stealTools = require("steal-tools");
stealTools.export({
  steal: {
    main: "myproject",
    config: __dirname+"/config.js"
  },
  options: {
    verbose: true
  },
  outputs: {
    amd: {
      format: "amd",
      graphs: ["myproject"],
      dest: __dirname+"/dist/amd"
    },
    standalone: {
      format: "global",
      modules: ["myproject"],
      dest: __dirname+"/dist/standalone.js",
      minify: true
    }
  }
})

exportTask

The first argument is an ExportObject. Details about its API and options can be found on its page.

defaults

As there are times when the same options may need to be set over and over again, the defaults option can contain default values each output can call:

var stealTools = require("steal-tools");
stealTools.export({
  steal: {
    main: "myproject",  config: __dirname+"/config.js"
  },
  outputs: {
    "+commonjs": {
      dest: __dirname+"/dist/cjs"
    },
    "+cjs+minify": {
      dest: __dirname+"/dist/min/cjs"
    }
  }
},{
  "commonjs" : {
    modules: ["myproject"],
    format: "cjs"
  },
  "minify": {
    minify: true,
    uglifyOptions: { ... }
  }
})

The cjs and other export helpers can also be mixed in output names by default:

var stealTools = require("steal-tools");
stealTools.export({
  steal: {
    main: "myproject",  config: __dirname+"/config.js"
  },
  outputs: {
    "+cjs" : {}
  }
})

modules

Deprecated.