diff --git a/src/Bundle.js b/src/Bundle.js index 82b19dd..537435c 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -1,11 +1,9 @@ -import { basename, extname } from './utils/path'; import { Promise } from 'sander'; import MagicString from 'magic-string'; import { blank, keys } from './utils/object'; import Module from './Module'; import ExternalModule from './ExternalModule'; import finalisers from './finalisers/index'; -import makeLegalIdentifier from './utils/makeLegalIdentifier'; import ensureArray from './utils/ensureArray'; import { defaultResolver, defaultExternalResolver } from './utils/resolveId'; import { defaultLoader } from './utils/load'; @@ -52,38 +50,8 @@ export default class Bundle { return Promise.resolve( this.resolveId( this.entry, undefined, this.resolveOptions ) ) .then( id => this.fetchModule( id ) ) .then( entryModule => { - const defaultExport = entryModule.exports.default; - this.entryModule = entryModule; - if ( defaultExport ) { - entryModule.needsDefault = true; - - // `export default function foo () {...}` - - // use the declared name for the export - if ( defaultExport.identifier ) { - entryModule.suggestName( 'default', defaultExport.identifier ); - } - - // `export default a + b` - generate an export name - // based on the id of the entry module - else { - let defaultExportName = makeLegalIdentifier( basename( this.entryModule.id ).slice( 0, -extname( this.entryModule.id ).length ) ); - - // deconflict - let topLevelNames = []; - entryModule.statements.forEach( statement => { - keys( statement.defines ).forEach( name => topLevelNames.push( name ) ); - }); - - while ( ~topLevelNames.indexOf( defaultExportName ) ) { - defaultExportName = `_${defaultExportName}`; - } - - entryModule.suggestName( 'default', defaultExportName ); - } - } - entryModule.markAllStatements( true ); this.markAllModifierStatements(); this.orderedModules = this.sort(); diff --git a/src/ExternalModule.js b/src/ExternalModule.js index 0d8a492..5b57fed 100644 --- a/src/ExternalModule.js +++ b/src/ExternalModule.js @@ -39,12 +39,4 @@ export default class ExternalModule { findDefiningStatement () { return null; } - - suggestName ( exportName, suggestion ) { - const id = this.exports.lookup( exportName ); - - if ( id.name === id.originalName ) { - id.name = suggestion; - } - } } diff --git a/src/Module.js b/src/Module.js index 9b5469d..b72c2cd 100644 --- a/src/Module.js +++ b/src/Module.js @@ -1,3 +1,4 @@ +import { basename, extname } from './utils/path'; import { parse } from 'acorn'; import MagicString from 'magic-string'; import Statement from './Statement'; @@ -32,7 +33,7 @@ export default class Module { this.id = id; // Implement Identifier interface. - this.name = makeLegalIdentifier( id ); + this.name = makeLegalIdentifier( basename( id ).slice( 0, -extname( id ).length ) ); // By default, `id` is the filename. Custom resolvers and loaders // can change that, but it makes sense to use it for the source filename