Skip to content

Commit bff9731

Browse files
committed
Switched from browserify to pure-cjs bundler.
1 parent 1666935 commit bff9731

2 files changed

Lines changed: 16 additions & 41 deletions

File tree

grunt/tasks/browserify.js

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var browserify = require('browserify');
3+
var cjs = require('pure-cjs');
44
var grunt = require('grunt');
55

66
module.exports = function() {
@@ -18,51 +18,26 @@ module.exports = function() {
1818
config.after = [config.after];
1919
}
2020

21-
// create the bundle we'll work with
22-
var entries = grunt.file.expand(config.entries);
23-
var bundle = browserify(entries);
24-
25-
// Make sure the things that need to be exposed are.
26-
var requires = config.requires || {};
27-
if (requires instanceof Array) {
28-
grunt.file.expand({
29-
nonull: true, // Keep IDs that don't expand to anything.
30-
cwd: "src"
31-
}, requires).forEach(function(name) {
32-
bundle.require("./build/modules/" + name, {
33-
expose: name.replace(/\.js$/i, "")
34-
});
35-
});
36-
} else if (typeof requires === "object") {
37-
Object.keys(requires).forEach(function(name) {
38-
bundle.require(requires[name], { expose: name });
39-
});
40-
}
41-
42-
// Extract other options
21+
// Extract options
4322
var options = {
44-
debug: config.debug, // sourcemaps
45-
standalone: config.standalone // global
23+
input: config.entries[0],
24+
output: config.outfile,
25+
map: config.debug, // sourcemaps
26+
exports: config.standalone, // global
27+
transform: config.transforms,
28+
dryRun: true // we will write to disk ourselves
4629
};
4730

48-
// TODO: make sure this works, test with this too
49-
config.transforms.forEach(function(transform) {
50-
bundle.transform({}, transform);
51-
});
52-
5331
// Actually bundle it up
5432
var _this = this;
55-
bundle.bundle(options, function(err, src) {
56-
if (err) {
57-
grunt.log.error(err);
58-
done();
59-
}
60-
61-
config.after.forEach(function(fn) {
62-
src = fn.call(_this, src);
63-
});
33+
cjs.transform(options).then(function(result) {
34+
grunt.file.write(config.outfile, config.after.reduce(function(src, fn) {
35+
return fn.call(_this, src);
36+
}, result.code));
6437

65-
grunt.file.write(config.outfile, src);
38+
done();
39+
}, function(err) {
40+
grunt.log.error(err);
6641
done();
6742
});
6843
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
},
4040
"devDependencies": {
4141
"benchmark": "~1.0.0",
42-
"browserify": "~3.20.0",
4342
"coverify": "~1.0.4",
4443
"envify": "~1.0.1",
4544
"es5-shim": "~2.3.0",
@@ -60,6 +59,7 @@
6059
"phantomjs": "~1.9",
6160
"platform": "~1.0.0",
6261
"populist": "~0.1.6",
62+
"pure-cjs": "~1.8.0",
6363
"recast": "~0.5.6",
6464
"sauce-tunnel": "~1.1.0",
6565
"semver": "~2.2.1",

0 commit comments

Comments
 (0)