鍍金池/ 問答/HTML/ webpack 提取公共模塊報(bào)錯(cuò)問題

webpack 提取公共模塊報(bào)錯(cuò)問題

react多入口:
webpack 提取公共模塊,編譯可以通過,但是執(zhí)行JS報(bào)錯(cuò):"Uncaught ReferenceError: exports is not defined"

看編譯后的文件跟正常編譯后的文件有很大的差別:例如

exports.ids = [6];
exports.modules = {

/***/ 100:
/***/ (function(module, exports) {

module.exports = function (it, Constructor, name, forbiddenField) {
  if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
    throw TypeError(name + ': incorrect invocation!');
  } return it;
};

錯(cuò)誤也就是定位到第一行。
這里是跟babel配置有關(guān)系么?配置代碼如下:

{
    "presets": [
        ["es2015", {
            // "modules": false
        }],
        "stage-2",
        "react"
    ],
    "plugins": [
        "transform-decorators-legacy",
        "react-hot-loader/babel", ["transform-runtime", {
            "helpers": false,
            "polyfill": true,
            "regenerator": true,
            "moduleName": "babel-runtime"
        }]
    ]
}

請(qǐng)大拿們幫我解決困惑。

問題描述

問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法

相關(guān)代碼

// 請(qǐng)把代碼文本粘貼到下方(請(qǐng)勿用圖片代替代碼)

你期待的結(jié)果是什么?實(shí)際看到的錯(cuò)誤信息又是什么?

回答
編輯回答
下墜
presets: [['es2015', { modules: false }], 'stage-2', 'react'],
2017年12月11日 06:36