Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #233 from mbostock/fix-require-collision
Browse files Browse the repository at this point in the history
Fix #232 - require collision.
  • Loading branch information
lukastaegert committed Oct 7, 2017
2 parents 419a912 + 7c14734 commit 8d53cca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
if ( existing === undefined ) {
sources.push( source );

if ( !name ) name = `require$$${uid++}`;
if ( !name ) {
do name = `require$$${uid++}`;
while ( scope.contains( name ) );
}

required[ source ] = { source, name, importsDefault: false };
}

Expand Down
5 changes: 5 additions & 0 deletions test/form/require-collision/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function() {
var foo = require("foo");
var require$$0 = "FAIL";
console.log(foo);
})();
15 changes: 15 additions & 0 deletions test/form/require-collision/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'foo';
import require$$1 from 'commonjs-proxy:foo';

(function() {
var foo = require$$1;
var require$$0 = "FAIL";
console.log(foo);
})();

var input = {

};

export default input;
export { input as __moduleExports };

0 comments on commit 8d53cca

Please sign in to comment.