ES6 modules: imported constants are undefined at first; they become available later
问题 I use ES6 modules in my JavaScript application. The sources are compiled with webpack and babel. This is a shortened version of the file that causes me trouble: export const JUST_FORM = 0; export const AS_PAGE = 1; console.log(AS_PAGE); // ** export default function doSomething(mode = AS_PAGE) { console.log(mode); console.log(JUST_FORM); } I use this functionality just as you would expect. import doSomething, { AS_PAGE } from './doSomething' console.log(AS_PAGE); doSomething(); When I run the