From 41489b2d8ed5c1677fd77975cecd54b4f60f4334 Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Mon, 4 Jan 2016 10:38:20 -0500 Subject: Update make build tasks --- support/build/aggregate-build.js | 20 ++ support/build/aggregate-bundle.js | 9 + support/build/aggregate-cjs.js | 9 + support/build/compile-modules.js | 34 ++++ support/build/modules-cjs.js | 3 + support/build/plugin-lodash-import-rename.js | 22 +++ support/dependencies.json | 262 --------------------------- 7 files changed, 97 insertions(+), 262 deletions(-) create mode 100644 support/build/aggregate-build.js create mode 100644 support/build/aggregate-bundle.js create mode 100644 support/build/aggregate-cjs.js create mode 100644 support/build/compile-modules.js create mode 100644 support/build/modules-cjs.js create mode 100644 support/build/plugin-lodash-import-rename.js delete mode 100644 support/dependencies.json (limited to 'support') diff --git a/support/build/aggregate-build.js b/support/build/aggregate-build.js new file mode 100644 index 0000000..63d7799 --- /dev/null +++ b/support/build/aggregate-build.js @@ -0,0 +1,20 @@ +import compileModules from './compile-modules'; +import rollup from 'rollup'; +import rimraf from 'rimraf/rimraf'; + +export default function buildBundle(options) { + function bundle() { + rollup.rollup({ + entry: options.outpath + '/index.js' + }).then(function ( bundle ) { + bundle.write({ + format: options.format, + moduleName: 'async', + dest: options.outfile + }); + rimraf.sync(options.outpath); + }); + } + + compileModules(bundle, options); +} diff --git a/support/build/aggregate-bundle.js b/support/build/aggregate-bundle.js new file mode 100644 index 0000000..5e6e005 --- /dev/null +++ b/support/build/aggregate-bundle.js @@ -0,0 +1,9 @@ +import aggregateBuild from './aggregate-build'; + +aggregateBuild({ + es6: true, + outpath:'build/build-modules-es6', + outfile: 'build/async-bundle.js', + format: 'umd', + lodashRename: true +}); \ No newline at end of file diff --git a/support/build/aggregate-cjs.js b/support/build/aggregate-cjs.js new file mode 100644 index 0000000..f27b6bf --- /dev/null +++ b/support/build/aggregate-cjs.js @@ -0,0 +1,9 @@ +import aggregateBuild from './aggregate-build'; + +aggregateBuild({ + es6: true, + outpath:'build/build-modules-es6', + outfile: 'build/async-cjs.js', + format: 'cjs', + lodashRename: false +}); diff --git a/support/build/compile-modules.js b/support/build/compile-modules.js new file mode 100644 index 0000000..17d34ec --- /dev/null +++ b/support/build/compile-modules.js @@ -0,0 +1,34 @@ +import async from '../../lib'; +import {transformFile} from 'babel-core'; +import _ from 'lodash'; +import readdirR from 'recursive-readdir'; +import pluginCJS from 'babel-plugin-transform-es2015-modules-commonjs'; +import pluginLodashImportRename from './plugin-lodash-import-rename'; +import {join as joinPath} from 'path'; +import fs from 'fs-extra'; + +export default function(cb, options) { + options = _.defaults({}, options, {path:'lib/', outpath:'build/modules', es6: false, lodashRename: false}); + let plugins = []; + + if (options.lodashRename) { + plugins.push(pluginLodashImportRename); + } + if (!options.es6) { + plugins.push(pluginCJS); + } + + readdirR(options.path, [], function(err, files) { + fs.emptyDirSync(options.outpath); + fs.emptyDirSync(joinPath(options.outpath, 'internal')); + async.each(files, (file, callback) => { + var filename = file.startsWith(options.path) ? file.slice(options.path.length) : file; + transformFile(file, { + babelrc: false, + plugins: plugins + }, function(err, content) { + fs.writeFile(joinPath(options.outpath, filename), content.code, callback); + }); + }, cb); + }); +} diff --git a/support/build/modules-cjs.js b/support/build/modules-cjs.js new file mode 100644 index 0000000..09632ff --- /dev/null +++ b/support/build/modules-cjs.js @@ -0,0 +1,3 @@ +import compileModules from './compile-modules'; + +compileModules(function() {}, {es6: false}); diff --git a/support/build/plugin-lodash-import-rename.js b/support/build/plugin-lodash-import-rename.js new file mode 100644 index 0000000..cb765fa --- /dev/null +++ b/support/build/plugin-lodash-import-rename.js @@ -0,0 +1,22 @@ +import _ from 'lodash'; +import {dirname, sep} from 'path'; + +export default function() { + return { + visitor: { + + ImportDeclaration(path, mapping) { + let {node} = path; + let {value} = node.source; + + if (/\blodash\b/.test(value)) { + let f = mapping.file.opts.filename; + let dir = dirname(f).split(sep); + let relative = _.repeat('../', dir.length + 1); + + node.source.value = value.replace(/\blodash\b/, relative + 'deps/lodash-es'); + } + } + } + }; +} diff --git a/support/dependencies.json b/support/dependencies.json deleted file mode 100644 index 2388eb4..0000000 --- a/support/dependencies.json +++ /dev/null @@ -1,262 +0,0 @@ -{ - "apply": { - "async.util.restparam": "<%=version%>" - }, - "applyeach": { - "async.eachof": "<%=version%>", - "async.util.applyeach": "<%=version%>" - }, - "applyeachseries": { - "async.eachofseries": "<%=version%>", - "async.util.applyeach": "<%=version%>" - }, - "asyncify": { - "async.util.asyncify": "<%=version%>" - }, - "auto": { - "async.util.arrayeach": "<%=version%>", - "async.util.foreachof": "<%=version%>", - "async.util.indexof": "<%=version%>", - "async.util.isarray": "<%=version%>", - "async.util.keys": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.once": "<%=version%>", - "async.util.reduce": "<%=version%>", - "async.util.restparam": "<%=version%>", - "async.util.setimmediate": "<%=version%>" - }, - "cargo": { - "async.util.queue": "<%=version%>" - }, - "compose": { - "async.seq": "<%=version%>" - }, - "concat": { - "async.util.concat": "<%=version%>", - "async.util.doparallel": "<%=version%>" - }, - "concatseries": { - "async.util.concat": "<%=version%>", - "async.util.doseries": "<%=version%>" - }, - "constant": { - "async.util.restparam": "<%=version%>" - }, - "detect": { - "async.eachof": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.findgetresult": "<%=version%>", - "async.util.identity": "<%=version%>" - }, - "detectlimit": { - "async.eachoflimit": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.findgetresult": "<%=version%>", - "async.util.identity": "<%=version%>" - }, - "detectseries": { - "async.eachofseries": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.findgetresult": "<%=version%>", - "async.util.identity": "<%=version%>" - }, - "dir": { - "async.util.consolefn": "<%=version%>" - }, - "doduring": { - "async.during": "<%=version%>" - }, - "dountil": { - "async.dowhilst": "<%=version%>" - }, - "dowhilst": { - "async.whilst": "<%=version%>" - }, - "during": { - "async.util.noop": "<%=version%>", - "async.util.restparam": "<%=version%>" - }, - "each": { - "async.eachof": "<%=version%>", - "async.util.withoutindex": "<%=version%>" - }, - "eachlimit": { - "async.util.eachoflimit": "<%=version%>", - "async.util.withoutindex": "<%=version%>" - }, - "eachof": { - "async.util.keyiterator": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.once": "<%=version%>", - "async.util.onlyonce": "<%=version%>" - }, - "eachoflimit": { - "async.util.eachoflimit": "<%=version%>" - }, - "eachofseries": { - "async.util.keyiterator": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.once": "<%=version%>", - "async.util.onlyonce": "<%=version%>", - "async.util.setimmediate": "<%=version%>" - }, - "eachseries": { - "async.eachofseries": "<%=version%>", - "async.util.withoutindex": "<%=version%>" - }, - "ensureasync": { - "async.util.ensureasync": "<%=version%>" - }, - "every": { - "async.eachof": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.notid": "<%=version%>" - }, - "everylimit": { - "async.eachoflimit": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.notid": "<%=version%>" - }, - "filter": { - "async.util.doparallel": "<%=version%>", - "async.util.filter": "<%=version%>" - }, - "filterlimit": { - "async.util.doparallellimit": "<%=version%>", - "async.util.filter": "<%=version%>" - }, - "filterseries": { - "async.util.doseries": "<%=version%>", - "async.util.filter": "<%=version%>" - }, - "forever": { - "async.util.ensureasync": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.onlyonce": "<%=version%>" - }, - "iterator": {}, - "log": { - "async.util.consolefn": "<%=version%>" - }, - "map": { - "async.util.doparallel": "<%=version%>", - "async.util.mapasync": "<%=version%>" - }, - "maplimit": { - "async.util.doparallellimit": "<%=version%>", - "async.util.mapasync": "<%=version%>" - }, - "mapseries": { - "async.util.doseries": "<%=version%>", - "async.util.mapasync": "<%=version%>" - }, - "memoize": { - "async.util.identity": "<%=version%>", - "async.util.restparam": "<%=version%>", - "async.util.setimmediate": "<%=version%>" - }, - "nexttick": { - "async.util.nexttick": "<%=version%>" - }, - "parallel": { - "async.eachof": "<%=version%>", - "async.util.parallel": "<%=version%>" - }, - "parallellimit": { - "async.util.eachoflimit": "<%=version%>", - "async.util.parallel": "<%=version%>" - }, - "priorityqueue": { - "async.queue": "<%=version%>", - "async.util.arrayeach": "<%=version%>", - "async.util.isarray": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.setimmediate": "<%=version%>" - }, - "queue": { - "async.util.queue": "<%=version%>" - }, - "reduce": { - "async.eachofseries": "<%=version%>" - }, - "reduceright": { - "async.reduce": "<%=version%>", - "async.util.identity": "<%=version%>", - "async.util.map": "<%=version%>" - }, - "reject": { - "async.util.doparallel": "<%=version%>", - "async.util.reject": "<%=version%>" - }, - "rejectlimit": { - "async.util.doparallellimit": "<%=version%>", - "async.util.reject": "<%=version%>" - }, - "rejectseries": { - "async.util.doseries": "<%=version%>", - "async.util.reject": "<%=version%>" - }, - "retry": { - "async.series": "<%=version%>" - }, - "seq": { - "async.reduce": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.restparam": "<%=version%>" - }, - "series": { - "async.eachofseries": "<%=version%>", - "async.util.parallel": "<%=version%>" - }, - "setimmediate": { - "async.util.setimmediate": "<%=version%>" - }, - "some": { - "async.eachof": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.identity": "<%=version%>", - "async.util.tobool": "<%=version%>" - }, - "somelimit": { - "async.eachoflimit": "<%=version%>", - "async.util.createtester": "<%=version%>", - "async.util.identity": "<%=version%>", - "async.util.tobool": "<%=version%>" - }, - "sortby": { - "async.map": "<%=version%>", - "async.util.map": "<%=version%>" - }, - "times": { - "async.map": "<%=version%>", - "async.util.times": "<%=version%>" - }, - "timeslimit": { - "async.maplimit": "<%=version%>", - "async.util.range": "<%=version%>" - }, - "timesseries": { - "async.mapseries": "<%=version%>", - "async.util.times": "<%=version%>" - }, - "transform": { - "async.eachof": "<%=version%>", - "async.util.isarray": "<%=version%>" - }, - "unmemoize": {}, - "until": { - "async.whilst": "<%=version%>" - }, - "waterfall": { - "async.iterator": "<%=version%>", - "async.util.ensureasync": "<%=version%>", - "async.util.isarray": "<%=version%>", - "async.util.noop": "<%=version%>", - "async.util.once": "<%=version%>", - "async.util.restparam": "<%=version%>" - }, - "whilst": { - "async.util.noop": "<%=version%>", - "async.util.restparam": "<%=version%>" - } -} -- cgit v1.2.1