Permalink
Browse files

Add option to turn off deduping

  • Loading branch information...
1 parent 071642a commit 7fbaee2d1373f5f186bab98d80dbffaccd058d92 @ganemone ganemone committed Jun 23, 2016
Showing with 31 additions and 3 deletions.
  1. +4 −0 bin/advanced.txt
  2. +3 −1 bin/args.js
  3. +4 −2 index.js
  4. +4 −0 readme.markdown
  5. +16 −0 test/dedupe-deps.js
View
@@ -70,6 +70,10 @@ Advanced Options:
Instead of standard bundle output, print the dependency array generated by
module-deps.
+ --no-dedupe
+
+ Turn off deduping.
+
--list
Print each file in the dependency graph. Useful for makefiles.
View
@@ -47,6 +47,7 @@ module.exports = function (args, opts) {
commondir: true,
'bundle-external': true,
bf: true,
+ dedupe: true,
node: false
}
});
@@ -104,7 +105,8 @@ module.exports = function (args, opts) {
bundleExternal: argv['bundle-external'],
basedir: argv.basedir,
browserField: argv.browserField,
-
+ dedupe: argv['dedupe'],
+
detectGlobals: argv.detectGlobals,
insertGlobals: argv['insert-globals'] || argv.ig,
insertGlobalVars: insertGlobalVars,
View
@@ -49,7 +49,9 @@ function Browserify (files, opts) {
if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
throw new Error('opts.basedir must be either undefined or a string.');
}
-
+
+ opts.dedupe = opts.dedupe === false ? false : true;
+
self._external = [];
self._exclude = [];
self._ignore = [];
@@ -380,7 +382,7 @@ Browserify.prototype._createPipeline = function (opts) {
var dopts = {
index: !opts.fullPaths && !opts.exposeAll,
- dedupe: true,
+ dedupe: opts.dedupe,
expose: this._expose
};
this._bpack = bpack(xtend(opts, { raw: true }));
View
@@ -178,6 +178,10 @@ Advanced Options:
Instead of standard bundle output, print the dependency array generated by
module-deps.
+ --no-dedupe
+
+ Turn off deduping.
+
--list
Print each file in the dependency graph. Useful for makefiles.
View
@@ -41,3 +41,19 @@ test('identical content gets deduped with fullPaths', function (t) {
);
}
})
+
+test('identical content does not get deduped with dedupe option false', function (t) {
+ t.plan(1)
+
+ var rows = [];
+ browserify({fullPaths: true, dedupe: false})
+ .on('dep', [].push.bind(rows))
+ .require(require.resolve('./dup'), { entry: true })
+ .bundle(check);
+
+ function check(err, src) {
+ if (err) return t.fail(err);
+ var deduped = rows.filter(function (x) { return x.dedupe });
+ t.equal(deduped.length, 0, 'does not dedupe');
+ }
+})

0 comments on commit 7fbaee2

Please sign in to comment.