Browse Source

Updated ES6 finalizer

gh-109
Oskar Segersvärd 10 years ago
parent
commit
5e5bb7b9e0
  1. 14
      src/finalisers/es6.js

14
src/finalisers/es6.js

@ -1,9 +1,11 @@
import { keys } from '../utils/object';
function specifiersFor ( scope ) { function specifiersFor ( externalModule ) {
return scope.getNames() return keys( externalModule.importedByBundle )
.filter( notDefault ) .filter( notDefault )
.sort()
.map( name => { .map( name => {
const id = scope.lookup( name ); const id = externalModule.exports.lookup( name );
return name !== id.name ? `${name} as ${id.name}` : name; return name !== id.name ? `${name} as ${id.name}` : name;
}); });
@ -25,13 +27,11 @@ export default function es6 ( bundle, magicString ) {
} }
if ( module.needsAll ) { if ( module.needsAll ) {
specifiers.push( '* as ' + module.importedByBundle.filter( declaration => specifiers.push( '* as ' + module.name );
declaration.name === '*' )[0].localName );
} }
if ( module.needsNamed ) { if ( module.needsNamed ) {
specifiers.push( '{ ' + specifiersFor( module.exports ) specifiers.push( '{ ' + specifiersFor( module ).join( ', ' ) + ' }' );
.join( ', ' ) + ' }' );
} }
return specifiers.length ? return specifiers.length ?

Loading…
Cancel
Save