Browse Source

remove obsolete special case logic

contingency-plan
Rich-Harris 10 years ago
parent
commit
0cc1221b7a
  1. 28
      src/Module.js

28
src/Module.js

@ -397,34 +397,6 @@ export default class Module {
statement = name === 'default' ? this.exports.default.statement : this.definitions[ name ];
promise = statement && !statement.isIncluded ? statement.mark() : emptyArrayPromise;
// Special case - `export default foo; foo += 1` - need to be
// vigilant about maintaining the correct order of the export
// declaration. Otherwise, the export declaration will always
// go at the end of the expansion, because the expansion of
// `foo` will include statements *after* the declaration
if ( name === 'default' && this.exports.default.identifier && this.exports.default.isModified ) {
const defaultExportStatement = this.exports.default.statement;
promise = promise.then( statements => {
// remove the default export statement...
// TODO could this be statements.pop()?
statements.splice( statements.indexOf( defaultExportStatement ), 1 );
let i = statements.length;
let inserted = false;
while ( i-- ) {
if ( statements[i].module === this && statements[i].index < defaultExportStatement.index ) {
statements.splice( i + 1, 0, defaultExportStatement );
inserted = true;
break;
}
}
if ( !inserted ) statements.push( statement );
return statements;
});
}
}
this.definitionPromises[ name ] = promise || emptyArrayPromise;

Loading…
Cancel
Save