Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-systemjs-builder

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-systemjs-builder - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

tests/example/app/demo/app.js

6

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc