Webpack 2“导出未定义”

时间:2017-02-04 12:47:46

标签: webpack webpack-dev-server babel

我刚刚更新到Webpack 2并在浏览器中收到运行时错误exports is not defined。我改变了我的.babelrc:

{
  "plugins": [
    "syntax-flow",
    "transform-flow-strip-types",
    "add-module-exports"
  ],
  "presets": [
    "latest",
    "stage-2"
  ]
}

到此:

{
  "plugins": [
    "syntax-flow",
    "transform-flow-strip-types",
    "add-module-exports"
  ],
  "presets": [
    ["latest", {
        "es2015": {
            "modules": false
        }
    }],
    "stage-2"
  ]
}

停用模块导入/导出转换并利用webpack 2的树状抖动功能。我错过了什么吗?构建编译正确,但在浏览器中它只是爆炸。

1 个答案:

答案 0 :(得分:6)

TL; DR)摆脱add-module-exports

要了解有关正在发生的事情的更多信息:https://ntucker.true.io/ntucker/webpack-2-uncaught-referenceerror-exports-is-not-defined/