Skip to content

Commit

Permalink
Add Broccoli build pipeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
timrwood authored and ichernev committed Mar 25, 2015
1 parent 7ce3fa7 commit f5e077f
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ sauce_connect.log
.sauce-labs.creds
npm-debug.log
.build*
temp
58 changes: 58 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
var compileModules = require('broccoli-es6-module-transpiler');
var compile6to5 = require('broccoli-6to5-transpiler');
var uglify = require('broccoli-uglify-js');
var merge = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');

var testFiles = new Funnel('.', {
include: [/^test\/(moment|qunit|helpers)/]
});

var libAndTests = merge(['lib', testFiles]);

var tests = compileModules(libAndTests, {
formatter: 'bundle',
output: 'test/moment-and-tests.js'
});

function bundle (file) {
var template = new Funnel('templates', {
include : [new RegExp(file + ".js")]
});
return compileModules(merge(['lib', template]), {
formatter: 'bundle',
output: file + '/moment.js'
});
}

var bundled = merge([
bundle('amd'),
bundle('amd-named'),
bundle('globals')
]);

var minified = uglify(bundled, {
mangle: true,
compress: {
dead_code: false // jshint ignore:line
},
output: {
ascii_only: true // jshint ignore:line
}
});

var commonjsSource = compile6to5(libAndTests, {
modules: 'commonInterop'
});

var commonjs = new Funnel(commonjsSource, {
destDir: "commonjs"
});

var all = merge([minified, tests, commonjs]);

var allWithoutMaps = new Funnel(all, {
exclude: [/\.map$/]
});

module.exports = allWithoutMaps;
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
],
"devDependencies": {
"uglify-js": "latest",
"broccoli": "^0.13.3",
"broccoli-6to5-transpiler": "^0.1.1",
"broccoli-cli": "0.0.1",
"broccoli-es6-module-transpiler": "^0.5.0",
"broccoli-funnel": "^0.1.6",
"broccoli-merge-trees": "^0.2.1",
"broccoli-uglify-js": "^0.1.3",
"grunt": "latest",
"nodeunit": "latest",
"benchmark": "latest",
Expand All @@ -62,10 +69,12 @@
"karma-firefox-launcher": "latest",
"karma-nodeunit": "latest",
"karma-sauce-launcher": "latest",
"qunit": "^0.7.5",
"qunit-cli": "^0.1.4",
"spacejam": "latest"
},
"scripts": {
"test": "grunt test:node"
"test": "rm -rf temp; broccoli build temp; qunit-cli temp/test/*.js; qunit-cli temp/commonjs/test/**/*.js;"
},
"ender": "./ender.js",
"dojoBuild": "package.js",
Expand Down
6 changes: 6 additions & 0 deletions test/helpers/each.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function (array, callback) {
var i;
for (i = 0; i < array.length; i++) {
callback(array[i], i, array);
}
}
24 changes: 24 additions & 0 deletions test/qunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*global QUnit:false*/

import moment from "../moment";

export var test = QUnit.test;

export function module (name, lifecycle) {
QUnit.module(name, {
setup : function () {
moment.locale('en');
moment.createFromInputFallback = function () {
throw new Error('input not handled by moment');
};
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
}

0 comments on commit f5e077f

Please sign in to comment.