From a0a81e980e0410783e4070e1d1518fed58a1d83f Mon Sep 17 00:00:00 2001 From: jackwanders Date: Sat, 15 Nov 2014 19:11:49 -0500 Subject: [PATCH 001/193] Ensure path to outfile exists before opening stream --- bin/cmd.js | 3 +++ package.json | 1 + test/externalize.js | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index d61bf1ea9..d7cc844b9 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -2,6 +2,8 @@ var fs = require('fs'); var JSONStream = require('JSONStream'); var through = require('through2'); +var mkdirp = require('mkdirp'); +var path = require('path'); var b = require('./args')(process.argv.slice(2)); process.stdout.on('error', process.exit); @@ -57,6 +59,7 @@ bundle.on('error', errorExit); var outfile = b.argv.o || b.argv.outfile; if (outfile) { + mkdirp.sync(path.dirname(outfile)); bundle.pipe(fs.createWriteStream(outfile)); } else { diff --git a/package.json b/package.json index e27146e72..40f99183d 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "insert-module-globals": "^6.1.0", "isarray": "0.0.1", "labeled-stream-splicer": "^1.0.0", + "mkdirp": "^0.5.0", "module-deps": "^3.5.0", "os-browserify": "~0.1.1", "parents": "~0.0.1", diff --git a/test/externalize.js b/test/externalize.js index 15b97fec6..a78a699ec 100644 --- a/test/externalize.js +++ b/test/externalize.js @@ -28,18 +28,18 @@ fs.writeFileSync( test('externalize bin', function (t) { t.plan(5); - + var commands = [ [ '-r', './robot.js', '-o', path.join(pubdir, 'common.js') ], [ '-x', './robot.js', 'beep.js', '-o', path.join(pubdir, 'beep.js') ], - [ '-x', './robot.js', 'boop.js', '-o', path.join(pubdir, 'boop.js') ] + [ '-x', './robot.js', 'boop.js', '-o', path.join(pubdir, 'boop/bop.js') ] ]; (function next () { if (commands.length === 0) { var common = fs.readFileSync(path.join(pubdir, 'common.js')); var beep = fs.readFileSync(path.join(pubdir, 'beep.js')); - var boop = fs.readFileSync(path.join(pubdir, 'boop.js')); - + var boop = fs.readFileSync(path.join(pubdir, 'boop/bop.js')); + vm.runInNewContext(common + beep, { console: { log: function (msg) { t.equal(msg, 'BEEP!') } } }); From 7c4391e30251033204163ac1bb4ce59dd5189ea5 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 12 Apr 2015 17:55:58 -0400 Subject: [PATCH 002/193] Sanitize json modules --- index.js | 3 ++- package.json | 1 + test/json.js | 26 ++++++++++++++++++++++++++ test/json/evil-chars.json | 3 +++ test/json/evil.js | 2 ++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/json/evil-chars.json create mode 100644 test/json/evil.js diff --git a/index.js b/index.js index 1216cdc81..ef10a7437 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,7 @@ var copy = require('shallow-copy'); var isarray = require('isarray'); var defined = require('defined'); var has = require('has'); +var sanitize = require('htmlescape').sanitize; var bresolve = require('browser-resolve'); var resolve = require('resolve'); @@ -583,7 +584,7 @@ Browserify.prototype._recorder = function (opts) { Browserify.prototype._json = function () { return through.obj(function (row, enc, next) { if (/\.json$/.test(row.file) && !isdedupe(row.source)) { - row.source = 'module.exports=' + row.source; + row.source = 'module.exports=' + sanitize(row.source); } this.push(row); next(); diff --git a/package.json b/package.json index 4fbe037f5..c6d770160 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "events": "~1.0.0", "glob": "^4.0.5", "has": "^1.0.0", + "htmlescape": "^1.1.0", "http-browserify": "^1.4.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", diff --git a/test/json.js b/test/json.js index 33dbbecfb..ffa5333f4 100644 --- a/test/json.js +++ b/test/json.js @@ -1,4 +1,5 @@ var browserify = require('../'); +var fs = require('fs'); var vm = require('vm'); var test = require('tap').test; @@ -16,3 +17,28 @@ test('json', function (t) { vm.runInNewContext(src, c); }); }); + +test('verify evil json', function(t) { + t.plan(1); + fs.readFile(__dirname + '/json/evil-chars.json', function(err, data) { + if (err) t.fail(err); + t.throws(function() { + vm.runInNewContext('(' + data.toString() + ')'); + }); + }); +}); + +test('evil json', function (t) { + t.plan(2); + var b = browserify(); + b.add(__dirname + '/json/evil.js'); + b.bundle(function (err, src) { + if (err) t.fail(err); + var c = { + ex : function (obj) { + t.same(obj, { evil : '\u2028\u2029' }); + } + }; + vm.runInNewContext(src, c); + }); +}); diff --git a/test/json/evil-chars.json b/test/json/evil-chars.json new file mode 100644 index 000000000..4a5851bb6 --- /dev/null +++ b/test/json/evil-chars.json @@ -0,0 +1,3 @@ +{ + "evil": "

" +} diff --git a/test/json/evil.js b/test/json/evil.js new file mode 100644 index 000000000..767e9cb27 --- /dev/null +++ b/test/json/evil.js @@ -0,0 +1,2 @@ +ex(require('./evil-chars.json')); +ex(require('./evil-chars')); From 6b46456a42644e4bfd323a1da8cd2c3a32863b48 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 19 Apr 2015 01:14:14 -0400 Subject: [PATCH 003/193] Remove 'v' shortcut for version --- bin/cmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cmd.js b/bin/cmd.js index d61bf1ea9..105e0f9c3 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -20,7 +20,7 @@ if (b.argv._[0] === 'help' || b.argv.h || b.argv.help .on('close', function () { process.exit(1) }) ; } -if (b.argv.v || b.argv.version) { +if (b.argv.version) { return console.log(require('../package.json').version); } From ef4fcee6c4ff61e8791f3d5ada16e63f48631f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 21 Apr 2015 13:54:03 +0200 Subject: [PATCH 004/193] readme: document opts.transform --- readme.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.markdown b/readme.markdown index e8972e9cc..4c9690678 100644 --- a/readme.markdown +++ b/readme.markdown @@ -368,6 +368,9 @@ requires will know where to resolve from. each file in the array. Use this for giant libs like jquery or threejs that don't have any requires or node-style globals but take forever to parse. +`opts.transform` is an array of transform functions or modules names which will +transform the source code before the parsing. + `opts.extensions` is an array of optional extra extensions for the module lookup machinery to use when the extension has not been specified. By default browserify considers only `.js` and `.json` files in such cases. From e7db329e96febc82dbfd87711626e57da6632015 Mon Sep 17 00:00:00 2001 From: Jesse McCarthy Date: Wed, 22 Apr 2015 09:34:20 -0400 Subject: [PATCH 005/193] Update constructor docs. --- readme.markdown | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/readme.markdown b/readme.markdown index e8972e9cc..a3d8232d3 100644 --- a/readme.markdown +++ b/readme.markdown @@ -355,14 +355,38 @@ b.bundle().pipe(process.stdout); var browserify = require('browserify') ``` -## var b = browserify(files=[] or opts={}) +## `browserify([files] [, opts])` -Create a browserify instance `b` from the entry main `files` or `opts.entries`. -`files` can be an array of files or a single file. +Returns a new browserify instance. -For each `file` in `files`, if `file` is a stream, its contents will be used. -You should use `opts.basedir` when using streaming files so that relative -requires will know where to resolve from. +
+
+files +
+ +
+String, file object, or array of those types (they may be mixed) specifying entry file(s). +
+ +
+opts +
+ +
+Object. +
+
+ +`files` and `opts` are both optional, but must be in the order shown if both are +passed. + +Entry files may be passed in `files` and / or `opts.entries`. + +If an entry file is a stream, its contents will be used. You should pass +`opts.basedir` when using streaming files so that relative requires can be +resolved. + +`opts.entries` has the same definition as `files`. `opts.noParse` is an array which will skip all require() and global parsing for each file in the array. Use this for giant libs like jquery or threejs that From efccc16ef17600892c4e8aff67d6b47db0e3b2a4 Mon Sep 17 00:00:00 2001 From: Ben Drucker Date: Sun, 12 Apr 2015 13:48:44 -0400 Subject: [PATCH 006/193] Link to umd docs about standalone global camel casing --- readme.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index e8972e9cc..ee63e5d6c 100644 --- a/readme.markdown +++ b/readme.markdown @@ -408,7 +408,8 @@ you are in a modern enough browser. When `opts.standalone` is a non-empty string, a standalone module is created with that name and a [umd](https://github.com/forbeslindesay/umd) wrapper. You can use namespaces in the standalone global export using a `.` in the string -name as a separator. For example: `'A.B.C'` +name as a separator, for example `'A.B.C'`. The global export will be [sanitized +and camel cased](https://github.com/ForbesLindesay/umd#name-casing-and-characters). Note that in standalone mode the `require()` calls from the original source will still be around, which may trip up AMD loaders scanning for `require()` calls. From 004a90f7d06f24ef79f140bcb849f6d49d8d43ef Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 25 Apr 2015 22:06:57 -0400 Subject: [PATCH 007/193] Update to defined@^1.0.0, xtend@^4.0.0 and punycode@^1.3.2 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4fbe037f5..ddf1a11f3 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "constants-browserify": "~0.0.1", "crypto-browserify": "^3.0.0", "deep-equal": "^1.0.0", - "defined": "~0.0.0", + "defined": "^1.0.0", "deps-sort": "^1.3.5", "domain-browser": "~1.1.0", "duplexer2": "~0.0.2", @@ -51,7 +51,7 @@ "parents": "^1.0.1", "path-browserify": "~0.0.0", "process": "^0.10.0", - "punycode": "~1.2.3", + "punycode": "^1.3.2", "querystring-es3": "~0.2.0", "read-only-stream": "^1.1.1", "readable-stream": "^1.1.13", @@ -69,7 +69,7 @@ "url": "~0.10.1", "util": "~0.10.1", "vm-browserify": "~0.0.1", - "xtend": "^3.0.0" + "xtend": "^4.0.0" }, "devDependencies": { "backbone": "~0.9.2", From 3be09e51881ed1d806654d26ad32237210021cc4 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 25 Apr 2015 22:09:26 -0400 Subject: [PATCH 008/193] Update module-deps to ^3.7.7 For this fix https://github.com/substack/module-deps/pull/80 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ddf1a11f3..a4988fa62 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "insert-module-globals": "^6.2.0", "isarray": "0.0.1", "labeled-stream-splicer": "^1.0.0", - "module-deps": "^3.7.0", + "module-deps": "^3.7.7", "os-browserify": "~0.1.1", "parents": "^1.0.1", "path-browserify": "~0.0.0", From 67700c2880f7456480695f28ae3e16e8b5e40004 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 26 Apr 2015 21:19:37 -0400 Subject: [PATCH 009/193] Update process to ~0.11.0 --- package.json | 2 +- test/bundle.js | 1 + test/coffeeify.js | 3 ++- test/external_shim.js | 6 +++++- test/global.js | 2 +- test/global_coffeeify.js | 3 ++- test/leak.js | 6 +++++- test/process.js | 3 ++- test/reset.js | 1 + test/reverse_multi_bundle.js | 1 + 10 files changed, 21 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 277dd6a7d..4dbb0d45a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "os-browserify": "~0.1.1", "parents": "^1.0.1", "path-browserify": "~0.0.0", - "process": "^0.10.0", + "process": "~0.11.0", "punycode": "^1.3.2", "querystring-es3": "~0.2.0", "read-only-stream": "^1.1.1", diff --git a/test/bundle.js b/test/bundle.js index 025714414..115317a61 100644 --- a/test/bundle.js +++ b/test/bundle.js @@ -13,6 +13,7 @@ test('bundle', function (t) { var c = { setTimeout : setTimeout, + clearTimeout : clearTimeout, console : console }; vm.runInNewContext(src, c); diff --git a/test/coffeeify.js b/test/coffeeify.js index e63416af9..176008c00 100644 --- a/test/coffeeify.js +++ b/test/coffeeify.js @@ -11,7 +11,8 @@ test('coffeeify with an implicit global', function (t) { if (err) t.fail(err); vm.runInNewContext(src, { console: { log: log }, - setTimeout: setTimeout + setTimeout: setTimeout, + clearTimeout: clearTimeout }); function log (msg) { t.equal(msg, 'eyo') } }); diff --git a/test/external_shim.js b/test/external_shim.js index 4f595389c..63739c00a 100644 --- a/test/external_shim.js +++ b/test/external_shim.js @@ -14,7 +14,11 @@ test('requiring a shimmed module name from an external bundle', function (t) { b2.bundle(function (err, src2) { t.plan(1); - var c = {setTimeout: setTimeout, console: console}; + var c = { + console: console, + setTimeout: setTimeout, + clearTimeout: clearTimeout + }; vm.runInNewContext(src1 + src2, c); t.ok(c.require('bundle1').shim === c.require('bundle2').shim); diff --git a/test/global.js b/test/global.js index 954c0c371..b860abb86 100644 --- a/test/global.js +++ b/test/global.js @@ -69,7 +69,7 @@ test('process.nextTick', function (t) { var b = browserify(); b.add(__dirname + '/global/tick.js'); b.bundle(function (err, src) { - var c = { t: t, setTimeout: setTimeout }; + var c = { t: t, setTimeout: setTimeout, clearTimeout: clearTimeout }; vm.runInNewContext(src, c); }); }); diff --git a/test/global_coffeeify.js b/test/global_coffeeify.js index 47e6da41d..00aa54a1d 100644 --- a/test/global_coffeeify.js +++ b/test/global_coffeeify.js @@ -11,7 +11,8 @@ test('coffeeify globally', function (t) { if (err) t.fail(err); vm.runInNewContext(src, { console: { log: log }, - setTimeout: setTimeout + setTimeout: setTimeout, + clearTimeout: clearTimeout }); function log (msg) { t.equal(msg, 'eyo') } }); diff --git a/test/leak.js b/test/leak.js index 2e2fa8d21..7479640c6 100644 --- a/test/leak.js +++ b/test/leak.js @@ -30,7 +30,11 @@ test('leaking information about system paths (process)', function (t) { t.equal(src.indexOf(dirstring), -1, 'temp directory visible'); t.equal(src.indexOf(process.cwd()), -1, 'cwd directory visible'); t.equal(src.indexOf('/home'), -1, 'home directory visible'); - vm.runInNewContext(src, { t: t, setTimeout: setTimeout }); + vm.runInNewContext(src, { + t: t, + setTimeout: setTimeout, + clearTimeout: clearTimeout + }); }); }); diff --git a/test/process.js b/test/process.js index 0660d5429..83ffa14ff 100644 --- a/test/process.js +++ b/test/process.js @@ -13,7 +13,8 @@ test('implicit process global', function (t) { t.equal(two, 2); t.end(); }, - setTimeout: setTimeout + setTimeout: setTimeout, + clearTimeout: clearTimeout }; vm.runInNewContext(src, c); }); diff --git a/test/reset.js b/test/reset.js index 10499c860..dad18b3af 100644 --- a/test/reset.js +++ b/test/reset.js @@ -18,6 +18,7 @@ test('reset', function (t) { t.ifError(err); var c = { setTimeout : setTimeout, + clearTimeout : clearTimeout, console : console }; vm.runInNewContext(src, c); diff --git a/test/reverse_multi_bundle.js b/test/reverse_multi_bundle.js index 06f273375..8d9f8325f 100644 --- a/test/reverse_multi_bundle.js +++ b/test/reverse_multi_bundle.js @@ -38,6 +38,7 @@ test('reverse multi bundle', function (t) { var src = appSrc + ';' + lazySrc; var c = { setTimeout: setTimeout, + clearTimeout: clearTimeout, t: t }; vm.runInNewContext(src, c); From a762d3bce06ae09b2cec2a1e8025aec2b283e470 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 26 Apr 2015 23:12:43 -0400 Subject: [PATCH 010/193] Bump insert-module-globals to ^6.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4dbb0d45a..dcf7134c1 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "http-browserify": "^1.4.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", - "insert-module-globals": "^6.2.0", + "insert-module-globals": "^6.4.0", "isarray": "0.0.1", "labeled-stream-splicer": "^1.0.0", "module-deps": "^3.7.7", From b9727cfcb4fe2d03e11e517e5f41c37704ec5f39 Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Thu, 30 Apr 2015 09:09:41 -0700 Subject: [PATCH 011/193] 10.0.0 --- changelog.markdown | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 4cbbdb7be..c2dced4bb 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,21 @@ +# 10.0.0 + +## Possibly Breaking Change +The ‘process’ dependency was updated to ~0.11.0, this module is inserted into bundles as the ‘process’ global/dependency. +Previously, an unhandled error thrown in a ‘process.nextTick’ task would prevent any subsequent tasks from running, forever. +The task queue now recovers from this condition, but may do so on a future browser tick. +As part of this update, ‘process.nextTick’ now accepts variadic arguments, passed to the task, added to io.js in 1.8.1. + +* [#1231](https://github.com/substack/node-browserify/pull/1231) +* [defunctzombie/node-process#38](https://github.com/defunctzombie/node-process/pull/38) +* [iojs/io.js#1077](https://github.com/iojs/io.js/pull/1077) + +## Other changes + +* Escapes JavaScript-unsafe characters from JSON. [#1211](https://github.com/substack/node-browserify/pull/1211) +* Removes ‘-v’ shortcut for ‘--version’ (conflicted with watchify) [#1222](https://github.com/substack/node-browserify/pull/1222) +* Updated ‘defined’, ‘punycode’, ‘module-deps’, and ‘xtend’ dependencies to reduce install size [#1230](https://github.com/substack/node-browserify/pull/1230) + # 9.0.8 makes `.require({ expose: 'name' })` and `require('name')` work at the same time diff --git a/package.json b/package.json index dcf7134c1..af6f0e909 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "9.0.8", + "version": "10.0.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 6df33e5cb0e9110f7656bf07109f245170df5a19 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Sun, 3 May 2015 13:01:51 -0700 Subject: [PATCH 012/193] test for browserField: false --- test/ignore_browser_field.js | 21 +++++++++++++++++++ test/ignore_browser_field/main.js | 2 ++ .../node_modules/a/browser.js | 1 + .../node_modules/a/main.js | 1 + .../node_modules/a/package.json | 6 ++++++ .../node_modules/b/browser-x.js | 1 + .../node_modules/b/main.js | 1 + .../node_modules/b/package.json | 8 +++++++ test/ignore_browser_field/node_modules/b/x.js | 1 + 9 files changed, 42 insertions(+) create mode 100644 test/ignore_browser_field.js create mode 100644 test/ignore_browser_field/main.js create mode 100644 test/ignore_browser_field/node_modules/a/browser.js create mode 100644 test/ignore_browser_field/node_modules/a/main.js create mode 100644 test/ignore_browser_field/node_modules/a/package.json create mode 100644 test/ignore_browser_field/node_modules/b/browser-x.js create mode 100644 test/ignore_browser_field/node_modules/b/main.js create mode 100644 test/ignore_browser_field/node_modules/b/package.json create mode 100644 test/ignore_browser_field/node_modules/b/x.js diff --git a/test/ignore_browser_field.js b/test/ignore_browser_field.js new file mode 100644 index 000000000..a925f2e62 --- /dev/null +++ b/test/ignore_browser_field.js @@ -0,0 +1,21 @@ +var test = require('tap').test; +var browserify = require('../'); +var path = require('path'); +var mainfile = path.join(__dirname, 'ignore_browser_field/main.js'); +var vm = require('vm'); + +test('ignore browser field', function (t) { + t.plan(3); + var b = browserify(mainfile, { browserField: false }); + var expected = [ 'A:NODE', 'B:X.JS' ]; + + b.bundle(function (err, src) { + t.ifError(err); + var c = { console: { log: log } }; + vm.runInNewContext(src, c); + + function log (msg) { + t.equal(msg, expected.shift()); + } + }); +}); diff --git a/test/ignore_browser_field/main.js b/test/ignore_browser_field/main.js new file mode 100644 index 000000000..bae4a2290 --- /dev/null +++ b/test/ignore_browser_field/main.js @@ -0,0 +1,2 @@ +console.log(require('a')); +console.log(require('b')); diff --git a/test/ignore_browser_field/node_modules/a/browser.js b/test/ignore_browser_field/node_modules/a/browser.js new file mode 100644 index 000000000..229aa83cb --- /dev/null +++ b/test/ignore_browser_field/node_modules/a/browser.js @@ -0,0 +1 @@ +module.exports = 'A:BROWSER' diff --git a/test/ignore_browser_field/node_modules/a/main.js b/test/ignore_browser_field/node_modules/a/main.js new file mode 100644 index 000000000..1f95fc3c3 --- /dev/null +++ b/test/ignore_browser_field/node_modules/a/main.js @@ -0,0 +1 @@ +module.exports = 'A:NODE' diff --git a/test/ignore_browser_field/node_modules/a/package.json b/test/ignore_browser_field/node_modules/a/package.json new file mode 100644 index 000000000..d7572b6f9 --- /dev/null +++ b/test/ignore_browser_field/node_modules/a/package.json @@ -0,0 +1,6 @@ +{ + "name": "a", + "version": "1.0.0", + "main": "main.js", + "browser": "browser.js" +} diff --git a/test/ignore_browser_field/node_modules/b/browser-x.js b/test/ignore_browser_field/node_modules/b/browser-x.js new file mode 100644 index 000000000..aca586288 --- /dev/null +++ b/test/ignore_browser_field/node_modules/b/browser-x.js @@ -0,0 +1 @@ +module.exports = 'browser-x.js' diff --git a/test/ignore_browser_field/node_modules/b/main.js b/test/ignore_browser_field/node_modules/b/main.js new file mode 100644 index 000000000..5b7a8817b --- /dev/null +++ b/test/ignore_browser_field/node_modules/b/main.js @@ -0,0 +1 @@ +module.exports = ('b:' + require('./x.js')).toUpperCase(); diff --git a/test/ignore_browser_field/node_modules/b/package.json b/test/ignore_browser_field/node_modules/b/package.json new file mode 100644 index 000000000..021d8bb38 --- /dev/null +++ b/test/ignore_browser_field/node_modules/b/package.json @@ -0,0 +1,8 @@ +{ + "name": "b", + "version": "1.0.0", + "main": "main.js", + "browser": { + "./x.js": "./browser-x.js" + } +} diff --git a/test/ignore_browser_field/node_modules/b/x.js b/test/ignore_browser_field/node_modules/b/x.js new file mode 100644 index 000000000..43396403b --- /dev/null +++ b/test/ignore_browser_field/node_modules/b/x.js @@ -0,0 +1 @@ +module.exports = 'x.js'; From df00165be759d15e8a1e655d0f29daf34efee390 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Sun, 3 May 2015 13:12:28 -0700 Subject: [PATCH 013/193] opts.browserField === false implementation, passes its test --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ef10a7437..f30fbb7fa 100644 --- a/index.js +++ b/index.js @@ -61,6 +61,13 @@ function Browserify (files, opts) { self._transforms = []; self._entryOrder = 0; self._ticked = false; + self._bresolve = opts.browserField === false + ? function (id, opts, cb) { + if (!opts.basedir) opts.basedir = path.dirname(opts.filename) + resolve(id, opts, cb) + } + : bresolve + ; var ignoreTransform = [].concat(opts.ignoreTransform).filter(Boolean); self._filterTransform = function (tr) { @@ -447,7 +454,7 @@ Browserify.prototype._createDeps = function (opts) { mopts.resolve = function (id, parent, cb) { if (self._ignore.indexOf(id) >= 0) return cb(null, paths.empty, {}); - bresolve(id, parent, function (err, file, pkg) { + self._bresolve(id, parent, function (err, file, pkg) { if (file && self._ignore.indexOf(file) >= 0) { return cb(null, paths.empty, {}); } From fe3c8a6751af2817e9a5c884ede75605114da8ef Mon Sep 17 00:00:00 2001 From: James Halliday Date: Sun, 3 May 2015 13:23:43 -0700 Subject: [PATCH 014/193] --no-browser-field and --node --- bin/advanced.txt | 11 ++++++++++- bin/args.js | 13 +++++++++++-- readme.markdown | 14 +++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/bin/advanced.txt b/bin/advanced.txt index 23ed10f31..c0efe1226 100644 --- a/bin/advanced.txt +++ b/bin/advanced.txt @@ -51,6 +51,15 @@ Advanced Options: to just "__filename,__dirname". This is handy if you want to run bundles in node. + --no-browser-field, --no-bf + + Turn off package.json browser field resolution. This is also handy if you + need to run a bundle in node. + + --node + + Alias for --bare and --no-browser-field. + --full-paths Turn off converting module ids into numerical indexes. This is useful for @@ -70,7 +79,7 @@ Advanced Options: Consider files with specified EXTENSION as modules, this option can used multiple times. - --global-transform=MODULE, --g MODULE + --global-transform=MODULE, -g MODULE Use a transform module on all files after any ordinary transforms have run. diff --git a/bin/args.js b/bin/args.js index d9fd01ccc..d9906862a 100644 --- a/bin/args.js +++ b/bin/args.js @@ -13,12 +13,14 @@ module.exports = function (args, opts) { var argv = subarg(args, { 'boolean': [ 'deps', 'pack', 'ig', 'dg', 'im', 'd', 'list', 'builtins', - 'commondir', 'bare', 'full-paths', 'bundle-external' + 'commondir', 'bare', 'full-paths', 'bundle-external', 'bf', + 'node' ], string: [ 's', 'r', 'u', 'x', 't', 'i', 'o', 'e', 'c', 'it' ], alias: { ig: [ 'insert-globals', 'fast' ], dg: [ 'detect-globals', 'detectGlobals', 'dg' ], + bf: [ 'browser-field', 'browserField ' ], im: 'ignore-missing', it: 'ignore-transform', igv: 'insert-global-vars', @@ -43,7 +45,9 @@ module.exports = function (args, opts) { d: false, builtins: true, commondir: true, - 'bundle-external': true + 'bundle-external': true, + bf: true, + node: false } }); @@ -60,6 +64,10 @@ module.exports = function (args, opts) { return path.resolve(process.cwd(), entry); }); + if (argv.node) { + argv.bare = true; + argv.browserField = false; + } if (argv.bare) { argv.builtins = false; argv.commondir = false; @@ -80,6 +88,7 @@ module.exports = function (args, opts) { commondir: argv.commondir === false ? false : undefined, bundleExternal: argv['bundle-external'], basedir: argv.basedir, + browserField: argv.browserField, detectGlobals: argv.detectGlobals, insertGlobals: argv['insert-globals'] || argv.ig, diff --git a/readme.markdown b/readme.markdown index 3e3c88a4f..ce20e5dab 100644 --- a/readme.markdown +++ b/readme.markdown @@ -159,6 +159,15 @@ Advanced Options: to just "__filename,__dirname". This is handy if you want to run bundles in node. + --no-browser-field, --no-bf + + Turn off package.json browser field resolution. This is also handy if you + need to run a bundle in node. + + --node + + Alias for --bare and --no-browser-field. + --full-paths Turn off converting module ids into numerical indexes. This is useful for @@ -178,11 +187,6 @@ Advanced Options: Consider files with specified EXTENSION as modules, this option can used multiple times. - --ignore-transform=MODULE, --it MODULE - - Any transforms matching the given name will be ignored, including - those in your module dependencies. - --global-transform=MODULE, -g MODULE Use a transform module on all files after any ordinary transforms have run. From 0ad9b05b09838ecc100c9c6aae0670ec3c9a79ed Mon Sep 17 00:00:00 2001 From: James Halliday Date: Mon, 4 May 2015 10:11:24 -0700 Subject: [PATCH 015/193] 10.1.0 --- changelog.markdown | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index c2dced4bb..263eecdd9 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,13 @@ +# 10.1.0 + +adds `--no-browser-field` and `opts.browserField = false` behavior to turn off +the package.json browser field. This is useful if you want to make a bundle with +a target of node or some environment with shimmed node primitives. + +A new alias `--node` sets `--no-browser-field` and `--bare`. + +https://github.com/substack/node-browserify/pull/1240 + # 10.0.0 ## Possibly Breaking Change diff --git a/package.json b/package.json index af6f0e909..6f6431e1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.0.0", + "version": "10.1.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 2a08528bb6b67cb6359157519b8e438d2e2d5e35 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 5 May 2015 23:42:35 -0400 Subject: [PATCH 016/193] Remove "isDedupe" json check watchify doesn't cache when "deps" are emitted, it caches module-deps' output - which would be the preprocessed json. --- index.js | 8 +------- test/double_bundle_json.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index f30fbb7fa..bf098a57a 100644 --- a/index.js +++ b/index.js @@ -590,7 +590,7 @@ Browserify.prototype._recorder = function (opts) { Browserify.prototype._json = function () { return through.obj(function (row, enc, next) { - if (/\.json$/.test(row.file) && !isdedupe(row.source)) { + if (/\.json$/.test(row.file)) { row.source = 'module.exports=' + sanitize(row.source); } this.push(row); @@ -627,12 +627,6 @@ Browserify.prototype._syntax = function () { }); }; -function isdedupe (src) { // mega-hack - return /^arguments\[4\]\[/.test(src) - && /\]\[0\]\.apply\(exports,arguments\)$/.test(src) - ; -} - Browserify.prototype._dedupe = function () { return through.obj(function (row, enc, next) { if (!row.dedupeIndex && row.dedupe) { diff --git a/test/double_bundle_json.js b/test/double_bundle_json.js index f692404fc..ac72709b7 100644 --- a/test/double_bundle_json.js +++ b/test/double_bundle_json.js @@ -1,6 +1,8 @@ var browserify = require('../'); var vm = require('vm'); var test = require('tap').test; +var through = require('through2'); +var xtend = require('xtend'); test('double bundle json', function (t) { t.plan(6); @@ -12,11 +14,16 @@ test('double bundle json', function (t) { var cache = {}; var b = browserify(__dirname + '/double_bundle_json/index.js', { - cache: cache, fullPaths: true - }); - b.on('dep', function (row) { - cache[row.id] = row; + cache: cache }); + b.pipeline.get('deps').push(through.obj(function(row, enc, next) { + cache[row.file] = { + source: row.source, + deps: xtend(row.deps) + }; + this.push(row); + next(); + })); b.bundle(function (err, src0) { t.ifError(err); vm.runInNewContext(src0, { console: { log: log0 } }); From a2288659c7a0ac9e6a6760edf61e5b147d27f232 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Wed, 6 May 2015 13:27:22 -0700 Subject: [PATCH 017/193] Replace JSONStream with jsonstream NPM now has opinions about names of modules when publishing. We have an internal NPM registry and cannot sync browserify to is due to this dependency. No fear, @dominictarr has published a lowercase version. --- bin/cmd.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index 105e0f9c3..7acb11f48 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -1,6 +1,6 @@ #!/usr/bin/env node var fs = require('fs'); -var JSONStream = require('JSONStream'); +var JSONStream = require('jsonstream'); var through = require('through2'); var b = require('./args')(process.argv.slice(2)); diff --git a/package.json b/package.json index 6f6431e1d..0facc6600 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "javascript" ], "dependencies": { - "JSONStream": "~0.10.0", "assert": "~1.3.0", "browser-pack": "^4.0.0", "browser-resolve": "^1.7.1", @@ -46,6 +45,7 @@ "inherits": "~2.0.1", "insert-module-globals": "^6.4.0", "isarray": "0.0.1", + "jsonstream": "^1.0.3", "labeled-stream-splicer": "^1.0.0", "module-deps": "^3.7.7", "os-browserify": "~0.1.1", From 5264f3a058a6c18c28fbcfd2631273da28640c8a Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Wed, 6 May 2015 18:27:27 -0400 Subject: [PATCH 018/193] Make sure entry paths are always full paths --- bin/args.js | 2 +- index.js | 6 +++++- test/entry.js | 25 ++++++++++++++++++++++++- test/entry_relative.js | 42 ++++++++++++++++++++++++++++++++++++++++++ test/multi_entry.js | 22 +++++++++++++++++++--- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 test/entry_relative.js diff --git a/bin/args.js b/bin/args.js index d9906862a..fe4d9c384 100644 --- a/bin/args.js +++ b/bin/args.js @@ -61,7 +61,7 @@ module.exports = function (args, opts) { s.resume(); return rs; } - return path.resolve(process.cwd(), entry); + return entry; }); if (argv.node) { diff --git a/index.js b/index.js index f30fbb7fa..08b05ae1f 100644 --- a/index.js +++ b/index.js @@ -180,7 +180,11 @@ Browserify.prototype.require = function (file, opts) { self._bpack.hasExports = true; } - if (row.entry) row.order = self._entryOrder ++; + if (row.entry) { + row.file = path.resolve(basedir, row.file); + row.order = self._entryOrder ++; + } + if (opts.transform === false) row.transform = false; self.pipeline.write(row); return self; diff --git a/test/entry.js b/test/entry.js index f9b37d06c..34d91e9f6 100644 --- a/test/entry.js +++ b/test/entry.js @@ -3,9 +3,32 @@ var vm = require('vm'); var test = require('tap').test; test('entry', function (t) { - t.plan(2); + t.plan(3); var b = browserify(__dirname + '/entry/main.js'); + b.on('dep', function(row) { + if (row.entry) t.equal(row.file, __dirname + '/entry/main.js'); + }); + b.bundle(function (err, src) { + var c = { + done : function (one, two) { + t.equal(one, 1); + t.equal(two, 2); + t.end(); + } + }; + vm.runInNewContext(src, c); + }); +}); + +test('entry via add', function (t) { + t.plan(3); + + var b = browserify(); + b.add(__dirname + '/entry/main.js'); + b.on('dep', function(row) { + if (row.entry) t.equal(row.file, __dirname + '/entry/main.js'); + }); b.bundle(function (err, src) { var c = { done : function (one, two) { diff --git a/test/entry_relative.js b/test/entry_relative.js new file mode 100644 index 000000000..123532c18 --- /dev/null +++ b/test/entry_relative.js @@ -0,0 +1,42 @@ +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +test('entry - relative path', function (t) { + t.plan(3); + + var b = browserify('entry/main.js'); + b.on('dep', function(row) { + if (row.entry) t.equal(row.file, __dirname + '/entry/main.js'); + }); + b.bundle(function (err, src) { + var c = { + done : function (one, two) { + t.equal(one, 1); + t.equal(two, 2); + t.end(); + } + }; + vm.runInNewContext(src, c); + }); +}); + +test('entry - relative path via add', function (t) { + t.plan(3); + + var b = browserify({basedir: __dirname}); + b.add('entry/main.js'); + b.on('dep', function(row) { + if (row.entry) t.equal(row.file, __dirname + '/entry/main.js'); + }); + b.bundle(function (err, src) { + var c = { + done : function (one, two) { + t.equal(one, 1); + t.equal(two, 2); + t.end(); + } + }; + vm.runInNewContext(src, c); + }); +}); diff --git a/test/multi_entry.js b/test/multi_entry.js index 3b5812cf3..45df2bc87 100644 --- a/test/multi_entry.js +++ b/test/multi_entry.js @@ -10,14 +10,20 @@ var testFiles = [ ]; test('multi entry', function (t) { - t.plan(3); + t.plan(6); var b = browserify([ testFiles[0], testFiles[1] ]); b.add(testFiles[2]); - + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + b.bundle(function (err, src) { var c = { times : 0, @@ -28,7 +34,7 @@ test('multi entry', function (t) { }); test('entries as streams', function (t) { - t.plan(3); + t.plan(6); // transform paths to streams for (var i = 0; i < testFiles.length; i++) { @@ -44,6 +50,16 @@ test('entries as streams', function (t) { ], opts); b.add(testFiles[2]); + b.on('dep', function(row) { + if (row.entry) { + t.similar( + row.file, + RegExp(__dirname + '/multi_entry/_stream_[\\d].js'), + 'should be full entry path' + ); + } + }); + b.bundle(function (err, src) { var c = { times : 0, From fb86b454d3b344130c686c0a89809b7b53109810 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 6 May 2015 16:34:29 -0700 Subject: [PATCH 019/193] 10.1.1 --- changelog.markdown | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 263eecdd9..469fcf59b 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 10.1.1 + +ensures that entry paths are always full paths + +https://github.com/substack/node-browserify/pull/1248 + # 10.1.0 adds `--no-browser-field` and `opts.browserField = false` behavior to turn off diff --git a/package.json b/package.json index 6f6431e1d..5e734e385 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.1.0", + "version": "10.1.1", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 1ca71e23212e16a8c52f150b2e73c28d063a686d Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 7 May 2015 12:32:18 -0400 Subject: [PATCH 020/193] Update deps to avoid jsonstream npm case problems See https://github.com/substack/node-browserify/pull/1247 --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b8c70eaeb..14683b76b 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "dependencies": { "assert": "~1.3.0", - "browser-pack": "^4.0.0", + "browser-pack": "^4.0.3", "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", "buffer": "^3.0.0", @@ -33,7 +33,7 @@ "crypto-browserify": "^3.0.0", "deep-equal": "^1.0.0", "defined": "^1.0.0", - "deps-sort": "^1.3.5", + "deps-sort": "^1.3.7", "domain-browser": "~1.1.0", "duplexer2": "~0.0.2", "events": "~1.0.0", @@ -43,11 +43,11 @@ "http-browserify": "^1.4.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", - "insert-module-globals": "^6.4.0", + "insert-module-globals": "^6.4.1", "isarray": "0.0.1", "jsonstream": "^1.0.3", "labeled-stream-splicer": "^1.0.0", - "module-deps": "^3.7.7", + "module-deps": "^3.7.11", "os-browserify": "~0.1.1", "parents": "^1.0.1", "path-browserify": "~0.0.0", From 66a5842aebbbdc00994c689b702c63f4cbb927ab Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 7 May 2015 12:34:31 -0400 Subject: [PATCH 021/193] 10.1.2 --- changelog.markdown | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 469fcf59b..a4d2ceaa2 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,11 @@ +# 10.1.2 + +Replace JSONStream with jsonstream +Update deps to avoid jsonstream npm case problems + +https://github.com/substack/node-browserify/pull/1247 +https://github.com/substack/node-browserify/commit/1ca71e23 + # 10.1.1 ensures that entry paths are always full paths diff --git a/package.json b/package.json index 14683b76b..c339bbb17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.1.1", + "version": "10.1.2", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 4d65dfca8b86645796b89f3cce8b794df0896c50 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 7 May 2015 16:44:43 -0400 Subject: [PATCH 022/193] replace jsonstream with JSONStream --- bin/cmd.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index 7acb11f48..105e0f9c3 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -1,6 +1,6 @@ #!/usr/bin/env node var fs = require('fs'); -var JSONStream = require('jsonstream'); +var JSONStream = require('JSONStream'); var through = require('through2'); var b = require('./args')(process.argv.slice(2)); diff --git a/package.json b/package.json index c339bbb17..eaa753d26 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "javascript" ], "dependencies": { + "JSONStream": "^1.0.3", "assert": "~1.3.0", "browser-pack": "^4.0.3", "browser-resolve": "^1.7.1", @@ -45,7 +46,6 @@ "inherits": "~2.0.1", "insert-module-globals": "^6.4.1", "isarray": "0.0.1", - "jsonstream": "^1.0.3", "labeled-stream-splicer": "^1.0.0", "module-deps": "^3.7.11", "os-browserify": "~0.1.1", From 1ff88d58830b954d3ea47fb10f6b7df05ab7a785 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 7 May 2015 17:26:06 -0400 Subject: [PATCH 023/193] 10.1.3 --- changelog.markdown | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index a4d2ceaa2..7d6c58d28 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 10.1.3 + +Replace jsonstream with JSONStream + +https://github.com/substack/node-browserify/pull/1252 + # 10.1.2 Replace JSONStream with jsonstream diff --git a/package.json b/package.json index eaa753d26..9d52d6ff0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.1.2", + "version": "10.1.3", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 9271862a2c5f336021ca3c624f71a4f0f81a0705 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 7 May 2015 21:07:46 -0400 Subject: [PATCH 024/193] Add syntax check cache --- index.js | 11 +++++++-- test/syntax_cache.js | 47 ++++++++++++++++++++++++++++++++++++ test/syntax_cache/invalid.js | 2 ++ test/syntax_cache/valid.js | 2 ++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/syntax_cache.js create mode 100644 test/syntax_cache/invalid.js create mode 100644 test/syntax_cache/valid.js diff --git a/index.js b/index.js index 08b05ae1f..0784f822e 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ var isarray = require('isarray'); var defined = require('defined'); var has = require('has'); var sanitize = require('htmlescape').sanitize; +var shasum = require('shasum'); var bresolve = require('browser-resolve'); var resolve = require('resolve'); @@ -68,6 +69,7 @@ function Browserify (files, opts) { } : bresolve ; + self._syntaxCache = {}; var ignoreTransform = [].concat(opts.ignoreTransform).filter(Boolean); self._filterTransform = function (tr) { @@ -623,9 +625,14 @@ Browserify.prototype._unshebang = function () { }; Browserify.prototype._syntax = function () { + var self = this; return through.obj(function (row, enc, next) { - var err = syntaxError(row.source, row.file || row.id); - if (err) return this.emit('error', err); + var h = shasum(row.source); + if (typeof self._syntaxCache[h] === 'undefined') { + var err = syntaxError(row.source, row.file || row.id); + if (err) return this.emit('error', err); + self._syntaxCache[h] = true; + } this.push(row); next(); }); diff --git a/test/syntax_cache.js b/test/syntax_cache.js new file mode 100644 index 000000000..ff2a5deec --- /dev/null +++ b/test/syntax_cache.js @@ -0,0 +1,47 @@ +var Seq = require('seq'); +var browserify = require('../'); +var test = require('tap').test; +var shasum = require('shasum'); + +test('syntax cache - valid', function (t) { + t.plan(2); + + var expectedCache = {} + var cacheKey; + + var b = browserify(__dirname + '/syntax_cache/valid.js'); + b.once('dep', function(row) { + cacheKey = shasum(row.source); + expectedCache[cacheKey] = true; + }); + + Seq() + .seq(function() { b.bundle(this); }) + .seq(function() { + t.deepEqual(b._syntaxCache, expectedCache); + b._syntaxCache[cacheKey] = expectedCache[cacheKey] = 'beep'; + b.bundle(function(err, src) { + // if the cache worked, the "cacheKey" + // should not be reset to "true" + t.deepEqual(b._syntaxCache, expectedCache); + }); + }); +}); + +test('syntax cache - skip invalid', function (t) { + t.plan(5); + + var b = browserify(__dirname + '/syntax_cache/invalid.js'); + + Seq() + .seq(function() { b.bundle(this); }) + .catch(function(lastErr) { + t.deepEqual(b._syntaxCache, {}); + t.similar(String(lastErr), /ParseError/); + b.bundle(function(err, src) { + t.deepEqual(b._syntaxCache, {}); + t.similar(String(err), /ParseError/); + t.notEqual(lastErr, err, 'errors should be unique'); + }); + }); +}); diff --git a/test/syntax_cache/invalid.js b/test/syntax_cache/invalid.js new file mode 100644 index 000000000..e85c07cca --- /dev/null +++ b/test/syntax_cache/invalid.js @@ -0,0 +1,2 @@ +var x = { +var y = 6; diff --git a/test/syntax_cache/valid.js b/test/syntax_cache/valid.js new file mode 100644 index 000000000..cf4f426f5 --- /dev/null +++ b/test/syntax_cache/valid.js @@ -0,0 +1,2 @@ +var x = {}; +var y = 6; From 48550ce7ef5ca7471205b615e209a2d145553e34 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 9 May 2015 00:03:20 -0400 Subject: [PATCH 025/193] Fix globals transform noParse path matcher --- index.js | 12 ++- test/global/node_modules/aaa/index.js | 2 + test/global/node_modules/robot/index.js | 1 + test/global/node_modules/robot/lib/beep.js | 2 + test/global_noparse.js | 101 +++++++++++++++++++++ 5 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 test/global/node_modules/aaa/index.js create mode 100644 test/global/node_modules/robot/index.js create mode 100644 test/global/node_modules/robot/lib/beep.js create mode 100644 test/global_noparse.js diff --git a/index.js b/index.js index 08b05ae1f..3d4374704 100644 --- a/index.js +++ b/index.js @@ -518,15 +518,19 @@ Browserify.prototype._createDeps = function (opts) { }); } + var no = [].concat(opts.noParse).filter(Boolean); + var absno = no.filter(function(x) { + return typeof x === 'string'; + }).map(function (x) { + return path.resolve(basedir, x); + }); + function globalTr (file) { if (opts.detectGlobals === false) return through(); if (opts.noParse === true) return through(); - var no = [].concat(opts.noParse).filter(Boolean); if (no.indexOf(file) >= 0) return through(); - if (no.map(function (x){return path.resolve(x)}).indexOf(file)>=0){ - return through(); - } + if (absno.indexOf(file) >= 0) return through(); var parts = file.split('/node_modules/'); for (var i = 0; i < no.length; i++) { diff --git a/test/global/node_modules/aaa/index.js b/test/global/node_modules/aaa/index.js new file mode 100644 index 000000000..85dc112bf --- /dev/null +++ b/test/global/node_modules/aaa/index.js @@ -0,0 +1,2 @@ +exports.filename = __filename; +exports.dirname = __dirname; diff --git a/test/global/node_modules/robot/index.js b/test/global/node_modules/robot/index.js new file mode 100644 index 000000000..dc8377968 --- /dev/null +++ b/test/global/node_modules/robot/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/beep'); diff --git a/test/global/node_modules/robot/lib/beep.js b/test/global/node_modules/robot/lib/beep.js new file mode 100644 index 000000000..85dc112bf --- /dev/null +++ b/test/global/node_modules/robot/lib/beep.js @@ -0,0 +1,2 @@ +exports.filename = __filename; +exports.dirname = __dirname; diff --git a/test/global_noparse.js b/test/global_noparse.js new file mode 100644 index 000000000..decd772da --- /dev/null +++ b/test/global_noparse.js @@ -0,0 +1,101 @@ +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +test('global noparse module', function (t) { + t.plan(2); + + var b = browserify({ + noParse: 'aaa' + }); + b.require(__dirname + '/global/node_modules/aaa', { expose: 'x' }); + b.bundle(function (err, src) { + var c = { + __filename: __filename, + __dirname: __dirname + }; + vm.runInNewContext(src, c); + var x = c.require('x'); + t.equal(x.filename, __filename); + t.equal(x.dirname, __dirname); + }); +}); + +test('global noparse module file', function (t) { + t.plan(2); + + var b = browserify({ + noParse: 'aaa/index.js' + }); + b.require(__dirname + '/global/node_modules/aaa', { expose: 'x' }); + b.bundle(function (err, src) { + var c = { + __filename: __filename, + __dirname: __dirname + }; + vm.runInNewContext(src, c); + var x = c.require('x'); + t.equal(x.filename, __filename); + t.equal(x.dirname, __dirname); + }); +}); + +test('global noparse module deep file', function (t) { + t.plan(2); + + var b = browserify({ + noParse: 'robot/lib/beep.js' + }); + b.require(__dirname + '/global/node_modules/robot', { expose: 'x' }); + b.bundle(function (err, src) { + var c = { + __filename: __filename, + __dirname: __dirname + }; + vm.runInNewContext(src, c); + var x = c.require('x'); + t.equal(x.filename, __filename); + t.equal(x.dirname, __dirname); + }); +}); + +test('global noparse basedir', function (t) { + t.plan(2); + + var b = browserify({ + basedir: __dirname + '/global', + noParse: 'filename.js' + }); + b.require(__dirname + '/global/filename.js', { expose: 'x' }); + b.bundle(function (err, src) { + var c = { + __filename: __filename, + __dirname: __dirname + }; + vm.runInNewContext(src, c); + var x = c.require('x'); + t.equal(x.filename, __filename); + t.equal(x.dirname, __dirname); + }); +}); + +test('global noparse function', function (t) { + t.plan(2); + + var b = browserify({ + noParse: function(file) { + return file === __dirname + '/global/filename.js'; + } + }); + b.require(__dirname + '/global/filename.js', { expose: 'x' }); + b.bundle(function (err, src) { + var c = { + __filename: __filename, + __dirname: __dirname + }; + vm.runInNewContext(src, c); + var x = c.require('x'); + t.equal(x.filename, __filename); + t.equal(x.dirname, __dirname); + }); +}); From 1d750308405e9bb7c249d86b8000af0921a867e1 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 9 May 2015 00:14:34 -0400 Subject: [PATCH 026/193] Add test for "noParse" --- test/noparse.js | 29 ++++++++++++++++++++ test/noparse/a.js | 4 +++ test/noparse/b.js | 5 ++++ test/noparse/dir1/1.js | 4 +++ test/noparse/dir1/dir2/2.js | 3 ++ test/noparse/node_modules/robot/lib/beep.js | 4 +++ test/noparse/node_modules/robot/lib/boop.js | 3 ++ test/noparse/node_modules/robot/main.js | 4 +++ test/noparse/node_modules/robot/package.json | 3 ++ 9 files changed, 59 insertions(+) create mode 100644 test/noparse.js create mode 100644 test/noparse/a.js create mode 100644 test/noparse/b.js create mode 100644 test/noparse/dir1/1.js create mode 100644 test/noparse/dir1/dir2/2.js create mode 100644 test/noparse/node_modules/robot/lib/beep.js create mode 100644 test/noparse/node_modules/robot/lib/boop.js create mode 100644 test/noparse/node_modules/robot/main.js create mode 100644 test/noparse/node_modules/robot/package.json diff --git a/test/noparse.js b/test/noparse.js new file mode 100644 index 000000000..93376f91a --- /dev/null +++ b/test/noparse.js @@ -0,0 +1,29 @@ +var browserify = require('../'); +var test = require('tap').test; +var path = require('path'); + +test('noParse array', function (t) { + t.plan(2); + + var actual = []; + var expected = [ + 'noparse/a.js', + 'noparse/b.js', + 'noparse/dir1/1.js', + 'noparse/node_modules/robot/main.js' + ].map(function (x) {return path.resolve(x);}).sort(); + + var b = browserify({ + entries: [ __dirname + '/noparse/a.js' ], + noParse: [ + __dirname + '/noparse/dir1/1.js', + __dirname + '/noparse/node_modules/robot/main.js' + ] + }); + b.on('dep', function(dep) { actual.push(dep.file); }); + b.bundle(function (err, src) { + actual.sort(); + t.ifError(err); + t.deepEqual(actual, expected); + }); +}); diff --git a/test/noparse/a.js b/test/noparse/a.js new file mode 100644 index 000000000..076812a66 --- /dev/null +++ b/test/noparse/a.js @@ -0,0 +1,4 @@ +module.exports = { + a: true, + b: require('./b') +}; diff --git a/test/noparse/b.js b/test/noparse/b.js new file mode 100644 index 000000000..de0ba559a --- /dev/null +++ b/test/noparse/b.js @@ -0,0 +1,5 @@ +module.exports = { + b: true, + 1: require('./dir1/1'), + robot: require('robot') +}; diff --git a/test/noparse/dir1/1.js b/test/noparse/dir1/1.js new file mode 100644 index 000000000..960968b0b --- /dev/null +++ b/test/noparse/dir1/1.js @@ -0,0 +1,4 @@ +module.exports = { + 1: true, + 2: require('./dir2/2') +}; diff --git a/test/noparse/dir1/dir2/2.js b/test/noparse/dir1/dir2/2.js new file mode 100644 index 000000000..ef4ba1962 --- /dev/null +++ b/test/noparse/dir1/dir2/2.js @@ -0,0 +1,3 @@ +module.exports = { + 2: true +}; diff --git a/test/noparse/node_modules/robot/lib/beep.js b/test/noparse/node_modules/robot/lib/beep.js new file mode 100644 index 000000000..6529dd85c --- /dev/null +++ b/test/noparse/node_modules/robot/lib/beep.js @@ -0,0 +1,4 @@ +module.exports = { + beep: true, + boop: require('./boop') +}; diff --git a/test/noparse/node_modules/robot/lib/boop.js b/test/noparse/node_modules/robot/lib/boop.js new file mode 100644 index 000000000..696a67245 --- /dev/null +++ b/test/noparse/node_modules/robot/lib/boop.js @@ -0,0 +1,3 @@ +module.exports = { + boop: true +}; diff --git a/test/noparse/node_modules/robot/main.js b/test/noparse/node_modules/robot/main.js new file mode 100644 index 000000000..87af6096a --- /dev/null +++ b/test/noparse/node_modules/robot/main.js @@ -0,0 +1,4 @@ +module.exports = { + robot: true, + beep: require('./lib/beep') +}; diff --git a/test/noparse/node_modules/robot/package.json b/test/noparse/node_modules/robot/package.json new file mode 100644 index 000000000..c13b8cf6a --- /dev/null +++ b/test/noparse/node_modules/robot/package.json @@ -0,0 +1,3 @@ +{ + "main": "main.js" +} From bf21b51eede9892193ec1f5a3ea8f5d2361c2390 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 12 May 2015 00:26:47 -0400 Subject: [PATCH 027/193] Update to browser-pack@^5.0.0 and fix source-map test --- package.json | 2 +- test/debug_standalone.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9d52d6ff0..8deb08fc5 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "JSONStream": "^1.0.3", "assert": "~1.3.0", - "browser-pack": "^4.0.3", + "browser-pack": "^5.0.0", "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", "buffer": "^3.0.0", diff --git a/test/debug_standalone.js b/test/debug_standalone.js index 0d9fcdfcb..23a06cc38 100644 --- a/test/debug_standalone.js +++ b/test/debug_standalone.js @@ -16,7 +16,7 @@ test('ordinary debug', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ .test(last) ); }); @@ -35,7 +35,7 @@ test('debug standalone', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ .test(last) ); }); @@ -54,7 +54,7 @@ test('debug standalone exposed', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ .test(last) ); var c = { window: {} }; From b065829be44a214d2bb9817933aee988ff6d1599 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 14 May 2015 07:22:17 -0400 Subject: [PATCH 028/193] 10.2.0 --- changelog.markdown | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 7d6c58d28..73cb3c666 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,21 @@ +# 10.2.0 + +remove unnecessary "isDedupe" json check. this was a hack-fix for watchify <=2.4. + +https://github.com/substack/node-browserify/pull/1244 + +fixes for the "noParse" path matcher. + +https://github.com/substack/node-browserify/pull/1259 + +add syntax check cache. this speeds up rebuilds (like when using watchify). + +https://github.com/substack/node-browserify/pull/1253 + +update to browser-pack@^5.0.0 - includes several fixes related to source maps. + +https://github.com/substack/node-browserify/pull/1257 + # 10.1.3 Replace jsonstream with JSONStream diff --git a/package.json b/package.json index 8deb08fc5..3ae42ed10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.1.3", + "version": "10.2.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 20d9d4ded7ee40ddcb7c46bb53e6462f7e5465d4 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 19 May 2015 23:19:51 -0400 Subject: [PATCH 029/193] Remove unused functions --- bin/args.js | 7 ------- bin/cmd.js | 8 -------- 2 files changed, 15 deletions(-) diff --git a/bin/args.js b/bin/args.js index fe4d9c384..f1b4c50da 100644 --- a/bin/args.js +++ b/bin/args.js @@ -245,13 +245,6 @@ module.exports = function (args, opts) { return b; }; -function copy (obj) { - return Object.keys(obj).reduce(function (acc, key) { - acc[key] = obj[key]; - return acc; - }, {}); -} - function splitOnColon (f) { var pos = f.lastIndexOf(':'); if (pos == -1) { diff --git a/bin/cmd.js b/bin/cmd.js index 105e0f9c3..5b838bb46 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -63,14 +63,6 @@ else { bundle.pipe(process.stdout); } -function packageFilter (info) { - if (info && typeof info.browserify === 'string' && !info.browser) { - info.browser = info.browserify; - delete info.browserify; - } - return info || {}; -} - function errorExit(err) { if (err.stack) { console.error(err.stack); From ef250a6cc3b0b9a3d5bcd4d85ce418490c814d79 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 19 May 2015 23:21:16 -0400 Subject: [PATCH 030/193] Remove unused require --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 1ebb17492..2217dd434 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ var builtins = require('./lib/builtins.js'); var splicer = require('labeled-stream-splicer'); var through = require('through2'); var concat = require('concat-stream'); -var duplexer = require('duplexer2'); var inherits = require('inherits'); var EventEmitter = require('events').EventEmitter; From 3842880361882f4e9fcf7d31ed7927acff00aedd Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Tue, 19 May 2015 23:23:39 -0400 Subject: [PATCH 031/193] Use xtend instead of shallow-copy xtend already does what we're using shallow-copy for --- index.js | 5 ++--- package.json | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2217dd434..bfe3e095f 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,6 @@ var concat = require('concat-stream'); var inherits = require('inherits'); var EventEmitter = require('events').EventEmitter; var xtend = require('xtend'); -var copy = require('shallow-copy'); var isarray = require('isarray'); var defined = require('defined'); var has = require('has'); @@ -422,7 +421,7 @@ Browserify.prototype._createPipeline = function (opts) { Browserify.prototype._createDeps = function (opts) { var self = this; - var mopts = copy(opts); + var mopts = xtend(opts); var basedir = defined(opts.basedir, process.cwd()); // Let mdeps populate these values since it will be resolving file paths @@ -502,7 +501,7 @@ Browserify.prototype._createDeps = function (opts) { else if (opts.builtins && typeof opts.builtins === 'object') { mopts.modules = opts.builtins; } - else mopts.modules = copy(builtins); + else mopts.modules = xtend(builtins); Object.keys(builtins).forEach(function (key) { if (!has(mopts.modules, key)) self._exclude.push(key); diff --git a/package.json b/package.json index 3ae42ed10..78480272d 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "read-only-stream": "^1.1.1", "readable-stream": "^1.1.13", "resolve": "^1.1.4", - "shallow-copy": "0.0.1", "shasum": "^1.0.0", "shell-quote": "~0.0.1", "stream-browserify": "^1.0.0", From c707805caf9598ba0bc4972f1a40ea5baac6f502 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Wed, 20 May 2015 00:13:12 -0400 Subject: [PATCH 032/193] 10.2.1 --- changelog.markdown | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 73cb3c666..7378bcf82 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 10.2.1 + +housekeeping - removed unused code + +https://github.com/substack/node-browserify/pull/1273 + # 10.2.0 remove unnecessary "isDedupe" json check. this was a hack-fix for watchify <=2.4. diff --git a/package.json b/package.json index 78480272d..7649670e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.0", + "version": "10.2.1", "description": "browser-side require() the node way", "main": "index.js", "bin": { From fe7ae3d69f01a1c900c6a7a2e4a4f942ddc944d7 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Thu, 21 May 2015 22:08:17 -0400 Subject: [PATCH 033/193] Fix tests for tap@^1.1.0 (and update tap) --- package.json | 2 +- test/entry_relative.js | 4 +++- test/ignore_missing.js | 13 +++++++++---- test/noparse.js | 2 ++ test/tr_no_entry.js | 2 ++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7649670e1..bc7892b32 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "es6ify": "~0.4.8", "isstream": "^0.1.2", "seq": "0.3.3", - "tap": "~0.4.0", + "tap": "^1.1.0", "temp": "^0.8.1", "through": "^2.3.4" }, diff --git a/test/entry_relative.js b/test/entry_relative.js index 123532c18..f1ae37f2c 100644 --- a/test/entry_relative.js +++ b/test/entry_relative.js @@ -3,8 +3,10 @@ var vm = require('vm'); var test = require('tap').test; test('entry - relative path', function (t) { + process.chdir(__dirname); + t.plan(3); - + var b = browserify('entry/main.js'); b.on('dep', function(row) { if (row.entry) t.equal(row.file, __dirname + '/entry/main.js'); diff --git a/test/ignore_missing.js b/test/ignore_missing.js index e7410cb28..ddf72ed20 100644 --- a/test/ignore_missing.js +++ b/test/ignore_missing.js @@ -3,6 +3,8 @@ var test = require('tap').test; test('ignoreMissing option', function (t) { t.test('on browserify', function(t) { + t.plan(1); + var ignored = browserify({ entries: [__dirname + '/ignore_missing/main.js'], ignoreMissing: true @@ -10,27 +12,30 @@ test('ignoreMissing option', function (t) { ignored.bundle(function(err) { t.ok(!err, "bundle completed with missing file ignored"); - t.end() }); }); t.test('on .bundle', function(t) { + t.plan(1); + var ignored = browserify(__dirname + '/ignore_missing/main.js', { ignoreMissing: true }); ignored.bundle(function(err) { t.ok(!err, "bundle completed with missing file ignored"); - t.end(); }); }); - test('defaults to false', function (t) { + t.test('defaults to false', function (t) { + t.plan(1); + var expected = browserify(__dirname + '/ignore_missing/main.js'); expected.bundle(function(err) { t.ok(err, 'ignoreMissing was false, an error was raised'); - t.end(); }); }); + + t.end(); }); diff --git a/test/noparse.js b/test/noparse.js index 93376f91a..7d0b3b272 100644 --- a/test/noparse.js +++ b/test/noparse.js @@ -3,6 +3,8 @@ var test = require('tap').test; var path = require('path'); test('noParse array', function (t) { + process.chdir(__dirname); + t.plan(2); var actual = []; diff --git a/test/tr_no_entry.js b/test/tr_no_entry.js index f31be8265..f41d9ceb5 100644 --- a/test/tr_no_entry.js +++ b/test/tr_no_entry.js @@ -3,6 +3,8 @@ var test = require('tap').test; var path = require('path') test('transform with no entry files', function (t) { + process.chdir(__dirname); + t.plan(2); var b = browserify(); b.transform('tr'); From f1fb53eda640118b0b6336a5be2ae11bd6eab4cc Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Mon, 25 May 2015 00:50:40 -0400 Subject: [PATCH 034/193] 10.2.2 --- changelog.markdown | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 7378bcf82..5215470cd 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 10.2.2 + +fix tests for tap@^1.1.0 (and update tap) + +https://github.com/substack/node-browserify/pull/1276 + # 10.2.1 housekeeping - removed unused code diff --git a/package.json b/package.json index bc7892b32..62e67e342 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.1", + "version": "10.2.2", "description": "browser-side require() the node way", "main": "index.js", "bin": { From d67fe654a558964000f616af72348d8feeef2985 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Fri, 29 May 2015 11:38:53 +0200 Subject: [PATCH 035/193] fix missing space in bin/args for browserField --- bin/args.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/args.js b/bin/args.js index f1b4c50da..cd1b6753b 100644 --- a/bin/args.js +++ b/bin/args.js @@ -20,7 +20,7 @@ module.exports = function (args, opts) { alias: { ig: [ 'insert-globals', 'fast' ], dg: [ 'detect-globals', 'detectGlobals', 'dg' ], - bf: [ 'browser-field', 'browserField ' ], + bf: [ 'browser-field', 'browserField' ], im: 'ignore-missing', it: 'ignore-transform', igv: 'insert-global-vars', From 34bf148cbda33d3fdf40a18055ec5ecea680eec1 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Fri, 29 May 2015 11:48:10 +0200 Subject: [PATCH 036/193] 10.2.3 --- changelog.markdown | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 5215470cd..cb3ee95e3 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,10 @@ +# 10.2.3 + +fixes an errant space in the `--no-browser-field` flag alias +that kept it from working + +https://github.com/substack/node-browserify/issues/1286 + # 10.2.2 fix tests for tap@^1.1.0 (and update tap) diff --git a/package.json b/package.json index 62e67e342..887043329 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.2", + "version": "10.2.3", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 785fe1563bb4b52ba02b8a474fb66903cfc08886 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 16 May 2015 16:52:39 -0400 Subject: [PATCH 037/193] Fix multi entry with cross require --- index.js | 11 ++- test/multi_entry.js | 67 +++++++++++++++--- test/multi_entry_cross_require.js | 92 +++++++++++++++++++++++++ test/multi_entry_cross_require/a.js | 8 +++ test/multi_entry_cross_require/c.js | 7 ++ test/multi_entry_cross_require/lib/b.js | 5 ++ 6 files changed, 175 insertions(+), 15 deletions(-) create mode 100644 test/multi_entry_cross_require.js create mode 100644 test/multi_entry_cross_require/a.js create mode 100644 test/multi_entry_cross_require/c.js create mode 100644 test/multi_entry_cross_require/lib/b.js diff --git a/index.js b/index.js index bfe3e095f..b4f4dca2a 100644 --- a/index.js +++ b/index.js @@ -156,16 +156,16 @@ Browserify.prototype.require = function (file, opts) { if (typeof file === 'object') { row = xtend(file, opts); } - else if (isExternalModule(file)) { + else if (!opts.entry && isExternalModule(file)) { // external module or builtin row = xtend(opts, { id: expose || file, file: file }); } else { - row = xtend(opts, { file: file }); + row = xtend(opts, { file: path.resolve(basedir, file) }); } if (!row.id) { - row.id = expose || file; + row.id = expose || row.file; } if (expose || !row.entry) { // Make this available to mdeps so that it can assign the value when it @@ -180,10 +180,7 @@ Browserify.prototype.require = function (file, opts) { self._bpack.hasExports = true; } - if (row.entry) { - row.file = path.resolve(basedir, row.file); - row.order = self._entryOrder ++; - } + if (row.entry) row.order = self._entryOrder ++; if (opts.transform === false) row.transform = false; self.pipeline.write(row); diff --git a/test/multi_entry.js b/test/multi_entry.js index 45df2bc87..f910eddc2 100644 --- a/test/multi_entry.js +++ b/test/multi_entry.js @@ -33,22 +33,73 @@ test('multi entry', function (t) { }); }); -test('entries as streams', function (t) { +test('multi entry relative', function (t) { t.plan(6); - // transform paths to streams - for (var i = 0; i < testFiles.length; i++) { - testFiles[i] = fs.createReadStream(testFiles[i]); - } + var rTestFiles = testFiles.map(function(x) { + return x.replace(__dirname + '/', ''); + }); + + var b = browserify({ + entries: [rTestFiles[0], rTestFiles[1]], + basedir: __dirname + }); + b.add(rTestFiles[2]); + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + + b.bundle(function (err, src) { + var c = { + times : 0, + t : t + }; + vm.runInNewContext(src, c); + }); +}); + +test('multi entry relative cwd', function (t) { + t.plan(6); + + var rTestFiles = testFiles.map(function(x) { + return x.replace(__dirname + '/', './'); + }); + + var b = browserify({ + entries: [rTestFiles[0], rTestFiles[1]], + basedir: __dirname + }); + b.add(rTestFiles[2]); + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + + b.bundle(function (err, src) { + var c = { + times : 0, + t : t + }; + vm.runInNewContext(src, c); + }); +}); + +test('entries as streams', function (t) { + t.plan(6); // commondir blows up with streams and without basedir var opts = { basedir: __dirname + '/multi_entry' }; var b = browserify([ - testFiles[0], - testFiles[1] + fs.createReadStream(testFiles[0]), + fs.createReadStream(testFiles[1]) ], opts); - b.add(testFiles[2]); + b.add(fs.createReadStream(testFiles[2])); b.on('dep', function(row) { if (row.entry) { diff --git a/test/multi_entry_cross_require.js b/test/multi_entry_cross_require.js new file mode 100644 index 000000000..0cc1a8829 --- /dev/null +++ b/test/multi_entry_cross_require.js @@ -0,0 +1,92 @@ +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +var testFiles = [ + __dirname + '/multi_entry_cross_require/a.js', + __dirname + '/multi_entry_cross_require/lib/b.js', + __dirname + '/multi_entry_cross_require/c.js' +]; + +test('multi entry cross require', function (t) { + t.plan(8); + + var b = browserify([ + testFiles[0], + testFiles[1] + ]); + b.add(testFiles[2]); + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + + b.bundle(function (err, src) { + if (err) throw err; + var c = { + times : 0, + t : t + }; + vm.runInNewContext(src, c); + }); +}); + +test('multi entry cross require - relative cwd', function (t) { + t.plan(8); + + var dsTestFiles = testFiles.map(function(x) { + return x.replace(__dirname + '/', './'); + }); + + var b = browserify({ + entries: [dsTestFiles[0], dsTestFiles[1]], + basedir: __dirname + }); + b.add(dsTestFiles[2]); + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + + b.bundle(function (err, src) { + if (err) throw err; + var c = { + times : 0, + t : t + }; + vm.runInNewContext(src, c); + }); +}); + +test('multi entry cross require - relative', function (t) { + t.plan(8); + + var rTestFiles = testFiles.map(function(x) { + return x.replace(__dirname + '/', ''); + }); + + var b = browserify({ + entries: [rTestFiles[0], rTestFiles[1]], + basedir: __dirname + }); + b.add(rTestFiles[2]); + + b.on('dep', function(row) { + if (row.entry) { + t.ok(testFiles.indexOf(row.file) > -1, 'should contain full entry path'); + } + }); + + b.bundle(function (err, src) { + if (err) throw err; + var c = { + times : 0, + t : t + }; + vm.runInNewContext(src, c); + }); +}); diff --git a/test/multi_entry_cross_require/a.js b/test/multi_entry_cross_require/a.js new file mode 100644 index 000000000..0223dafc0 --- /dev/null +++ b/test/multi_entry_cross_require/a.js @@ -0,0 +1,8 @@ +times ++; +t.equal(times, 1); + +var b = require('./lib/b'); +t.equal(times, 2); + +b.foo(); +t.equal(times, 3); diff --git a/test/multi_entry_cross_require/c.js b/test/multi_entry_cross_require/c.js new file mode 100644 index 000000000..e1918384b --- /dev/null +++ b/test/multi_entry_cross_require/c.js @@ -0,0 +1,7 @@ +times++; +t.equal(times, 4); + +var b = require('./lib/b'); +b.foo(); + +t.equal(times, 5); diff --git a/test/multi_entry_cross_require/lib/b.js b/test/multi_entry_cross_require/lib/b.js new file mode 100644 index 000000000..e7d2dad1f --- /dev/null +++ b/test/multi_entry_cross_require/lib/b.js @@ -0,0 +1,5 @@ +times++; + +module.exports.foo = function() { + times++; +}; From d4ef33bf8105438b85ce5c8be336a4905dd33903 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Mon, 25 May 2015 00:53:25 -0400 Subject: [PATCH 038/193] remove unused dep "deep-equal" --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 887043329..5390b3989 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "console-browserify": "^1.1.0", "constants-browserify": "~0.0.1", "crypto-browserify": "^3.0.0", - "deep-equal": "^1.0.0", "defined": "^1.0.0", "deps-sort": "^1.3.7", "domain-browser": "~1.1.0", From 391761e7943633d05a6a0f42eb778c1afc25048c Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Mon, 25 May 2015 01:01:24 -0400 Subject: [PATCH 039/193] remove "lib/_exclude.js" it hasn't been a thing since v5.0.0 --- lib/_exclude.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/_exclude.js diff --git a/lib/_exclude.js b/lib/_exclude.js deleted file mode 100644 index e69de29bb..000000000 From f9c256174fe282f7a8ca619d7168161e8e208524 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 6 Jun 2015 14:53:00 -0400 Subject: [PATCH 040/193] 10.2.4 --- changelog.markdown | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index cb3ee95e3..bed5a4cc0 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,11 @@ +# 10.2.4 + +fixes requiring an entry from another entry + +remove unused dep "deep-equal" and unused file "lib/_exclude.js" + +https://github.com/substack/node-browserify/pull/1268 + # 10.2.3 fixes an errant space in the `--no-browser-field` flag alias diff --git a/package.json b/package.json index 5390b3989..e22d8ad80 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.3", + "version": "10.2.4", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 2e8cf0c87d5f720eaff426e0243e512c3714797b Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Fri, 12 Jun 2015 09:18:10 +1000 Subject: [PATCH 041/193] Update compatibility: events link --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index ce20e5dab..18d0c50a6 100644 --- a/readme.markdown +++ b/readme.markdown @@ -224,7 +224,7 @@ When you `require()` any of these modules, you will get a browser-specific shim: * [constants](https://www.npmjs.com/package/constants-browserify) * [crypto](https://www.npmjs.com/package/crypto-browserify) * [domain](https://www.npmjs.com/package/domain-browser) -* [events](https://www.npmjs.com/package/events-browserify) +* [events](https://www.npmjs.com/package/events) * [http](https://www.npmjs.com/package/http-browserify) * [https](https://www.npmjs.com/package/https-browserify) * [os](https://www.npmjs.com/package/os-browserify) From 504832b4b9fde30c36877122b265ddccbea7be77 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Tue, 30 Jun 2015 14:35:39 -0700 Subject: [PATCH 042/193] handle symlinks --- index.js | 3 ++- test/symlink_dedupe.js | 16 ++++++++++++++++ test/symlink_dedupe/main.js | 6 ++++++ test/symlink_dedupe/one/dir | 1 + test/symlink_dedupe/one/f.js | 3 +++ test/symlink_dedupe/one/g.js | 2 ++ 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/symlink_dedupe.js create mode 100644 test/symlink_dedupe/main.js create mode 120000 test/symlink_dedupe/one/dir create mode 100644 test/symlink_dedupe/one/f.js create mode 100644 test/symlink_dedupe/one/g.js diff --git a/index.js b/index.js index b4f4dca2a..f7f57a42e 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,7 @@ var readonly = require('read-only-stream'); module.exports = Browserify; inherits(Browserify, EventEmitter); +var fs = require('fs'); var path = require('path'); var paths = { empty: path.join(__dirname, 'lib/_empty.js') @@ -481,7 +482,7 @@ Browserify.prototype._createDeps = function (opts) { return cb(null, paths.empty, {}); } } - cb(err, file, pkg); + cb(err, file && fs.realpathSync(file), pkg); }); }; diff --git a/test/symlink_dedupe.js b/test/symlink_dedupe.js new file mode 100644 index 000000000..00d21d15c --- /dev/null +++ b/test/symlink_dedupe.js @@ -0,0 +1,16 @@ +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +test('hash instances with hashed contexts', function (t) { + t.plan(5); + + var b = browserify(__dirname + '/symlink_dedupe/main.js'); + b.bundle(function (err, buf) { + var c = { t: t }; + var src = buf.toString('utf8'); + t.equal(src.match(RegExp('// FILE F ONE', 'g')).length, 1); + t.equal(src.match(RegExp('// FILE G ONE', 'g')).length, 1); + vm.runInNewContext(src, c); + }); +}); diff --git a/test/symlink_dedupe/main.js b/test/symlink_dedupe/main.js new file mode 100644 index 000000000..92ff18df1 --- /dev/null +++ b/test/symlink_dedupe/main.js @@ -0,0 +1,6 @@ +var A = require('./one/f.js'); +var B = require('./one/dir/f.js'); +t.equal(A, B); +t.equal(A(), 555); +t.equal(B(), 555); + diff --git a/test/symlink_dedupe/one/dir b/test/symlink_dedupe/one/dir new file mode 120000 index 000000000..945c9b46d --- /dev/null +++ b/test/symlink_dedupe/one/dir @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/test/symlink_dedupe/one/f.js b/test/symlink_dedupe/one/f.js new file mode 100644 index 000000000..a315c1e7d --- /dev/null +++ b/test/symlink_dedupe/one/f.js @@ -0,0 +1,3 @@ +// FILE F ONE +var G = require('./g.js'); +module.exports = function () { return 111 * G }; diff --git a/test/symlink_dedupe/one/g.js b/test/symlink_dedupe/one/g.js new file mode 100644 index 000000000..837303206 --- /dev/null +++ b/test/symlink_dedupe/one/g.js @@ -0,0 +1,2 @@ +// FILE G ONE +module.exports = 5 From 2947e82400f3bcc6601218c3a6952a215e9e6bf1 Mon Sep 17 00:00:00 2001 From: John McLaughlin Date: Wed, 1 Jul 2015 15:15:46 -0700 Subject: [PATCH 043/193] Update readme.markdown Change to non deprecated link. --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index ce20e5dab..18d0c50a6 100644 --- a/readme.markdown +++ b/readme.markdown @@ -224,7 +224,7 @@ When you `require()` any of these modules, you will get a browser-specific shim: * [constants](https://www.npmjs.com/package/constants-browserify) * [crypto](https://www.npmjs.com/package/crypto-browserify) * [domain](https://www.npmjs.com/package/domain-browser) -* [events](https://www.npmjs.com/package/events-browserify) +* [events](https://www.npmjs.com/package/events) * [http](https://www.npmjs.com/package/http-browserify) * [https](https://www.npmjs.com/package/https-browserify) * [os](https://www.npmjs.com/package/os-browserify) From 46e8446a6cc323286b8983e00e97b7db9be58809 Mon Sep 17 00:00:00 2001 From: Edwin Lin Date: Thu, 9 Jul 2015 14:30:49 -0700 Subject: [PATCH 044/193] Update copyright year from 2008-2014 to 2008-2015 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c9016780d..dc49ca978 100644 --- a/LICENSE +++ b/LICENSE @@ -29,7 +29,7 @@ buffer_ieee754.js has this license in it: ---- -Copyright (c) 2008-2014, Fair Oaks Labs, Inc. +Copyright (c) 2008-2015, Fair Oaks Labs, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without From c4ca4172a2126b7b6118a32383493d48e34cb6a6 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 9 Jul 2015 15:33:25 -0700 Subject: [PATCH 045/193] failing multi-symlink test --- test/multi_symlink.js | 13 +++++++++++++ test/multi_symlink/main.js | 2 ++ test/multi_symlink/x.js | 1 + test/multi_symlink/y.js | 1 + 4 files changed, 17 insertions(+) create mode 100644 test/multi_symlink.js create mode 100644 test/multi_symlink/main.js create mode 100644 test/multi_symlink/x.js create mode 120000 test/multi_symlink/y.js diff --git a/test/multi_symlink.js b/test/multi_symlink.js new file mode 100644 index 000000000..913c7a3be --- /dev/null +++ b/test/multi_symlink.js @@ -0,0 +1,13 @@ +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +test('multiple symlink execution', function (t) { + t.plan(1); + var b = browserify(__dirname + '/multi_symlink/main.js'); + b.bundle(function (err, src) { + var c = { console: { log: log } }; + vm.runInNewContext(src, c); + function log (msg) { t.equal(msg, 'X') } + }); +}); diff --git a/test/multi_symlink/main.js b/test/multi_symlink/main.js new file mode 100644 index 000000000..0f904dc91 --- /dev/null +++ b/test/multi_symlink/main.js @@ -0,0 +1,2 @@ +require('./x.js'); +require('./y.js'); diff --git a/test/multi_symlink/x.js b/test/multi_symlink/x.js new file mode 100644 index 000000000..e894542cb --- /dev/null +++ b/test/multi_symlink/x.js @@ -0,0 +1 @@ +console.log('X'); diff --git a/test/multi_symlink/y.js b/test/multi_symlink/y.js new file mode 120000 index 000000000..ca52ee1f4 --- /dev/null +++ b/test/multi_symlink/y.js @@ -0,0 +1 @@ +./x.js \ No newline at end of file From f66966a4ff9f5d646271a9d0affe9b64c65260b7 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 9 Jul 2015 15:56:28 -0700 Subject: [PATCH 046/193] passing tr_symlink test --- test/tr_symlink.js | 21 ++++++++++++++++++++ test/tr_symlink/a-module/index.js | 1 + test/tr_symlink/app/main.js | 4 ++++ test/tr_symlink/app/node_modules/aaa | 1 + test/tr_symlink/app/node_modules/tr/index.js | 14 +++++++++++++ test/tr_symlink/app/package.json | 5 +++++ 6 files changed, 46 insertions(+) create mode 100644 test/tr_symlink.js create mode 100644 test/tr_symlink/a-module/index.js create mode 100644 test/tr_symlink/app/main.js create mode 120000 test/tr_symlink/app/node_modules/aaa create mode 100644 test/tr_symlink/app/node_modules/tr/index.js create mode 100644 test/tr_symlink/app/package.json diff --git a/test/tr_symlink.js b/test/tr_symlink.js new file mode 100644 index 000000000..c02d9c444 --- /dev/null +++ b/test/tr_symlink.js @@ -0,0 +1,21 @@ +// based on this scenario: +// https://github.com/substack/node-browserify/pull/831#issuecomment-49546902 + +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; +var through = require('through2'); + +test('transform symlink', function (t) { + t.plan(3); + var expected = [ 9, 555 ]; + var b = browserify(__dirname + '/tr_symlink/app/main.js', { + basedir: __dirname + '/tr_symlink/app' + }); + b.bundle(function (err, src) { + t.ifError(err); + var c = { console: { log: log } }; + vm.runInNewContext(src, c); + function log (msg) { t.equal(msg, expected.shift()) } + }); +}); diff --git a/test/tr_symlink/a-module/index.js b/test/tr_symlink/a-module/index.js new file mode 100644 index 000000000..3e842e734 --- /dev/null +++ b/test/tr_symlink/a-module/index.js @@ -0,0 +1 @@ +module.exports = 555 diff --git a/test/tr_symlink/app/main.js b/test/tr_symlink/app/main.js new file mode 100644 index 000000000..196452e5e --- /dev/null +++ b/test/tr_symlink/app/main.js @@ -0,0 +1,4 @@ +var a = require('aaa'); + +console.log(5); +console.log(a); diff --git a/test/tr_symlink/app/node_modules/aaa b/test/tr_symlink/app/node_modules/aaa new file mode 120000 index 000000000..fcd5624d4 --- /dev/null +++ b/test/tr_symlink/app/node_modules/aaa @@ -0,0 +1 @@ +../../a-module \ No newline at end of file diff --git a/test/tr_symlink/app/node_modules/tr/index.js b/test/tr_symlink/app/node_modules/tr/index.js new file mode 100644 index 000000000..f9d056885 --- /dev/null +++ b/test/tr_symlink/app/node_modules/tr/index.js @@ -0,0 +1,14 @@ +var through = require('through2'); + +module.exports = function () { + var bufs = []; + return through(write, end); + function write (buf, enc, next) { + bufs.push(buf); + next(); + } + function end () { + this.push(Buffer.concat(bufs).toString().replace(/5/g, 9)); + this.push(null); + } +}; diff --git a/test/tr_symlink/app/package.json b/test/tr_symlink/app/package.json new file mode 100644 index 000000000..2f2bbfff8 --- /dev/null +++ b/test/tr_symlink/app/package.json @@ -0,0 +1,5 @@ +{ + "browserify": { + "transform": [ "tr" ] + } +} From d22ca78c87cd4a00d330a3688d64cd47ed7b6788 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 9 Jul 2015 16:07:47 -0700 Subject: [PATCH 047/193] 10.2.5 --- changelog.markdown | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index bed5a4cc0..1d0304138 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,10 @@ +# 10.2.5 + +fixes an issue with symlinked files executing multiple times + +https://github.com/substack/node-browserify/issues/1063 +https://github.com/substack/node-browserify/pull/1318 + # 10.2.4 fixes requiring an entry from another entry diff --git a/package.json b/package.json index e22d8ad80..fd9ee1869 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.4", + "version": "10.2.5", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 1455a8db91cca66e65b67a628cc3a5e8a37c725f Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 9 Jul 2015 16:12:58 -0700 Subject: [PATCH 048/193] use the non-sync verion of fs.realpath --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f7f57a42e..b3152ad30 100644 --- a/index.js +++ b/index.js @@ -482,7 +482,11 @@ Browserify.prototype._createDeps = function (opts) { return cb(null, paths.empty, {}); } } - cb(err, file && fs.realpathSync(file), pkg); + if (err) cb(err, file, pkg) + else if (file) fs.realpath(file, function (err, res) { + cb(err, res, pkg); + }); + else cb(err, null, pkg) }); }; From 2462712ef368ffd1acbd5914aac7a128ea55defc Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 9 Jul 2015 16:13:53 -0700 Subject: [PATCH 049/193] 10.2.6 --- changelog.markdown | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 1d0304138..544989dce 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,7 @@ +# 10.2.6 + +uses the non-sync version of fs.realpath + # 10.2.5 fixes an issue with symlinked files executing multiple times diff --git a/package.json b/package.json index fd9ee1869..f4e29b9b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.5", + "version": "10.2.6", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 0c5116026ef7766ed4b733729221319041af846a Mon Sep 17 00:00:00 2001 From: James Halliday Date: Fri, 10 Jul 2015 17:21:08 -0700 Subject: [PATCH 050/193] copy what node does to handle shared symlink behavior --- test/shared_symlink.js | 16 ++++++++++++++++ test/shared_symlink/app/index.js | 1 + test/shared_symlink/main.js | 1 + test/shared_symlink/shared/index.js | 1 + 4 files changed, 19 insertions(+) create mode 100644 test/shared_symlink.js create mode 100644 test/shared_symlink/app/index.js create mode 100644 test/shared_symlink/main.js create mode 100644 test/shared_symlink/shared/index.js diff --git a/test/shared_symlink.js b/test/shared_symlink.js new file mode 100644 index 000000000..d5287c139 --- /dev/null +++ b/test/shared_symlink.js @@ -0,0 +1,16 @@ +// https://github.com/substack/node-browserify/issues/1325 + +var browserify = require('../'); +var vm = require('vm'); +var test = require('tap').test; + +test('shared symlink', function (t) { + t.plan(1); + var b = browserify(__dirname + '/shared_symlink/main.js'); + b.bundle(function (err, src) { + // does the same thing as node: crashes + t.equal(err.message, "Cannot find module 'foo' from '" + + __dirname + "/shared_symlink/shared'" + ); + }); +}); diff --git a/test/shared_symlink/app/index.js b/test/shared_symlink/app/index.js new file mode 100644 index 000000000..489c017f6 --- /dev/null +++ b/test/shared_symlink/app/index.js @@ -0,0 +1 @@ +module.exports = require('shared') + require('foo') diff --git a/test/shared_symlink/main.js b/test/shared_symlink/main.js new file mode 100644 index 000000000..a13f52481 --- /dev/null +++ b/test/shared_symlink/main.js @@ -0,0 +1 @@ +console.log(require('./app')) diff --git a/test/shared_symlink/shared/index.js b/test/shared_symlink/shared/index.js new file mode 100644 index 000000000..176676407 --- /dev/null +++ b/test/shared_symlink/shared/index.js @@ -0,0 +1 @@ +module.exports = require('foo') * 2 From 039ce8097a376ab348e91320dea3317e244969a5 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Fri, 10 Jul 2015 23:06:23 -0700 Subject: [PATCH 051/193] check in extra node_modules directory hiding in shared_symlink test --- test/shared_symlink/app/node_modules/foo/index.js | 1 + test/shared_symlink/app/node_modules/shared | 1 + 2 files changed, 2 insertions(+) create mode 100644 test/shared_symlink/app/node_modules/foo/index.js create mode 120000 test/shared_symlink/app/node_modules/shared diff --git a/test/shared_symlink/app/node_modules/foo/index.js b/test/shared_symlink/app/node_modules/foo/index.js new file mode 100644 index 000000000..7afe02674 --- /dev/null +++ b/test/shared_symlink/app/node_modules/foo/index.js @@ -0,0 +1 @@ +module.exports = 1234 diff --git a/test/shared_symlink/app/node_modules/shared b/test/shared_symlink/app/node_modules/shared new file mode 120000 index 000000000..0ab0cb2b3 --- /dev/null +++ b/test/shared_symlink/app/node_modules/shared @@ -0,0 +1 @@ +../../shared \ No newline at end of file From 918d62e804e0e735708e24fe53a78bca0400b7e5 Mon Sep 17 00:00:00 2001 From: John Hiesey Date: Sun, 12 Jul 2015 15:43:19 -0700 Subject: [PATCH 052/193] Replace http-browserify with stream-http stream-http uses new-style streams to provide true streaming or pseudo-streaming in as many browsers as possible. It uses the new fetch api with native browser streams where available (currently only chrome supports this combination) and various browser-specific xhr extensions to make binary-safe streaming work where possible. It is tested and working with at least basic functionality back to IE8. --- lib/builtins.js | 2 +- package.json | 2 +- readme.markdown | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/builtins.js b/lib/builtins.js index 743265150..26c8904ec 100644 --- a/lib/builtins.js +++ b/lib/builtins.js @@ -10,7 +10,7 @@ exports.dns = require.resolve('./_empty.js'); exports.domain = require.resolve('domain-browser'); exports.events = require.resolve('events/'); exports.fs = require.resolve('./_empty.js'); -exports.http = require.resolve('http-browserify'); +exports.http = require.resolve('stream-http'); exports.https = require.resolve('https-browserify'); exports.module = require.resolve('./_empty.js'); exports.net = require.resolve('./_empty.js'); diff --git a/package.json b/package.json index f4e29b9b2..adf906b73 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "glob": "^4.0.5", "has": "^1.0.0", "htmlescape": "^1.1.0", - "http-browserify": "^1.4.0", + "stream-http": "^1.2.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", "insert-module-globals": "^6.4.1", diff --git a/readme.markdown b/readme.markdown index 18d0c50a6..24e66fb1e 100644 --- a/readme.markdown +++ b/readme.markdown @@ -225,7 +225,7 @@ When you `require()` any of these modules, you will get a browser-specific shim: * [crypto](https://www.npmjs.com/package/crypto-browserify) * [domain](https://www.npmjs.com/package/domain-browser) * [events](https://www.npmjs.com/package/events) -* [http](https://www.npmjs.com/package/http-browserify) +* [http](https://www.npmjs.com/package/stream-http) * [https](https://www.npmjs.com/package/https-browserify) * [os](https://www.npmjs.com/package/os-browserify) * [path](https://www.npmjs.com/package/path-browserify) From d1b77a5f796bd34b2cc26a165a19549721324702 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 17 Jul 2015 00:13:01 -0700 Subject: [PATCH 053/193] use the latest streams3 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f4e29b9b2..7fd761c87 100644 --- a/package.json +++ b/package.json @@ -54,11 +54,11 @@ "punycode": "^1.3.2", "querystring-es3": "~0.2.0", "read-only-stream": "^1.1.1", - "readable-stream": "^1.1.13", + "readable-stream": "^2.0.2", "resolve": "^1.1.4", "shasum": "^1.0.0", "shell-quote": "~0.0.1", - "stream-browserify": "^1.0.0", + "stream-browserify": "^2.0.0", "string_decoder": "~0.10.0", "subarg": "^1.0.0", "syntax-error": "^1.1.1", From 59cee8675f3e34fae792e83e25db16428e6f7a4f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 17 Jul 2015 01:20:56 -0700 Subject: [PATCH 054/193] 11.0.0 --- changelog.markdown | 34 ++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 544989dce..ff3ae0daa 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,37 @@ +# 11.0.0 + +## streams3 + +The [`readable-stream`](https://npmjs.com/package/readable-stream) dependency was updated to `^2.0.0`. This package is inserted into bundles as `require('stream')`. Bundles will now get the latest streams implementation from io.js/node.js core, instead of an old version from node.js 0.11.x. Go forth and stream ALL THE DATA without fear! + +## shiny new HTTP package + +[John Hiesey](https://github.com/jhiesey) rewrote the [http-browserify](https://npmjs.org/package/http-browserify) package +to create [stream-http](https://npmjs.org/package/stream-http), an implemention of `http` that supports streaming in modern browsers. Before v11.0.0, in most situations when you used `http.get` or `http.request`, the entire request would buffer in memory until the download was complete, and a single `'data'` event was emitted with the entire response as a string. + +`stream-http` uses the [Fetch API](https://fetch.spec.whatwg.org/) and various browser-specific XHR extensions to make binary streaming http requests work in as many browsers as possible. + +The following browsers support true streaming, where only a small amount of the request has to be held in memory at once: + +* Chrome >= 43 (using the `fetch` api) +* Firefox >= 9 (using `moz-chunked-arraybuffer` responseType with XHR) + +The following browsers support pseudo-streaming, where the data is available before the request finishes, but the entire response must be held in memory: + +* Safari >= 5 +* IE >= 10 +* Most other Webkit-based browsers, including the default Android browser + +Older browsers will work, without streaming support. There is no support for IE6 or IE7. + +Compared to `http-browserify`, it is not necessary to set `options.responseType`. The `responseType` property of the XHR object will be set automatically depending on what features are detected in the browser (although see `options.mode` in the [readme](https://github.com/jhiesey/stream-http) to see how you can optimize this choice manually). + +The `response` is a streams3 stream, so all data is passed as `Buffer`s, unlike the variable types provided by the `'data'` event in `http-browserify`. This behavior tries to mimic the node core `http` module as closely as possible. + +* [#1327](https://github.com/substack/node-browserify/pull/1327) + +If you're brave, go ahead and give v11.0.0 a try today! + # 10.2.6 uses the non-sync version of fs.realpath diff --git a/package.json b/package.json index 5ca081c5c..8c9c7dc17 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "10.2.6", + "version": "11.0.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 9d61b356b94a8faeee0b7a617695bd4fce3c17f3 Mon Sep 17 00:00:00 2001 From: Chriest Yu Date: Sun, 26 Jul 2015 16:52:10 +0800 Subject: [PATCH 055/193] update a wrong info in readme.markdown --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index a36289f16..2f9b6e907 100644 --- a/readme.markdown +++ b/readme.markdown @@ -631,7 +631,7 @@ pipeline with these labels: * `'pack'` - [browser-pack](https://www.npmjs.com/package/browser-pack) * `'wrap'` - apply final wrapping, `require=` and a newline and semicolon -You can call `b.get()` with a label name to get a handle on a stream pipeline +You can call `b.pipeline.get()` with a label name to get a handle on a stream pipeline that you can `push()`, `unshift()`, or `splice()` to insert your own transform streams. From 90a429d6c22eefa61f73840ca212e7784666660a Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 29 Jul 2015 12:12:25 -0700 Subject: [PATCH 056/193] pipe bundle from output instead of pipeline to ensure that the bundle stream ends --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b3152ad30..70466fb94 100644 --- a/index.js +++ b/index.js @@ -770,7 +770,7 @@ Browserify.prototype.bundle = function (cb) { var output = readonly(this.pipeline); if (cb) { output.on('error', cb); - this.pipeline.pipe(concat(function (body) { + output.pipe(concat(function (body) { cb(null, body); })); } From 34e46a97706f35221dd5654e4240d20c608c1778 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 29 Jul 2015 12:14:33 -0700 Subject: [PATCH 057/193] 11.0.1 --- changelog.markdown | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index ff3ae0daa..6ae614ff4 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,10 @@ +# 11.0.1 + +The callback form of bundle() uses the returned output stream instead of the +pipeline so that the `'end'` event will fire on the bundle instance. + +https://github.com/substack/watchify/pull/249#issuecomment-126061169 + # 11.0.0 ## streams3 diff --git a/package.json b/package.json index 8c9c7dc17..3aa0a149b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "11.0.0", + "version": "11.0.1", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 7487bff8f4ae8fc150778b10a91dc4c78233f801 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 22 Aug 2015 18:23:37 -0400 Subject: [PATCH 058/193] Fix "--bare" and "--igv" "insert-module-globals" will merge any vars passed in with the default ones. To exclude any default var, it must be passed in with a value of "undefined". Fixes #1298 --- bin/args.js | 21 +++++++++++---------- test/bare.js | 31 +++++++++++++++++++++++++++++++ test/bare/main.js | 7 +++++++ 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 test/bare/main.js diff --git a/bin/args.js b/bin/args.js index cd1b6753b..35fbeabf8 100644 --- a/bin/args.js +++ b/bin/args.js @@ -71,12 +71,21 @@ module.exports = function (args, opts) { if (argv.bare) { argv.builtins = false; argv.commondir = false; - argv.detectGlobals = false; if (argv.igv === undefined) { argv.igv = '__filename,__dirname'; } } - + + if (argv.igv) { + var insertGlobalVars = {}; + var wantedGlobalVars = argv.igv.split(','); + Object.keys(insertGlobals.vars).forEach(function (x) { + if (wantedGlobalVars.indexOf(x) === -1) { + insertGlobalVars[x] = undefined; + } + }); + } + var ignoreTransform = argv['ignore-transform'] || argv.it; var b = browserify(xtend({ noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse], @@ -234,14 +243,6 @@ module.exports = function (args, opts) { return b; } - var insertGlobalVars; - if (argv.igv) { - insertGlobalVars = argv.igv.split(',').reduce(function (vars, x) { - vars[x] = insertGlobals.vars[x]; - return vars; - }, {}); - } - return b; }; diff --git a/test/bare.js b/test/bare.js index 2ef1031ba..7503180c6 100644 --- a/test/bare.js +++ b/test/bare.js @@ -37,3 +37,34 @@ test('bare', function (t) { t.equal(code, 0); }); }); + +test('bare inserts __filename,__dirname but not process,global,Buffer', function (t) { + t.plan(2); + + var ps = spawn(process.execPath, [ + path.resolve(__dirname, '../bin/cmd.js'), + path.resolve(__dirname, 'bare/main.js'), + '--bare' + ]); + + ps.stdout.pipe(concat(function (body) { + vm.runInNewContext(body, { + console: { + log: function (msg) { + t.same(msg, [ + path.join(__dirname, 'bare'), + path.join(__dirname, 'bare/main.js'), + 'undefined', + 'undefined', + 'undefined' + ]); + } + } + }); + })); + ps.stdin.end(); + + ps.on('exit', function (code) { + t.equal(code, 0); + }); +}); diff --git a/test/bare/main.js b/test/bare/main.js new file mode 100644 index 000000000..e79174303 --- /dev/null +++ b/test/bare/main.js @@ -0,0 +1,7 @@ +console.log([ + __dirname, + __filename, + typeof process, + typeof global, + typeof Buffer +]); From cf32d77b28a3a1c429063740842c5d35a6651de0 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 22 Aug 2015 18:30:03 -0400 Subject: [PATCH 059/193] Exclude "process" and "buffer" when "bundleExternal === false" --- index.js | 4 ++-- test/bundle_external_global.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 70466fb94..232087917 100644 --- a/index.js +++ b/index.js @@ -552,8 +552,8 @@ Browserify.prototype._createDeps = function (opts) { }, opts.insertGlobalVars); if (opts.bundleExternal === false) { - delete vars.process; - delete vars.buffer; + vars.process = undefined; + vars.buffer = undefined; } return insertGlobals(file, xtend(opts, { diff --git a/test/bundle_external_global.js b/test/bundle_external_global.js index 47a9c943d..ae02b8105 100644 --- a/test/bundle_external_global.js +++ b/test/bundle_external_global.js @@ -18,7 +18,7 @@ test('bundle external global', function (t) { process: process }); function log (msg) { - t.equal(typeof msg.nextTick, 'function'); + t.equal(msg, process); } }); }); From 1b73d9b0a24c0c0352a1721e03a82bdcacf4dcd7 Mon Sep 17 00:00:00 2001 From: Mike Nichols Date: Mon, 24 Aug 2015 10:25:47 -0600 Subject: [PATCH 060/193] bump buffer to 3.4.3 to fix maximum call stack exceeded errors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3aa0a149b..b9b180b41 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "browser-pack": "^5.0.0", "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", - "buffer": "^3.0.0", + "buffer": "^3.4.3", "builtins": "~0.0.3", "commondir": "0.0.1", "concat-stream": "~1.4.1", From 97a122e9c885158733e0fa2f4eecf5d238202381 Mon Sep 17 00:00:00 2001 From: mdemo Date: Wed, 9 Sep 2015 09:59:15 +0800 Subject: [PATCH 061/193] Update travis Node.js version & remove io.js --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 74c57bf15..caf8524af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ node_js: - "0.8" - "0.10" - "0.12" - - "iojs" + - "4.0.0" before_install: - npm install -g npm@~1.4.6 From c1c6b724ef78b2ea775e43a54625f0f6c1f572e5 Mon Sep 17 00:00:00 2001 From: faiq Date: Thu, 10 Sep 2015 18:55:06 -0500 Subject: [PATCH 062/193] browserify adds the '.' in case you forget it --- bin/args.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/args.js b/bin/args.js index cd1b6753b..1d9b345e8 100644 --- a/bin/args.js +++ b/bin/args.js @@ -80,7 +80,13 @@ module.exports = function (args, opts) { var ignoreTransform = argv['ignore-transform'] || argv.it; var b = browserify(xtend({ noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse], - extensions: [].concat(argv.extension).filter(Boolean), + extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) { + if (extension.charAt(0) != '.') { + return '.' + extension; + } else { + return extension + } + }), ignoreTransform: [].concat(ignoreTransform).filter(Boolean), entries: entries, fullPaths: argv['full-paths'], From 85e4b9daa7a0659b5ad1eecab4eb10193f04ccf9 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 10 Sep 2015 19:16:30 -0700 Subject: [PATCH 063/193] 11.1.0 --- changelog.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog.markdown b/changelog.markdown index 6ae614ff4..41f7aff45 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 11.1.0 + +adds a `'.'` to extensions if it wasn't added + +https://github.com/substack/node-browserify/pull/1380 + # 11.0.1 The callback form of bundle() uses the returned output stream instead of the From 05d786175e13b873c49afc40170a0428eb56354c Mon Sep 17 00:00:00 2001 From: James Halliday Date: Thu, 10 Sep 2015 20:06:23 -0700 Subject: [PATCH 064/193] update package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3aa0a149b..285030979 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "11.0.1", + "version": "11.1.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From b7cf5bef990a6823d14e2d437e15112aa6b3adfa Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Wed, 23 Sep 2015 21:01:16 -0700 Subject: [PATCH 065/193] 11.2.0 --- changelog.markdown | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index 41f7aff45..d39b61271 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,9 @@ +# 11.2.0 + +When `bundleExternal` is set to `false`, `process` and `buffer` are now correctly excluded. Also, using `--igv` via the CLI now works. That also means that `--bare` and `--node` actually insert `__filename` and `__dirname`. + +https://github.com/substack/node-browserify/pull/1361 + # 11.1.0 adds a `'.'` to extensions if it wasn't added diff --git a/package.json b/package.json index 285030979..7d361acdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "11.1.0", + "version": "11.2.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From a2120167e83c787b0096492d7d6b547a202514dc Mon Sep 17 00:00:00 2001 From: Emil Bay Date: Sun, 27 Sep 2015 01:23:58 +0200 Subject: [PATCH 066/193] Links to the wrong querystring module Previously linked to `querystring` while it actually depends on `querystring-es3` --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index 2f9b6e907..6df5d02cc 100644 --- a/readme.markdown +++ b/readme.markdown @@ -230,7 +230,7 @@ When you `require()` any of these modules, you will get a browser-specific shim: * [os](https://www.npmjs.com/package/os-browserify) * [path](https://www.npmjs.com/package/path-browserify) * [punycode](https://www.npmjs.com/package/punycode) -* [querystring](https://www.npmjs.com/package/querystring) +* [querystring](https://www.npmjs.com/package/querystring-es3) * [stream](https://www.npmjs.com/package/stream-browserify) * [string_decoder](https://www.npmjs.com/package/string_decoder) * [timers](https://www.npmjs.com/package/timers-browserify) From d847221d79b1f047a324936efb703f561911bf4a Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Tue, 29 Sep 2015 09:41:01 +1000 Subject: [PATCH 067/193] travis: test on node4 not "4.0.0" --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index caf8524af..d540a03be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ node_js: - "0.8" - "0.10" - "0.12" - - "4.0.0" + - "4" before_install: - npm install -g npm@~1.4.6 From 76b60a93c9c5f641bf02ab472593dea7d336bc2e Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:31:24 -0700 Subject: [PATCH 068/193] remove node 0.8 from travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d540a03be..c56c5bce4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: node_js node_js: - - "0.8" - "0.10" - "0.12" - "4" -before_install: - - npm install -g npm@~1.4.6 From 46aba9f28b770c093309d0c163d97bc69cfb3ddc Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:31:37 -0700 Subject: [PATCH 069/193] use latest node in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c56c5bce4..4eaf0db4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: node_js node_js: - "0.10" - "0.12" - - "4" + - node From dca78a6d96e246ec636385025a0985e209b0b405 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:33:26 -0700 Subject: [PATCH 070/193] update browser-pack & fix charset bug (also uses streams3) --- package.json | 2 +- test/debug_standalone.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d4f2b2510..da480a6df 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "JSONStream": "^1.0.3", "assert": "~1.3.0", - "browser-pack": "^5.0.0", + "browser-pack": "^6.0.1", "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", "buffer": "^3.4.3", diff --git a/test/debug_standalone.js b/test/debug_standalone.js index 23a06cc38..207090c3a 100644 --- a/test/debug_standalone.js +++ b/test/debug_standalone.js @@ -16,7 +16,7 @@ test('ordinary debug', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,[\w+\/=]+$/ .test(last) ); }); @@ -35,7 +35,7 @@ test('debug standalone', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,[\w+\/=]+$/ .test(last) ); }); @@ -54,7 +54,7 @@ test('debug standalone exposed', function (t) { var src = buf.toString('utf8'); var last = src.split('\n').slice(-2)[0]; t.ok( - /\/\/# sourceMappingURL=data:application\/json;charset:utf-8;base64,[\w+\/=]+$/ + /\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,[\w+\/=]+$/ .test(last) ); var c = { window: {} }; From df439330702664699361268afc7b00a7b566d479 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:34:08 -0700 Subject: [PATCH 071/193] remove unused deps --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index da480a6df..e66f53dab 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,6 @@ "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", "buffer": "^3.4.3", - "builtins": "~0.0.3", - "commondir": "0.0.1", "concat-stream": "~1.4.1", "console-browserify": "^1.1.0", "constants-browserify": "~0.0.1", From e3fbe7d3da2238dac2eda451b1f06630ba8c7a99 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:38:39 -0700 Subject: [PATCH 072/193] update module-deps & fix symlink bug (also uses streams3) see https://github.com/substack/module-deps/pull/99 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e66f53dab..700955f61 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "insert-module-globals": "^6.4.1", "isarray": "0.0.1", "labeled-stream-splicer": "^1.0.0", - "module-deps": "^3.7.11", + "module-deps": "^4.0.2", "os-browserify": "~0.1.1", "parents": "^1.0.1", "path-browserify": "~0.0.0", From da949a18d878eca4baf2c765d2f3810a29065a4b Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:40:25 -0700 Subject: [PATCH 073/193] update deps for streams3 --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 700955f61..61d998be2 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,14 @@ "browser-resolve": "^1.7.1", "browserify-zlib": "~0.1.2", "buffer": "^3.4.3", - "concat-stream": "~1.4.1", + "concat-stream": "~1.5.1", "console-browserify": "^1.1.0", "constants-browserify": "~0.0.1", "crypto-browserify": "^3.0.0", "defined": "^1.0.0", - "deps-sort": "^1.3.7", + "deps-sort": "^2.0.0", "domain-browser": "~1.1.0", - "duplexer2": "~0.0.2", + "duplexer2": "~0.1.2", "events": "~1.0.0", "glob": "^4.0.5", "has": "^1.0.0", @@ -41,9 +41,9 @@ "stream-http": "^1.2.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", - "insert-module-globals": "^6.4.1", + "insert-module-globals": "^7.0.0", "isarray": "0.0.1", - "labeled-stream-splicer": "^1.0.0", + "labeled-stream-splicer": "^2.0.0", "module-deps": "^4.0.2", "os-browserify": "~0.1.1", "parents": "^1.0.1", @@ -51,7 +51,7 @@ "process": "~0.11.0", "punycode": "^1.3.2", "querystring-es3": "~0.2.0", - "read-only-stream": "^1.1.1", + "read-only-stream": "^2.0.0", "readable-stream": "^2.0.2", "resolve": "^1.1.4", "shasum": "^1.0.0", @@ -60,7 +60,7 @@ "string_decoder": "~0.10.0", "subarg": "^1.0.0", "syntax-error": "^1.1.1", - "through2": "^1.0.0", + "through2": "^2.0.0", "timers-browserify": "^1.0.1", "tty-browserify": "~0.0.0", "url": "~0.10.1", From c35f73ef9fd9197eb8b1ca60961dacd37a1a78e3 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:45:27 -0700 Subject: [PATCH 074/193] update builtins deps These mostly include updates for newer versions of node. stream-http dropped IE8 support - needs shims to work (see #1384). --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 61d998be2..16071f723 100644 --- a/package.json +++ b/package.json @@ -28,17 +28,17 @@ "buffer": "^3.4.3", "concat-stream": "~1.5.1", "console-browserify": "^1.1.0", - "constants-browserify": "~0.0.1", + "constants-browserify": "~1.0.0", "crypto-browserify": "^3.0.0", "defined": "^1.0.0", "deps-sort": "^2.0.0", "domain-browser": "~1.1.0", "duplexer2": "~0.1.2", - "events": "~1.0.0", + "events": "~1.1.0", "glob": "^4.0.5", "has": "^1.0.0", "htmlescape": "^1.1.0", - "stream-http": "^1.2.0", + "stream-http": "^2.0.0", "https-browserify": "~0.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", @@ -63,7 +63,7 @@ "through2": "^2.0.0", "timers-browserify": "^1.0.1", "tty-browserify": "~0.0.0", - "url": "~0.10.1", + "url": "~0.11.0", "util": "~0.10.1", "vm-browserify": "~0.0.1", "xtend": "^4.0.0" From c77bf33e67781096368b7e2516d052cf69d2d2cf Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:46:31 -0700 Subject: [PATCH 075/193] update glob and shell-quote --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 16071f723..fb3167a28 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "domain-browser": "~1.1.0", "duplexer2": "~0.1.2", "events": "~1.1.0", - "glob": "^4.0.5", + "glob": "^5.0.15", "has": "^1.0.0", "htmlescape": "^1.1.0", "stream-http": "^2.0.0", @@ -55,7 +55,7 @@ "readable-stream": "^2.0.2", "resolve": "^1.1.4", "shasum": "^1.0.0", - "shell-quote": "~0.0.1", + "shell-quote": "^1.4.3", "stream-browserify": "^2.0.0", "string_decoder": "~0.10.0", "subarg": "^1.0.0", From c881c07f9ea2be6078d2d8b02009dd8d47cbc724 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 25 Oct 2015 22:47:08 -0700 Subject: [PATCH 076/193] update devdeps --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fb3167a28..6e56a79c7 100644 --- a/package.json +++ b/package.json @@ -70,13 +70,13 @@ }, "devDependencies": { "backbone": "~0.9.2", - "browser-unpack": "~0.0.0", - "coffee-script": "~1.5.0", - "coffeeify": "~0.6.0", + "browser-unpack": "^1.1.1", + "coffee-script": "~1.10.0", + "coffeeify": "~1.1.0", "es6ify": "~0.4.8", "isstream": "^0.1.2", - "seq": "0.3.3", - "tap": "^1.1.0", + "seq": "0.3.5", + "tap": "^2.2.0", "temp": "^0.8.1", "through": "^2.3.4" }, From e19f256a88d426d008d43ba31815b94a9f1d0139 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Mon, 26 Oct 2015 10:12:27 -0700 Subject: [PATCH 077/193] 12.0.0 --- changelog.markdown | 18 ++++++++++++++++++ package.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index d39b61271..d9eda9322 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,21 @@ +# 12.0.0 + +Node support changes: now testing against the latest node (currently 4.2.1). +node 0.8 is no longer supported, and iojs isn't actively tested. + +Stream3 everywhere! Everything has been updated to use streams3. + +Sourcemaps charset now uses an `=` instead of a `:`. This fixes certain issues +with Chinese characters in sourcemaps. See #753. + +module-deps has been updated to fix root transforms on symlinked modules. See +https://github.com/substack/module-deps/pull/99. + +stream-http, the module that provides `http` support, dropped IE8 support. If +you depend on this, see https://github.com/jhiesey/stream-http#ie8-note. + +Removed `builtins` and `commondir` – both unused dependencies. + # 11.2.0 When `bundleExternal` is set to `false`, `process` and `buffer` are now correctly excluded. Also, using `--igv` via the CLI now works. That also means that `--bare` and `--node` actually insert `__filename` and `__dirname`. diff --git a/package.json b/package.json index 6e56a79c7..e399be186 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "11.2.0", + "version": "12.0.0", "description": "browser-side require() the node way", "main": "index.js", "bin": { From ec829dfac8380873ed8aee9c995220638082af55 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 28 Oct 2015 02:49:48 -0700 Subject: [PATCH 078/193] transform tests --- index.js | 2 +- test/tr_symlink.js | 10 ++++++++-- test/tr_symlink/app/main.js | 2 ++ test/tr_symlink/app/node_modules/bbb | 1 + test/tr_symlink/b-module/index.js | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) create mode 120000 test/tr_symlink/app/node_modules/bbb create mode 100644 test/tr_symlink/b-module/index.js diff --git a/index.js b/index.js index 232087917..d9fd8ab29 100644 --- a/index.js +++ b/index.js @@ -484,7 +484,7 @@ Browserify.prototype._createDeps = function (opts) { } if (err) cb(err, file, pkg) else if (file) fs.realpath(file, function (err, res) { - cb(err, res, pkg); + cb(err, res, pkg, file); }); else cb(err, null, pkg) }); diff --git a/test/tr_symlink.js b/test/tr_symlink.js index c02d9c444..ae3210a50 100644 --- a/test/tr_symlink.js +++ b/test/tr_symlink.js @@ -7,11 +7,17 @@ var test = require('tap').test; var through = require('through2'); test('transform symlink', function (t) { - t.plan(3); - var expected = [ 9, 555 ]; + t.plan(4); + var expected = [ 9, 555, 777 ]; var b = browserify(__dirname + '/tr_symlink/app/main.js', { basedir: __dirname + '/tr_symlink/app' }); + b.transform(function (file) { + return through(function (buf, enc, next) { + this.push(String(buf).replace(/7/g, 9)); + next(); + }) + }); b.bundle(function (err, src) { t.ifError(err); var c = { console: { log: log } }; diff --git a/test/tr_symlink/app/main.js b/test/tr_symlink/app/main.js index 196452e5e..da0ac769b 100644 --- a/test/tr_symlink/app/main.js +++ b/test/tr_symlink/app/main.js @@ -1,4 +1,6 @@ var a = require('aaa'); +var b = require('bbb'); console.log(5); console.log(a); +console.log(b); diff --git a/test/tr_symlink/app/node_modules/bbb b/test/tr_symlink/app/node_modules/bbb new file mode 120000 index 000000000..bbded2ad5 --- /dev/null +++ b/test/tr_symlink/app/node_modules/bbb @@ -0,0 +1 @@ +../../b-module \ No newline at end of file diff --git a/test/tr_symlink/b-module/index.js b/test/tr_symlink/b-module/index.js new file mode 100644 index 000000000..9b843782e --- /dev/null +++ b/test/tr_symlink/b-module/index.js @@ -0,0 +1 @@ +module.exports = 777 From bbfabaa77fd18e81fe4fd74e104a8a793660f5c5 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 28 Oct 2015 02:55:52 -0700 Subject: [PATCH 079/193] 12.0.1 --- changelog.markdown | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog.markdown b/changelog.markdown index d9eda9322..ac1b57090 100644 --- a/changelog.markdown +++ b/changelog.markdown @@ -1,3 +1,10 @@ +# 12.0.1 + +adds the previously failing tests and a small change necessary for transforms to +be applied properly for symlinked packages + +https://github.com/substack/node-browserify/pull/1392 + # 12.0.0 Node support changes: now testing against the latest node (currently 4.2.1). diff --git a/package.json b/package.json index e399be186..c0147a7a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browserify", - "version": "12.0.0", + "version": "12.0.1", "description": "browser-side require() the node way", "main": "index.js", "bin": { From 7f8030563e89116a8a1d53feb8037006dc5c31e3 Mon Sep 17 00:00:00 2001 From: Julian Maughan Date: Sat, 7 Nov 2015 17:14:07 +0000 Subject: [PATCH 080/193] Fix badly formed module paths on Windows --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index d9fd8ab29..f13a01034 100644 --- a/index.js +++ b/index.js @@ -115,12 +115,14 @@ Browserify.prototype.require = function (file, opts) { var expose = opts.expose; if (file === expose && /^[\.]/.test(expose)) { expose = '/' + path.relative(basedir, expose); + expose = expose.replace(/\\/g, '/'); } if (expose === undefined && this._options.exposeAll) { expose = true; } if (expose === true) { expose = '/' + path.relative(basedir, file); + expose = expose.replace(/\\/g, '/'); } if (isStream(file)) { From 998603f97e216c08d8471b91e7719817dd8814d3 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 19 Nov 2015 00:32:14 -0500 Subject: [PATCH 081/193] #1386 Added failing test: browserify still transforms symlinked modules --- test/tr_symlink/b-module/ext.js | 1 + test/tr_symlink/b-module/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 test/tr_symlink/b-module/ext.js diff --git a/test/tr_symlink/b-module/ext.js b/test/tr_symlink/b-module/ext.js new file mode 100644 index 000000000..2fad98701 --- /dev/null +++ b/test/tr_symlink/b-module/ext.js @@ -0,0 +1 @@ +module.exports = 777; diff --git a/test/tr_symlink/b-module/index.js b/test/tr_symlink/b-module/index.js index 9b843782e..dae6275e7 100644 --- a/test/tr_symlink/b-module/index.js +++ b/test/tr_symlink/b-module/index.js @@ -1 +1,2 @@ -module.exports = 777 +var ext = require('./ext'); +module.exports = ext; From f2a6f805cb47cd085a4d723ef17a540988612230 Mon Sep 17 00:00:00 2001 From: ReadmeCritic Date: Sat, 21 Nov 2015 22:01:09 -0800 Subject: [PATCH 082/193] Update README URLs based on HTTP redirects --- readme.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.markdown b/readme.markdown index 6df5d02cc..bb9a79bfc 100644 --- a/readme.markdown +++ b/readme.markdown @@ -9,7 +9,7 @@ browserify will recursively analyze all the `require()` calls in your app in order to build a bundle you can serve up to the browser in a single `