17

babel をアップグレードしましたが、 Webpack6.x → 7.xの実行に問題があります。

行方不明について不平を言っていcore-js/modules/*ます。

babel.config.jsはルートディレクトリにあります。以前の既存の.babelrcものをjsに変換しました(.babelrc同じエラーも発生しました)。私はそれがすべてのコア、corejs2ランタイムのものとの衝突であると推測しています。

私の src には、mine と Styleguidist ( 内./node_modules) の 2 つのアプリがあります。私のアプリはこれらと同じpackage.json/babel.configでトランスパイルして動作しますが、Styleguidist は動作しません。


webpack で Styleguidist を実行すると、次のエラーが発生します。

Module not found: Error: Can't resolve 'core-js/modules/es.array.concat' in '/project/src/node_modules/react-styleguidist/lib/client/rsg-components/Slot'

/node_modules/react-styleguidist/lib/client/rsg-components/Slot.js:

import "core-js/modules/es.array.concat";
import "core-js/modules/es.array.filter";
...

パッケージ.json

"dependencies": {
    "@babel/polyfill": "^7.0.0",
    "@babel/runtime-corejs2": "^7.4.3",
}
"devDependencies": {
    "@babel/core": "^7.4.3",
    "@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.4.3",
    "@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-syntax-jsx": "^7.0.0",
    "@babel/plugin-transform-modules-commonjs": "^7.4.3",
    "@babel/plugin-transform-react-jsx": "^7.3.0",
    "@babel/plugin-transform-runtime": "^7.4.3",
    "@babel/preset-env": "^7.4.3",
    "@babel/register": "^7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-jest": "^24.7.1",
    "babel-loader": "^8.0.0",
    "babel-plugin-dynamic-import-node": "^2.2.0",
    "babel-plugin-transform-vue-jsx": "^4.0.1",
}

babel.config.js

module.exports = {
    presets: ['@babel/preset-env'],
    plugins: [
        '@babel/plugin-transform-runtime',
        '@babel/plugin-transform-react-jsx',
        'transform-vue-jsx',
        "@babel/plugin-proposal-object-rest-spread",
        "@babel/plugin-syntax-dynamic-import",
        "@babel/plugin-syntax-import-meta",
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-json-strings",
        [
            "@babel/plugin-proposal-decorators",
            {
                "legacy": true
            }
        ],
        "@babel/plugin-proposal-function-sent",
        "@babel/plugin-proposal-export-namespace-from",
        "@babel/plugin-proposal-numeric-separator",
        "@babel/plugin-proposal-throw-expressions"],
    comments: false
}
4

3 に答える 3

3

I had the same issue and as often happens I forgot to have another package installed as:

"@babel/runtime-corejs3": "^7.5.5",

Don't forgot to install it at same level where you have the issue(either dev, local or production) level:

 npm i -D(or --save-dev) @babel/runtime-corejs3

So in general this kind of errors happens when there are dependencies update change significantly in the version and aren't backward compatible with previous versions. Indeed corejs3 isn't at all compatible with corejs2 or older.

于 2019-08-31T15:20:00.097 に答える