Browse Source

Merge pull request #411 from rollup/gh-410

prevent resolution of external IDs
gh-438-b
Rich Harris 9 years ago
parent
commit
f62921048e
  1. 1
      .gitignore
  2. 7
      src/Bundle.js
  3. 15
      test/function/external-ids-not-resolved/_config.js
  4. 2
      test/function/external-ids-not-resolved/main.js
  5. 3
      test/node_modules/external.js

1
.gitignore

@ -1,5 +1,6 @@
.DS_Store .DS_Store
node_modules node_modules
!test/node_modules
.gobble* .gobble*
dist dist
_actual _actual

7
src/Bundle.js

@ -31,9 +31,8 @@ export default class Bundle {
this.entryModule = null; this.entryModule = null;
this.resolveId = first( this.resolveId = first(
this.plugins [ id => ~this.external.indexOf( id ) ? false : null ]
.map( plugin => plugin.resolveId ) .concat( this.plugins.map( plugin => plugin.resolveId ).filter( Boolean ) )
.filter( Boolean )
.concat( resolveId ) .concat( resolveId )
); );
@ -264,7 +263,7 @@ export default class Bundle {
if ( this.transformers.length || this.bundleTransformers.length ) { if ( this.transformers.length || this.bundleTransformers.length ) {
map = collapseSourcemaps( map, usedModules, bundleSourcemapChain ); map = collapseSourcemaps( map, usedModules, bundleSourcemapChain );
} }
map.sources = map.sources.map( unixizePath ); map.sources = map.sources.map( unixizePath );
} }

15
test/function/external-ids-not-resolved/_config.js

@ -0,0 +1,15 @@
module.exports = {
description: 'does not attempt to resolve external IDs',
options: {
external: [ 'external' ],
plugins: [
{
resolveId: function ( importee ) {
if ( importee === 'external' ) {
throw new Error( 'Attempted to resolve external module ID' );
}
}
}
]
}
};

2
test/function/external-ids-not-resolved/main.js

@ -0,0 +1,2 @@
import foo from 'external';
assert.ok( foo.external );

3
test/node_modules/external.js

@ -0,0 +1,3 @@
module.exports = {
external: true
};
Loading…
Cancel
Save