Revert "Switched from browserify to pure-cjs bundler."

This reverts commit bff9731b66.
This commit is contained in:
Ben Newman
2014-02-03 19:05:22 -05:00
parent 77c53dd5d4
commit 9f1ed709d0
2 changed files with 41 additions and 16 deletions
+40 -15
View File
@@ -1,6 +1,6 @@
'use strict';
var cjs = require('pure-cjs');
var browserify = require('browserify');
var grunt = require('grunt');
module.exports = function() {
@@ -18,26 +18,51 @@ module.exports = function() {
config.after = [config.after];
}
// Extract options
// create the bundle we'll work with
var entries = grunt.file.expand(config.entries);
var bundle = browserify(entries);
// Make sure the things that need to be exposed are.
var requires = config.requires || {};
if (requires instanceof Array) {
grunt.file.expand({
nonull: true, // Keep IDs that don't expand to anything.
cwd: "src"
}, requires).forEach(function(name) {
bundle.require("./build/modules/" + name, {
expose: name.replace(/\.js$/i, "")
});
});
} else if (typeof requires === "object") {
Object.keys(requires).forEach(function(name) {
bundle.require(requires[name], { expose: name });
});
}
// Extract other options
var options = {
input: config.entries[0],
output: config.outfile,
map: config.debug, // sourcemaps
exports: config.standalone, // global
transform: config.transforms,
dryRun: true // we will write to disk ourselves
debug: config.debug, // sourcemaps
standalone: config.standalone // global
};
// TODO: make sure this works, test with this too
config.transforms.forEach(function(transform) {
bundle.transform({}, transform);
});
// Actually bundle it up
var _this = this;
cjs.transform(options).then(function(result) {
grunt.file.write(config.outfile, config.after.reduce(function(src, fn) {
return fn.call(_this, src);
}, result.code));
bundle.bundle(options, function(err, src) {
if (err) {
grunt.log.error(err);
done();
}
done();
}, function(err) {
grunt.log.error(err);
config.after.forEach(function(fn) {
src = fn.call(_this, src);
});
grunt.file.write(config.outfile, src);
done();
});
};
+1 -1
View File
@@ -39,6 +39,7 @@
},
"devDependencies": {
"benchmark": "~1.0.0",
"browserify": "~3.20.0",
"coverify": "~1.0.4",
"envify": "~1.0.1",
"es5-shim": "~2.3.0",
@@ -59,7 +60,6 @@
"phantomjs": "~1.9",
"platform": "~1.0.0",
"populist": "~0.1.6",
"pure-cjs": "~1.8.0",
"recast": "~0.5.6",
"sauce-tunnel": "~1.1.0",
"semver": "~2.2.1",