summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2017-04-16 21:21:27 -0700
committerAlexander Early <alexander.early@gmail.com>2017-04-16 21:21:27 -0700
commitee06b105568edefba8e7442696b7c02fb67e6e9b (patch)
tree52e0fc72f709954d4d967c1ad14b69042bc5368a
parent80361aaccbca9cd2af30b76e5e93b58d25faa65b (diff)
downloadasync-ee06b105568edefba8e7442696b7c02fb67e6e9b.tar.gz
use make to manage compiling individual files
-rw-r--r--Makefile10
-rwxr-xr-xsupport/build/compile8
-rw-r--r--support/build/compile-module.js18
-rw-r--r--support/build/compile-modules.js33
-rw-r--r--support/build/modules-cjs.js7
5 files changed, 20 insertions, 56 deletions
diff --git a/Makefile b/Makefile
index 904a373..8e5ef04 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ LINT_FILES = lib/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) $(shell fi
UMD_BUNDLE = $(BUILDDIR)/dist/async.js
UMD_BUNDLE_MIN = $(BUILDDIR)/dist/async.min.js
ES_MODULES = $(patsubst lib/%.js, build-es/%.js, $(JS_SRC))
+CJS_MODULES = $(patsubst lib/%.js, build/%.js, $(JS_SRC))
all: clean lint build test
@@ -41,8 +42,11 @@ lint:
# Compile the ES6 modules to singular bundles, and individual bundles
build-bundle: build-modules $(UMD_BUNDLE)
-build-modules:
- node $(SCRIPTS)/build/modules-cjs.js
+build-modules: $(CJS_MODULES)
+
+$(BUILDDIR)/%.js: lib/%.js
+ mkdir -p "$(@D)"
+ node $(SCRIPTS)/build/compile --file $< --output $@
$(UMD_BUNDLE): $(ES_MODULES) package.json
mkdir -p "$(@D)"
@@ -98,7 +102,7 @@ $(BUILD_ES)/%: %
.PHONY: build-modules build-bundle build-dist build-es build-config build-es-config test-build
-build: clean build-bundle build-dist build-es build-config build-es-config test-build
+build: build-bundle build-dist build-es build-config build-es-config test-build
.PHONY: test lint build all clean
diff --git a/support/build/compile b/support/build/compile
new file mode 100755
index 0000000..f159624
--- /dev/null
+++ b/support/build/compile
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+
+const compileModule = require('./compile-module');
+const yargs = require('yargs');
+
+compileModule(yargs.argv, (err) => {
+ if (err) throw err;
+})
diff --git a/support/build/compile-module.js b/support/build/compile-module.js
index 1a3e330..d07376b 100644
--- a/support/build/compile-module.js
+++ b/support/build/compile-module.js
@@ -1,22 +1,14 @@
const fs = require('fs');
const {transformFile} = require('babel-core');
-const _ = require('lodash');
const pluginCJS = require('babel-plugin-transform-es2015-modules-commonjs');
const pluginModuleExports = require('babel-plugin-add-module-exports');
-module.exports = function compileModule(opts, callback) {
- const options = _.defaults({}, opts, {
- es6: false,
- lodashRename: false
- });
- const plugins = [];
-
- if (!options.es6) {
- plugins.push(pluginModuleExports);
- plugins.push(pluginCJS);
- }
-
+module.exports = function compileModule(options, callback) {
const {file, output} = options;
+ const plugins = [
+ pluginModuleExports,
+ pluginCJS
+ ];
transformFile(file, {
babelrc: false,
diff --git a/support/build/compile-modules.js b/support/build/compile-modules.js
deleted file mode 100644
index 0a93aaf..0000000
--- a/support/build/compile-modules.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const async = require('async');
-const _ = require('lodash');
-const readdirR = require('recursive-readdir');
-const joinPath = require('path').join;
-const fs = require('fs-extra');
-const compileModule = require('./compile-module');
-
-module.exports = function(options, cb) {
- options = _.defaults({}, options, {
- path: 'lib/',
- outpath: 'build',
- es6: false
- });
- const { path, outpath } = options;
-
- readdirR(path, [], (err, files) => {
- fs.emptyDirSync(outpath);
- fs.emptyDirSync(joinPath(outpath, 'internal'));
- async.each(files, (file, callback) => {
- const outfile = file.startsWith(path) ?
- file.slice(path.length) :
- file;
- const finalPath = joinPath(outpath, outfile);
-
- compileModule({
- file,
- output: finalPath,
- es6: options.es6
- }, callback)
-
- }, cb);
- });
-}
diff --git a/support/build/modules-cjs.js b/support/build/modules-cjs.js
deleted file mode 100644
index aabd469..0000000
--- a/support/build/modules-cjs.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const compileModules = require('./compile-modules');
-
-compileModules({
- es6: false,
- path: 'lib/',
- outpath: 'build'
-}, err => { if (err) throw err; });