You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I initially found an issue with webpack's module system. I reported that issue here webpack/webpack#4753.
I asked on the babel slack channel which behavior was correct, and @loganfsmyth said:
Looks like they are both a little wrong.
function foo(){}
export {foo};
and
export function foo(){}
should both export foo before processing the imported modules. Functions declaration bindings are initialized with their values before evaluating their imported modules.
Input Code
foo.js
import{bar}from"./bar";functionfoo(){}export{foo}
Expected Behavior
"use strict";Object.defineProperty(exports,"__esModule",{value: true});exports.foo=foo;// <--- foo should be exported before importvar_bar=require("./bar");functionfoo(){}
Current Behavior
"use strict";Object.defineProperty(exports,"__esModule",{value: true});exports.foo=undefined;// <--- foo is not undefinedvar_bar=require("./bar");functionfoo(){}exports.foo=foo;// <--- foo is defined after the import
Context
If I change my code to this I get the "Expected Behavior":
import{bar}from"./bar";exportfunctionfoo(){}
The original issue deals with circular dependencies. As such, I also have bar.js:
Hey @lukescott! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.
Activity
babel-bot commentedon Apr 20, 2017
Hey @lukescott! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.