Rich-Harris 9 years ago
parent
commit
275f0df91d
  1. 7
      src/Bundle.js
  2. 8
      src/Declaration.js
  3. 4
      test/form/external-import-alias-shadow/_expected/amd.js
  4. 4
      test/form/external-import-alias-shadow/_expected/cjs.js
  5. 4
      test/form/external-import-alias-shadow/_expected/es6.js
  6. 4
      test/form/external-import-alias-shadow/_expected/iife.js
  7. 4
      test/form/external-import-alias-shadow/_expected/umd.js

7
src/Bundle.js

@ -127,6 +127,13 @@ export default class Bundle {
this.externalModules.forEach( module => { this.externalModules.forEach( module => {
module.name = getSafeName( module.name ); module.name = getSafeName( module.name );
// ensure we don't shadow named external imports, if
// we're creating an ES6 bundle
keys( module.declarations ).forEach( name => {
const declaration = module.declarations[ name ];
declaration.setSafeName( getSafeName( name ) );
});
}); });
this.modules.forEach( module => { this.modules.forEach( module => {

8
src/Declaration.js

@ -221,6 +221,8 @@ export class ExternalDeclaration {
this.module = module; this.module = module;
this.name = name; this.name = name;
this.isExternal = true; this.isExternal = true;
this.safeName = null;
} }
addAlias () { addAlias () {
@ -246,13 +248,17 @@ export class ExternalDeclaration {
this.module.name; this.module.name;
} }
return es6 ? this.name : `${this.module.name}.${this.name}`; return es6 ? this.safeName : `${this.module.name}.${this.name}`;
} }
run () { run () {
return true; return true;
} }
setSafeName ( name ) {
this.safeName = name;
}
use () { use () {
// noop? // noop?
} }

4
test/form/external-import-alias-shadow/_expected/amd.js

@ -1,9 +1,9 @@
define(['acorn'], function (acorn) { 'use strict'; define(['acorn'], function (acorn) { 'use strict';
function parse(source) { function parse$1(source) {
return acorn.parse(source, { ecmaVersion: 6 }); return acorn.parse(source, { ecmaVersion: 6 });
} }
console.log(parse('foo')); console.log(parse$1('foo'));
}); });

4
test/form/external-import-alias-shadow/_expected/cjs.js

@ -2,8 +2,8 @@
var acorn = require('acorn'); var acorn = require('acorn');
function parse(source) { function parse$1(source) {
return acorn.parse(source, { ecmaVersion: 6 }); return acorn.parse(source, { ecmaVersion: 6 });
} }
console.log(parse('foo')); console.log(parse$1('foo'));

4
test/form/external-import-alias-shadow/_expected/es6.js

@ -1,7 +1,7 @@
import { parse } from 'acorn'; import { parse } from 'acorn';
function parse$$(source) { function parse$1(source) {
return parse(source, { ecmaVersion: 6 }); return parse(source, { ecmaVersion: 6 });
} }
console.log(parse$$('foo')); console.log(parse$1('foo'));

4
test/form/external-import-alias-shadow/_expected/iife.js

@ -1,10 +1,10 @@
(function (acorn) { (function (acorn) {
'use strict'; 'use strict';
function parse(source) { function parse$1(source) {
return acorn.parse(source, { ecmaVersion: 6 }); return acorn.parse(source, { ecmaVersion: 6 });
} }
console.log(parse('foo')); console.log(parse$1('foo'));
}(acorn)); }(acorn));

4
test/form/external-import-alias-shadow/_expected/umd.js

@ -4,10 +4,10 @@
(factory(global.acorn)); (factory(global.acorn));
}(this, function (acorn) { 'use strict'; }(this, function (acorn) { 'use strict';
function parse(source) { function parse$1(source) {
return acorn.parse(source, { ecmaVersion: 6 }); return acorn.parse(source, { ecmaVersion: 6 });
} }
console.log(parse('foo')); console.log(parse$1('foo'));
})); }));
Loading…
Cancel
Save