Skip to content

Commit

Permalink
Merge pull request #1244 from substack/remove-json-dedupe
Browse files Browse the repository at this point in the history
Remove unnecessary "isDedupe" json check
  • Loading branch information
zertosh committed May 14, 2015
2 parents 1ff88d5 + 2a08528 commit 52867a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,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);
Expand Down Expand Up @@ -631,12 +631,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) {
Expand Down
15 changes: 11 additions & 4 deletions test/double_bundle_json.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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 } });
Expand Down

0 comments on commit 52867a9

Please sign in to comment.