升级到babel7和webpack4后,“模块导出”停止工作

时间:2019-03-29 18:06:38

标签: javascript reactjs webpack babel create-react-app

我已将create-react-app从1升级到2,并且我的其中一个插件随后停止工作,因为module exports似乎存在问题 我已经使用新版本的babel7webpack4升级了配置 模块失败并出现以下问题-

TypeError: Cannot set property 'x' of undefined 
(function (exports) {
  exports.x = x;
...

这是我的babel配置-

"babel": {
    "plugins": [
      "add-module-exports",
      "@babel/plugin-syntax-dynamic-import",
      [
        "@babel/plugin-proposal-decorators",
        {
          "legacy": true
        }
      ],
      [
        "@babel/plugin-proposal-class-properties",
        {
          "loose": false
        }
      ]
    ],
    "presets": [
      [
        "@babel/preset-env",
        {
          "modules": false
        }
      ],
      [
        "react-app",
        {
          "helpers": false,
          "absoluteRuntime": false
        }
      ]
    ]

  }

这是我的webpack配置-

https://gist.github.com/sandipp/282bbbc1d23e6e9c2d8e2b01dc1077d7

0 个答案:

没有答案