Browse Source

Removed unused

gh-109
Oskar Segersvärd 9 years ago
parent
commit
d3f9f2fee6
  1. 32
      src/Bundle.js
  2. 8
      src/ExternalModule.js
  3. 3
      src/Module.js

32
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();

8
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;
}
}
}

3
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

Loading…
Cancel
Save