Browse Source

Merge pull request #48 from rollup/gh-43

Fix #43
contingency-plan
Rich Harris 10 years ago
parent
commit
15077a8729
  1. 4
      src/Bundle.js
  2. 1
      src/Module.js
  3. 3
      test/function/top-level-side-effect-on-imported/_config.js
  4. 5
      test/function/top-level-side-effect-on-imported/lib.js
  5. 3
      test/function/top-level-side-effect-on-imported/main.js
  6. 1
      test/function/top-level-side-effect-on-imported/obj.js

4
src/Bundle.js

@ -418,7 +418,9 @@ export default class Bundle {
keys( statement.modifies ).forEach( name => {
const definingStatement = module.definitions[ name ];
const exportDeclaration = module.exports[ name ];
const exportDeclaration = module.exports[ name ] || (
module.exports.default && module.exports.default.identifier === name && module.exports.default
);
const shouldMark = ( definingStatement && definingStatement.isIncluded ) ||
( exportDeclaration && exportDeclaration.isUsed );

1
src/Module.js

@ -412,6 +412,7 @@ export default class Module {
});
}
exportDeclaration.isUsed = true;
return module.mark( exportDeclaration.localName );
});
}

3
test/function/top-level-side-effect-on-imported/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'top level function calls are preserved'
};

5
test/function/top-level-side-effect-on-imported/lib.js

@ -0,0 +1,5 @@
import obj from './obj';
obj.value = 'augmented';
export default obj;

3
test/function/top-level-side-effect-on-imported/main.js

@ -0,0 +1,3 @@
import lib from './lib';
assert.strictEqual(lib.value, 'augmented');

1
test/function/top-level-side-effect-on-imported/obj.js

@ -0,0 +1 @@
export default { value: 'original' };
Loading…
Cancel
Save