对于这样的代码:
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 在顶部而不是底部创建导出是否有特殊原因?
谢谢。