Skip to content

Commit

Permalink
fix for deduped json
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Feb 21, 2015
1 parent 85f21bf commit 5a9d3fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ Browserify.prototype._recorder = function (opts) {

Browserify.prototype._json = function () {
return through.obj(function (row, enc, next) {
if (/\.json$/.test(row.file)) {
if (/\.json$/.test(row.file) && !isdedupe(row.source)) {
row.source = 'module.exports=' + row.source;
}
this.push(row);
Expand Down Expand Up @@ -617,6 +617,12 @@ 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

0 comments on commit 5a9d3fb

Please sign in to comment.