Browse Source

handle pathological cycles

declarations-and-references
Rich-Harris 9 years ago
parent
commit
ac25ad5f4c
  1. 5
      src/Bundle.js
  2. 14
      src/Module.js
  3. 2
      test/function/consistent-renaming-c/_config.js

5
src/Bundle.js

@ -68,7 +68,10 @@ export default class Bundle {
entryModule.getExports().forEach( name => {
const declaration = entryModule.traceExport( name );
declaration.isExported = true;
declaration.statement.mark();
if ( declaration.statement ) {
declaration.statement.mark();
}
});
this.markAllModifierStatements();

14
src/Module.js

@ -254,9 +254,19 @@ export default class Module {
this.statements.forEach( statement => {
statement.references.forEach( reference => {
if ( reference.declaration && reference.declaration.statement ) {
const module = reference.declaration.statement.module;
const declaration = reference.declaration;
if ( declaration && declaration.statement ) {
const module = declaration.statement.module;
if ( module === this ) return;
weakDependencies[ module.id ] = module;
// TODO handle references inside IIFEs, and disregard
// function declarations
if ( !reference.scope.parent ) {
strongDependencies[ module.id ] = module;
}
}
});
});

2
test/function/consistent-renaming-c/_config.js

@ -1,3 +1,3 @@
module.exports = {
description: 'consistent renaming test c'
};
};

Loading…
Cancel
Save