@samitouri / QOS-React-2 / commits / bff9731b66

Switched from browserify to pure-cjs bundler.

Ingvar Stepanyan committed Jan 31, 2014 at 18:25 UTC bff9731b66093239dc0408fb1d83df423925b6f9
2 files changed +16 -41
grunt/tasks/browserify.js
+15 -40
@@ -1,6 +1,6 @@
1 'use strict';
2
3 -var browserify = require('browserify');
3 +var cjs = require('pure-cjs');
4 var grunt = require('grunt');
5
6 module.exports = function() {
@@ -18,51 +18,26 @@ module.exports = function() {
18 config.after = [config.after];
19 }
20
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
22 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
29 };
30
48 - // TODO: make sure this works, test with this too
49 - config.transforms.forEach(function(transform) {
50 - bundle.transform({}, transform);
51 - });
52 -
31 // Actually bundle it up
32 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));
37
65 - grunt.file.write(config.outfile, src);
38 + done();
39 + }, function(err) {
40 + grunt.log.error(err);
41 done();
42 });
43 };
package.json
+1 -1
@@ -39,7 +39,6 @@
39 },
40 "devDependencies": {
41 "benchmark": "~1.0.0",
42 - "browserify": "~3.20.0",
42 "coverify": "~1.0.4",
43 "envify": "~1.0.1",
44 "es5-shim": "~2.3.0",
@@ -60,6 +59,7 @@
59 "phantomjs": "~1.9",
60 "platform": "~1.0.0",
61 "populist": "~0.1.6",
62 + "pure-cjs": "~1.8.0",
63 "recast": "~0.5.6",
64 "sauce-tunnel": "~1.1.0",
65 "semver": "~2.2.1",