Browse Source

do less work at end

rewrite
Rich-Harris 8 years ago
parent
commit
fe36478151
  1. 28
      src/Bundle.js

28
src/Bundle.js

@ -130,28 +130,22 @@ export default class Bundle {
while ( !settled ) { while ( !settled ) {
settled = true; settled = true;
for ( const expression of this.dependentExpressions ) { let i = this.dependentExpressions.length;
if ( expression.isUsedByBundle() ) { while ( i-- ) {
const statement = expression.findParent( /ExpressionStatement/ ); const expression = this.dependentExpressions[i];
const statement = expression.findParent( /ExpressionStatement/ );
if ( statement && !statement.ran ) {
settled = false; if ( !statement || statement.ran ) {
statement.run( statement.findScope() ); this.dependentExpressions.splice( i, 1 );
} } else if ( expression.isUsedByBundle() ) {
settled = false;
statement.run( statement.findScope() );
this.dependentExpressions.splice( i, 1 );
} }
} }
} }
} }
// let settled = false;
// while ( !settled ) {
// settled = true;
//
// this.modules.forEach( module => {
// if ( module.run( this.treeshake ) ) settled = false;
// });
// }
// Phase 4 – final preparation. We order the modules with an // Phase 4 – final preparation. We order the modules with an
// enhanced topological sort that accounts for cycles, then // enhanced topological sort that accounts for cycles, then
// ensure that names are deconflicted throughout the bundle // ensure that names are deconflicted throughout the bundle

Loading…
Cancel
Save