grunt-systemjs-builder
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "grunt-systemjs-builder", | ||
"version": "0.2.2", | ||
"description": "grunt task for building project based on systemjs", | ||
"version": "0.2.3", | ||
"description": "grunt task for building projects based on systemjs", | ||
"repository": { | ||
@@ -32,4 +32,4 @@ "type": "git", | ||
"dependencies": { | ||
"systemjs-builder": "^0.12.2" | ||
"systemjs-builder": "^0.14.11" | ||
} | ||
} |
@@ -19,3 +19,3 @@ [![npm version](https://badge.fury.io/js/grunt-systemjs-builder.svg)](https://www.npmjs.com/package/grunt-systemjs-builder) | ||
This is a [MultiTask](http://gruntjs.com/api/grunt.task#grunt.task.registermultitask) therefore it can run using different configuration using targets in the grunt configuration. see [grunt docs](http://gruntjs.com/configuring-tasks#task-configuration-and-targets) for more info | ||
This is a [MultiTask](http://gruntjs.com/api/grunt.task#grunt.task.registermultitask) therefore it can run using different configuration using targets in the grunt configuration. see [grunt docs](http://gruntjs.com/configuring-tasks#task-configuration-and-targets) for more info. | ||
@@ -30,9 +30,9 @@ ## Options | ||
[systemjs docs](The baseURL provides a special mechanism for loading modules relative to a standard reference URL.) | ||
[systemjs docs](https://github.com/systemjs/systemjs/blob/master/docs/overview.md#baseurl) | ||
_if baseURL is provided through the configuration, it will be the one used and any baseURL configuration from a configuration file will be ignored as systemjs only allows to configure baseURL once._ | ||
_if baseURL is provided through the configuration, it will be the one used and any subsequent **baseURL** configuration (even) from a configFile will be ignored as systemjs only allows to configure baseURL once._ | ||
### configFile: String | ||
path to an external configuration file (one with System.config calls). | ||
path to an external configuration file (one with System.config(...) calls). | ||
@@ -56,3 +56,3 @@ ### sfx: Boolean | ||
The configuration that is allowed when creating the builder instance. Basically systemjs configuration. | ||
The configuration that is allowed when creating the builder instance. Basically any valid systemjs configuration (same as calling System.config()). | ||
see [builder documentation](https://github.com/systemjs/builder/blob/master/README.md). | ||
@@ -59,0 +59,0 @@ |
module.exports = function (grunt) { | ||
"use strict"; | ||
"use strict"; | ||
function task() { | ||
//todo: allow Arithmetic builds - https://github.com/systemjs/builder#example---arithmetic-expressions | ||
//todo: use trace api for more advanced builds - https://github.com/systemjs/builder#example---direct-trace-api | ||
var buildQuickSettings = ["minify", "sourceMaps"], | ||
Builder = require("systemjs-builder"), | ||
options = _getOptions.call(this, buildQuickSettings), | ||
builder = new Builder(options.builder), | ||
done = this.async(); | ||
function task() { | ||
if (options.baseURL) { | ||
grunt.verbose.writeln("systemjs-builder-task - using base url: " + options.baseURL); | ||
builder.config({baseURL: options.baseURL}); | ||
var buildQuickSettings = ["minify", "sourceMaps"], | ||
Builder = require("systemjs-builder"), | ||
options = _getOptions.call(this, buildQuickSettings), | ||
builder = new Builder(options.builder), | ||
done = this.async(); | ||
if (options.configFile) { | ||
var orgConfig = builder.config.bind(builder); | ||
if (options.baseURL) { | ||
grunt.verbose.writeln("systemjs-builder-task - using base url: " + options.baseURL); | ||
builder.config({baseURL: options.baseURL}); | ||
builder.config = function (cfg) { //need to do this to allow dynamic base url from grunt build to override the base url in the config file | ||
if (cfg.baseURL) { //this is ugly but no choice because builder.loadConfig will override the baseURL provided in the config | ||
delete cfg.baseURL; | ||
} | ||
if (options.configFile) { | ||
var orgConfig = builder.config.bind(builder); | ||
orgConfig(cfg); | ||
}; | ||
} | ||
} | ||
builder.config = function (cfg) { //need to do this to allow dynamic base url from grunt build to override the base url in the config file | ||
if (cfg.baseURL) { //this is ugly but no choice because builder.loadConfig will override the baseURL provided in the config | ||
delete cfg.baseURL; | ||
} | ||
if (options.configFile) { | ||
orgConfig(cfg); | ||
}; | ||
} | ||
} | ||
builder.loadConfig(options.configFile) //load external config file if one specified | ||
.then(_build.bind(this, builder, options, done)) | ||
.catch(function (err) { | ||
grunt.fail.fatal(err); | ||
}); | ||
} | ||
else { | ||
_build.call(this, builder, options, done); | ||
} | ||
} | ||
if (options.configFile) { | ||
function _isUndefined(val) { | ||
return typeof val === "undefined"; | ||
} | ||
builder.loadConfig(options.configFile) //load external config file if one specified | ||
.then(_build.bind(this, builder, options, done)) | ||
.catch(function (err) { | ||
grunt.fail.fatal(err); | ||
}); | ||
} | ||
else { | ||
_build.call(this, builder, options, done); | ||
} | ||
} | ||
function _getOptions(buildQuickSettings) { | ||
function _isUndefined(val) { | ||
return typeof val === "undefined"; | ||
} | ||
var options = this.options({ | ||
builder: {}, | ||
build: {}, | ||
sfx: false, | ||
minify: false, | ||
sourceMaps: true | ||
}); | ||
function _getOptions(buildQuickSettings) { | ||
buildQuickSettings.forEach(function (setting) { //make it easier to set build options | ||
if (_isUndefined(options.build[setting] && !_isUndefined(options[setting]))) { | ||
options.build[setting] = options[setting]; | ||
} | ||
}); | ||
var options = this.options({ | ||
builder: {}, | ||
build: {}, | ||
sfx: false, | ||
minify: false, | ||
sourceMaps: true | ||
}); | ||
return options; | ||
} | ||
buildQuickSettings.forEach(function (setting) { //make it easier to set build options | ||
if (_isUndefined(options.build[setting] && !_isUndefined(options[setting]))) { | ||
options.build[setting] = options[setting]; | ||
} | ||
}); | ||
function _build(builder, options, done) { | ||
return options; | ||
} | ||
var buildMethod = options.sfx ? "buildSFX" : "build"; | ||
function _build(builder, options, done) { | ||
grunt.verbose.writeln("systemjs-builder-task - running build method: " + buildMethod); | ||
var buildMethod = options.sfx ? "buildStatic" : "bundle", | ||
counter = this.files.length, | ||
data = { | ||
builder: builder, | ||
buildMethod: buildMethod, | ||
options: options | ||
}; | ||
var data = { | ||
builder: builder, | ||
buildMethod: buildMethod, | ||
options: options | ||
}; | ||
grunt.verbose.writeln("systemjs-builder-task - running build method: " + buildMethod); | ||
this.files.forEach(_buildSource.bind(this, data, done)); | ||
} | ||
this.files.forEach(_buildSource.bind(this, data, function () { | ||
counter -= 1; | ||
function _buildSource(data, done, file) { | ||
if (counter === 0) { | ||
done(); | ||
} | ||
})); | ||
} | ||
if (file.src.length > 1) { | ||
grunt.fail.fatal("systemjs-builder-task - cant have more than one source file for the build process"); | ||
} | ||
function _buildSource(data, done, file) { | ||
var builder = data.builder, | ||
options = data.options, | ||
src = file.src[0]; | ||
if (file.src.length > 1) { //todo: support multiple src files using "&" - https://github.com/systemjs/builder#example---common-bundles | ||
grunt.fail.fatal("systemjs-builder-task - cant have more than one source file for the build process"); | ||
} | ||
grunt.verbose.writeln("systemjs-builder-task - about to build source: " + src); | ||
var builder = data.builder, | ||
options = data.options, | ||
src = file.src[0]; | ||
builder[data.buildMethod].call(builder, src, file.dest, options.build) | ||
.then(function () { | ||
grunt.verbose.writeln("systemjs-builder-task - finished building source: " + src); | ||
done(); | ||
}) | ||
.catch(function (err) { | ||
grunt.fail.fatal(err); | ||
}); | ||
} | ||
grunt.verbose.writeln("systemjs-builder-task - about to build source: " + src); | ||
grunt.registerMultiTask("systemjs", "build project using systemjs builder", task); | ||
builder[data.buildMethod].call(builder, src, file.dest, options.build) | ||
.then(function () { | ||
grunt.verbose.writeln("systemjs-builder-task - finished building source: " + src); | ||
done(); | ||
}) | ||
.catch(function (err) { | ||
grunt.fail.fatal(err); | ||
}); | ||
} | ||
grunt.registerMultiTask("systemjs", "build project using systemjs builder", task); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10252
12
137
+ Addedbluebird@3.7.2(transitive)
+ Addedd@1.0.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedes6-template-strings@2.0.1(transitive)
+ Addedesniff@1.1.32.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedglob@6.0.4(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedsystemjs@0.19.9(transitive)
+ Addedsystemjs-builder@0.14.15(transitive)
+ Addedtraceur@0.0.93(transitive)
+ Addedtype@2.7.3(transitive)
- Removedglob@5.0.15(transitive)
- Removedsource-map@0.4.4(transitive)
- Removedsystemjs@0.18.17(transitive)
- Removedsystemjs-builder@0.12.2(transitive)
- Removedtraceur@0.0.90(transitive)
Updatedsystemjs-builder@^0.14.11