突然在 webpack 构建上从运行时 corejs3 中解决错误



我使用这个设置已经有一段时间了。我有时也会遇到类似的错误,但我可以通过删除版本上的^来修复。然而,这一次似乎不起作用。我不能再构建这个项目了。

错误列表。它显示了他们所有人的类似错误。奇怪的是,当我没有更新任何内容并尝试重建时,它突然发生了。

ERROR in ./node_modules/core-js-pure/modules/es.array.splice.js
Module not found: Error: Can't resolve '../internals/array-species-create' in '/var/www/xx.ca/app/node_modules/core-js-pure/modules'
ERROR in ./node_modules/core-js-pure/modules/es.array.flat.js
Module not found: Error: Can't resolve '../internals/array-species-create' in '/var/www/xxx.ca/app/node_modules/core-js-pure/modules'
ERROR in ./node_modules/core-js-pure/internals/get-iterator.js
Module not found: Error: Can't resolve '../internals/an-object' in '/var/www/xxx.ca/app/node_modules/core-js-pure/internals'

我在入口点文件中添加了核心js/stable和再生器运行时

import 'core-js/stable'
import 'regenerator-runtime/runtime'

我的babel.js是这样的。

{
"presets": [
"@babel/preset-react",
["@babel/preset-env", {
"useBuiltIns": "usage",
"corejs": 3,
"targets": {
"ie": "11"
}
}]
],
"plugins": [
"react-hot-loader/babel",
"@babel/plugin-transform-arrow-functions",
"@babel/plugin-transform-spread",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
[
"babel-plugin-webpack-alias",
{
"config": "${PWD}/config/aliases/aliases.config.js"
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
["@babel/transform-runtime", {
"corejs": 3
}],
"react-imported-component/babel",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
]
}

这是我现在使用的版本

"@babel/core": "7.6.2",
"@babel/register": "7.6.2",
"@babel/runtime-corejs3": "7.6.2",
"@babel/polyfill": "^7.0.0",
"@babel/core": "7.6.2",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/plugin-transform-spread": "^7.6.2",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.6.2",
"core-js": "3.2.1",

我刚刚通过删除一些部分并添加新插件来解决这个问题。

我删除了

import 'regenerator-runtime/runtime' 

从入口点

并添加

"@babel/plugin-transform-runtime",

我仍然不知道它是怎么坏的,因为什么都没有改变。

相关内容

最新更新