【发布时间】:2018-08-23 05:09:41
【问题描述】:
对于这样的代码:
const top = document.createElement("div");
top.innerText = "This is the top";
top.style = red;
export { top };
Webpack 创建以下内容:
...
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "top", function() { return top; });
...
const top = document.createElement("div");
top.innerText = "This is the top";
top.style = red;
由于在 getter 内部 function() { return top; }、top 在执行脚本时尚未定义,这如何工作?
Webpack 在顶部而不是底部创建导出是否有特殊原因?
谢谢。
【问题讨论】:
标签: javascript webpack ecmascript-6 es6-modules webpack-bundle