From: Tim Wood Date: Sun, 11 Jan 2015 19:14:35 +0000 (-0800) Subject: Add Broccoli build pipeline. X-Git-Tag: 2.10.2~15^2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5e077f075dddfb4dd9d110d996b0fa330a3fcf4;p=thirdparty%2Fmoment.git Add Broccoli build pipeline. --- diff --git a/.gitignore b/.gitignore index 8ec4b029b..3f7127b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ sauce_connect.log .sauce-labs.creds npm-debug.log .build* +temp diff --git a/Brocfile.js b/Brocfile.js new file mode 100644 index 000000000..b353a7e05 --- /dev/null +++ b/Brocfile.js @@ -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; diff --git a/package.json b/package.json index 5520d1579..5007d8eaa 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/test/helpers/each.js b/test/helpers/each.js new file mode 100644 index 000000000..56c9968bd --- /dev/null +++ b/test/helpers/each.js @@ -0,0 +1,6 @@ +export default function (array, callback) { + var i; + for (i = 0; i < array.length; i++) { + callback(array[i], i, array); + } +} diff --git a/test/qunit.js b/test/qunit.js new file mode 100644 index 000000000..59d50d735 --- /dev/null +++ b/test/qunit.js @@ -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(); + } + } + }); +}