Browse Source

allow namespace to be assigned to a variable. fixes #168

better-aggressive
Rich-Harris 9 years ago
parent
commit
06b4107440
  1. 3
      src/Module.js
  2. 3
      test/function/assign-namespace-to-var/_config.js
  3. 5
      test/function/assign-namespace-to-var/b.js
  4. 4
      test/function/assign-namespace-to-var/main.js

3
src/Module.js

@ -274,8 +274,11 @@ export default class Module {
bindAliases () { bindAliases () {
keys( this.declarations ).forEach( name => { keys( this.declarations ).forEach( name => {
if ( name === '*' ) return;
const declaration = this.declarations[ name ]; const declaration = this.declarations[ name ];
const statement = declaration.statement; const statement = declaration.statement;
if ( statement.node.type !== 'VariableDeclaration' ) return; if ( statement.node.type !== 'VariableDeclaration' ) return;
statement.references.forEach( reference => { statement.references.forEach( reference => {

3
test/function/assign-namespace-to-var/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'allows a namespace to be assigned to a variable'
};

5
test/function/assign-namespace-to-var/b.js

@ -0,0 +1,5 @@
export function foo () {
return 10;
}
export var bar = 20;

4
test/function/assign-namespace-to-var/main.js

@ -0,0 +1,4 @@
import * as b from './b';
var val = b.foo();
var val2 = b.bar;
Loading…
Cancel
Save