Browse Source

Fixed modifier statements. All tests (but sourcemap/names) pass.

gh-109
Oskar Segersvärd 9 years ago
parent
commit
7627b6c810
  1. 32
      src/Bundle.js
  2. 7
      src/Statement.js

32
src/Bundle.js

@ -60,7 +60,6 @@ export default class Bundle {
this.exports = entryModule.exports; this.exports = entryModule.exports;
entryModule.markAllStatements( true ); entryModule.markAllStatements( true );
this.markAllModifierStatements();
this.orderedModules = this.sort(); this.orderedModules = this.sort();
this.exports.localIds().forEach( ([ , id ]) => { this.exports.localIds().forEach( ([ , id ]) => {
@ -148,37 +147,6 @@ export default class Bundle {
return Promise.all( promises ); return Promise.all( promises );
} }
markAllModifierStatements () {
let settled = true;
this.modules.forEach( module => {
module.statements.forEach( statement => {
if ( statement.isIncluded ) return;
keys( statement.modifies ).forEach( name => {
const local = module.locals.lookup( name );
const exported = module.exports.lookup( name );
if ( local && local.module === module || exported && exported.isUsed ) {
settled = false;
statement.mark();
return;
}
// special case - https://github.com/rollup/rollup/pull/40
// TODO refactor this? it's a bit confusing
// TODO things like `export default a + b` don't apply here... right?
if ( !local || !local.statement || !local.module || local.module.isExternal ) return;
settled = false;
statement.mark();
});
});
});
if ( !settled ) this.markAllModifierStatements();
}
render ( options = {} ) { render ( options = {} ) {
const format = options.format || 'es6'; const format = options.format || 'es6';

7
src/Statement.js

@ -33,7 +33,6 @@ export default class Statement {
this.scope = new Scope(); this.scope = new Scope();
this.defines = blank(); this.defines = blank();
this.modifies = blank();
this.dependsOn = blank(); this.dependsOn = blank();
this.stronglyDependsOn = blank(); this.stronglyDependsOn = blank();
@ -326,7 +325,11 @@ export default class Statement {
// anything (but we still need to call checkForWrites to // anything (but we still need to call checkForWrites to
// catch illegal reassignments to imported bindings) // catch illegal reassignments to imported bindings)
if ( writeDepth === 0 && node.type === 'Identifier' ) { if ( writeDepth === 0 && node.type === 'Identifier' ) {
this.modifies[ node.name ] = true; const id = this.module.locals.lookup( node.name );
if ( id && id.modifierStatements && !~id.modifierStatements.indexOf( this ) ) {
id.modifierStatements.push( this );
}
} }
}; };

Loading…
Cancel
Save