Browse Source

track side-effects to default exports - fixes #733, sort of

semi-dynamic-namespace-imports
Rich Harris 9 years ago
parent
commit
e628775a42
  1. 2
      src/utils/run.js
  2. 2
      test/function/export-two-ways-default/bar.js
  3. 2
      test/function/export-two-ways-default/foo.js
  4. 4
      test/function/export-two-ways-default/main.js

2
src/utils/run.js

@ -104,7 +104,7 @@ export default function run ( node, scope, statement, strongDependencies, force
} else {
declaration = statement.module.trace( subject.name );
if ( !declaration || declaration.isExternal || declaration.isUsed ) {
if ( !declaration || declaration.isExternal || declaration.isUsed || ( declaration.original && declaration.original.isUsed ) ) {
hasSideEffect = true;
}
}

2
test/function/export-two-ways-default/bar.js

@ -1,6 +1,6 @@
import { X } from './x.js'; // import X works
X.prototype.bar = function () {
console.log( 'bar' );
this.didBar = true;
return this;
};

2
test/function/export-two-ways-default/foo.js

@ -1,7 +1,7 @@
export function X () {}
X.prototype.foo = function () {
console.log( 'foo' );
this.didFoo = true;
return this;
};

4
test/function/export-two-ways-default/main.js

@ -1,4 +1,6 @@
import { x } from './x.js';
import './bar.js';
x().foo().bar();
var result = x().foo().bar();
assert.ok( result.didFoo );
assert.ok( result.didBar );

Loading…
Cancel
Save