Do you want to request a feature or report a bug?
Bug
What is the current behavior?
export function foo() {} is not hoisted above import. With code below, you get:
console.log(foo) -> undefined
If the current behavior is a bug, please provide the steps to reproduce.
foo.js
import {bar} from "./bar";
export function foo() {}
bar.js
import {foo} from "./foo";
console.log(foo);
index.js
.babelrc:
{
"presets": [
["latest", {"es2015": {"modules": false}}],
],
}
What is the expected behavior?
console.log(foo) -> function foo() {}
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
- Max OS X 10.11.6
- Chrome 57
- Node 7.8.0
- webpack 2.3.3
When you remove ["latest", {"es2015": {"modules": false}}], from .babelrc (set modules to true) it works as expected.
Babel produces this for foo.js:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = foo;
var _bar = require("./bar");
function foo() {}
If I change foo.js to this it breaks with babel:
import {bar} from "./bar";
function foo() {}
export {foo}
This is what babel produces:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.foo = undefined;
var _bar = require("./bar");
function foo() {}
exports.foo = foo;
It seems that Babel makes a distinction between export function foo{} and function foo() {}; export {foo} and webpack does not.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
export function foo() {}is not hoisted above import. With code below, you get:console.log(foo) ->
undefinedIf the current behavior is a bug, please provide the steps to reproduce.
foo.js
bar.js
index.js
.babelrc:
{ "presets": [ ["latest", {"es2015": {"modules": false}}], ], }What is the expected behavior?
console.log(foo) ->
function foo() {}Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
When you remove
["latest", {"es2015": {"modules": false}}],from .babelrc (set modules to true) it works as expected.Babel produces this for foo.js:
If I change foo.js to this it breaks with babel:
This is what babel produces:
It seems that Babel makes a distinction between
export function foo{}andfunction foo() {}; export {foo}and webpack does not.