esnext / es6-module-transpiler

Tomorrow’s JavaScript module syntax today
http://esnext.github.io/es6-module-transpiler/
Other
1.21k stars 85 forks source link

Module bindings are not propagated across multiple modules when using `import * as` syntax #189

Open Pauan opened 9 years ago

Pauan commented 9 years ago

Consider these three modules:

// foo.js
export var foo = 5;

// bar.js
import { foo } from "./foo";
export { foo };

// qux.js
import * as bar from "./bar";
console.log(bar.foo);

Using the "bundle" format of es6-module-transpiler version 0.9.6, I get this output:

(function() {
    "use strict";

    var $$bar$$ = {
        get foo() {
            return $$bar$$foo;
        }
    };

    var $$foo$$foo = 5;
    console.log($$bar$$.foo);
}).call(this);

//# sourceMappingURL=build.js.map

As you can see, it incorrectly uses the variable $$bar$$foo, rather than the correct variable $$foo$$foo.

If I change qux.js to this, then it works correctly:

import { foo } from "./bar";
console.log(foo);