Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to turn off deduping #1581

Merged
1 commit merged into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/advanced.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion bin/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = function (args, opts) {
commondir: true,
'bundle-external': true,
bf: true,
dedupe: true,
node: false
}
});
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 }));
Expand Down
4 changes: 4 additions & 0 deletions readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions test/dedupe-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
})