Browse Source

include members of namespaces that are exported as defaults

better-aggressive
Rich Harris 9 years ago
parent
commit
9a8f331a8b
  1. 12
      src/Module.js
  2. 1
      test/form/spacing-after-function-with-semicolon/_config.js
  3. 3
      test/function/mark-namespace-members/_config.js
  4. 5
      test/function/mark-namespace-members/bar.js
  5. 1
      test/function/mark-namespace-members/foo.js
  6. 4
      test/function/mark-namespace-members/main.js

12
src/Module.js

@ -42,6 +42,8 @@ class SyntheticDefaultDeclaration {
this.isUsed = true;
this.statement.mark();
if ( this.original ) this.original.use();
this.aliases.forEach( alias => alias.use() );
}
}
@ -84,11 +86,6 @@ class SyntheticNamespaceDeclaration {
if ( !this.needsNamespaceBlock ) {
this.needsNamespaceBlock = true;
this.module.bundle.internalNamespaces.push( this );
keys( this.originals ).forEach( name => {
const original = this.originals[ name ];
original.use();
});
}
reference.declaration = this;
@ -114,7 +111,10 @@ class SyntheticNamespaceDeclaration {
}
use () {
// noop?
keys( this.originals ).forEach( name => {
this.originals[ name ].use();
});
this.aliases.forEach( alias => alias.use() );
}
}

1
test/form/spacing-after-function-with-semicolon/_config.js

@ -1,4 +1,3 @@
module.exports = {
solo: true,
description: 'handles superfluous semicolons'
};

3
test/function/mark-namespace-members/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'marks namespace members'
};

5
test/function/mark-namespace-members/bar.js

@ -0,0 +1,5 @@
function bar () {
return 42;
}
export default bar;

1
test/function/mark-namespace-members/foo.js

@ -0,0 +1 @@
export { default as bar } from './bar';

4
test/function/mark-namespace-members/main.js

@ -0,0 +1,4 @@
import * as foo from './foo';
var member = 'bar';
assert.equal( foo[ member ](), 42 );
Loading…
Cancel
Save