ExportOutput

  • typedef
steal-tools.export.output {Object} inherits: steal

Specifies the behavior for an output in an ExportObject "outputs" property. These properties are in addition to TransformOptions.

Object

Properties

  1. modules {Array<moduleName | comparitor>}Optional

    Builds all the modules in modules together with their dependencies.

  2. eachModule {Array<moduleName | comparitor>}Optional

    Builds each module in the list with its dependendencies individually. Use this if you want to create separate builds for more than one module in your graph:

    stealTools.export({
        steal: {
            config: __dirname + "/package.json!npm"
        }
    
    });
    
  3. graphs {Array<moduleName | comparitor>}Optional

    Builds each item in the graph on its own. Each dependency is built individually.

  4. dest {String | function(moduleName, moduleData, load, loader)}

    Specifies where the output should be written. Dest can be provided as a string or a function that returns the location.

    • moduleName {String | Array<String>}

      The module name or module names being written out by this output.

    • moduleData {Object | Array<Object>}

      Deprecated.

    • load {Load | Array<Load>}

      The module load record, or module load records, being written by this output.

    • loader {Loader}

      The Steal loader used by Steal to load all of these modules. All configuration should be available on it.

  5. ignore {Array<moduleName | ignorer()>}Optional

    Modules that should be ignored and not included in the output.

    You can use it like:

    stealTools.export({
        steal: {
            config: __dirname + "/package.json!npm"
        },
        options: {},
        outputs: {
            "+global-js": {
                ignore: [
                    "jquery"
                ]
            }
        }
    })
    

    Or alternatively you can provide an ignorer function that will be called with each moduleName, giving you the opportunity to programmatically determine if a module should be ignored.

    stealTools.export({
        steal: {
            config: __dirname + "/package.json!npm"
        },
        options: {},
        outputs: {
            "+global-js": {
                ignore: [function(name){
                    if(name.indexOf("foobar") >= 0) {
                        return true;
                    } else {
                        return false;
                    }
                }]
            }
        }
    })
    

    For the [steal-tools/lib/build/helpers/global] helper providing false (instead of an Array) for this option will not ignore modules defined in node_modules as is done by default.

Use

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

modules

All modules specified by modules and their dependencies will be built together. For example:

{
  modules: ["foo","bar"],
  format: "global"
}

This will build "foo" and "bar" together in the global format. If "foo", or "bar" depend on "zed", "zed" will also be included.

eachModule

Each module specified by eachModule will be exported, including its dependencies individually. For example:

eachModule is useful when you want to take a dependency graph and split it into separate builds that will be combined around certain modules within that graph.

For example:

stealTools.export({
    steal: {
        config: __dirname + "/package.json!npm"
    },
    options: {},
    outputs: {
        "+standalone": {
            eachModule: [
                "app/a",
                "app/b"
            ]
        }
    }
});

This will build out dist/global/app/a.js and dist/global/app/b.js, both as standalone builds.

graphs

Each module specified by graphs and its dependencies will be exported individually. For example:

{
  graphs: ["foo","bar"],
  format: "cjs"
}

This will export "foo" to a file, and each of its dependencies to their own file. This will also export "bar" to a file, and each of its dependencies to their own file. If "foo" and "bar" both depend on "zed", "zed" will be written to its own file one time.

dest

Dest should specify a single file, typically with a string, if modules is provided, like:

{
  modules: ["foo","bar"],
  format: "global",
  dest: __dirname+"/foo-bar.js"
}

Otherwise, a folder or function should be provided, if using eachModule orgraphs`:

{
  graphs: ["foo","bar"],
  format: "cjs",
  dest: function(moduleName){
    return __dirname+"/"+moduleName+".js";
  }
}
Help us improve StealJS by taking our community survey