From 06b410744066961554e9ffba72e4209dad69d95f Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Wed, 7 Oct 2015 20:52:22 -0400 Subject: [PATCH] allow namespace to be assigned to a variable. fixes #168 --- src/Module.js | 3 +++ test/function/assign-namespace-to-var/_config.js | 3 +++ test/function/assign-namespace-to-var/b.js | 5 +++++ test/function/assign-namespace-to-var/main.js | 4 ++++ 4 files changed, 15 insertions(+) create mode 100644 test/function/assign-namespace-to-var/_config.js create mode 100644 test/function/assign-namespace-to-var/b.js create mode 100644 test/function/assign-namespace-to-var/main.js diff --git a/src/Module.js b/src/Module.js index 71f9ff6..96d6869 100644 --- a/src/Module.js +++ b/src/Module.js @@ -274,8 +274,11 @@ export default class Module { bindAliases () { keys( this.declarations ).forEach( name => { + if ( name === '*' ) return; + const declaration = this.declarations[ name ]; const statement = declaration.statement; + if ( statement.node.type !== 'VariableDeclaration' ) return; statement.references.forEach( reference => { diff --git a/test/function/assign-namespace-to-var/_config.js b/test/function/assign-namespace-to-var/_config.js new file mode 100644 index 0000000..ce0a100 --- /dev/null +++ b/test/function/assign-namespace-to-var/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'allows a namespace to be assigned to a variable' +}; diff --git a/test/function/assign-namespace-to-var/b.js b/test/function/assign-namespace-to-var/b.js new file mode 100644 index 0000000..4bc6359 --- /dev/null +++ b/test/function/assign-namespace-to-var/b.js @@ -0,0 +1,5 @@ +export function foo () { + return 10; +} + +export var bar = 20; diff --git a/test/function/assign-namespace-to-var/main.js b/test/function/assign-namespace-to-var/main.js new file mode 100644 index 0000000..4bbbfd4 --- /dev/null +++ b/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;