itsource

추적: 노드 유형 SpreadProperty의 이름이 Object.isSpreadProperty에서 SpreadElement로 변경되었습니다.

mycopycode 2023. 3. 8. 21:11
반응형

추적: 노드 유형 SpreadProperty의 이름이 Object.isSpreadProperty에서 SpreadElement로 변경되었습니다.

리액트 앱을 기동하고 있습니다.웹팩 구성은 다음과 같습니다.

'use strict'

const ExtractPlugin = require('extract-text-webpack-plugin')
const HTMLPlugin = require('html-webpack-plugin')
module.exports = {
    devtool: 'eval',
    entry: `${__dirname}/src/main.js`,
    output: {
        filename: 'bundle-[hash].js',
        path: `${__dirname}/build`,
        publicPath: '/',
    },
    mode: 'development',
    performance: {
        hints: false
    },
    plugins: [
        new HTMLPlugin(),
        new ExtractPlugin('bundle-[hash].css'),
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_module/,
                loader: 'babel-loader',
            },
            {
                test: /\.scss$/,
                loader: ExtractPlugin.extract(['css-loader', 'sass-loader']),
            },
        ],
    },
}

그럼, 소포가 있어요.json 파일, 의존관계는 다음과 같습니다.

"devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-react": "^7.0.0",
    "and": "0.0.3",
    "babel-cli": "^6.26.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-loader": "^8.0.4",
    "eslint": "^5.9.0",
    "install": "^0.12.2",
    "jest": "^23.6.0",
    "npm": "^6.4.1",
    "webpack-cli": "^3.1.2"
  },
  "dependencies": {
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "css-loader": "^1.0.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.11.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "resolve-url-loader": "^3.0.0",
    "sass-loader": "^7.1.0",
    "webpack": "^4.25.1",
    "webpack-dev-server": "^3.1.10"
  } 

7번째 버전까지 babel 패키지를 업데이트하거나 babelrc 설정을 변경하는 등 여러 가지 방법을 시도해 보았습니다.

프로젝트는 컴파일되지만 컴파일 시작 시 다음과 같은 메시지가 나타납니다.

추적: 노드 유형 SpreadProperty의 이름이 Object.isSpreadProperty에서 SpreadElement로 변경되었습니다.

그리고 그와 같은 행이 100개 정도 됩니다.모든 행이 인쇄된 후 컴파일 프로세스가 진행되어 정상적으로 완료됩니다.

저건 뭐죠? 이 행은 어떻게 없앨 수 있나요?

여기 문제를 해결한 마지막 설정이 있습니다.

.babelrc

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-proposal-object-rest-spread"
  ]
}

이해를 돕기 위해, 여기 제 소포가 있습니다.json의 DevDependency:

"devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-transform-object-assign": "^7.0.0",
    "@babel/plugin-transform-react-jsx": "^7.1.6",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "8.0.4",
    "prop-types": "15.6.2",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "style-loader": "^0.23.1",
    "utils": "^0.3.1",
    "webpack": "4.26.1",
    "webpack-cli": "3.1.2",
    "webpack-dev-server": "^3.1.10"
  }

Webpack.config.js 모듈의 섹션은 다음과 같습니다.

module: {
        rules: [
            {
                test: /\.(js|jsx)$/ ,
                exclude: /node_modules/,
                loaders: "babel-loader"
            }
        ]
    }

이 문제는 오래된 사용으로 인해 발생합니다.

`"babel-plugin-transform-object-rest-spread"`

이것을 패키지로 갱신합니다.json

`"@babel/plugin-proposal-object-rest-spread": "^7.0.0",`

이 경우 .babelrc.filename 파일을 갱신합니다.

const isTest = String(process.env.NODE_ENV) === 'test'
module.exports = {
  presets: [["@babel/env", { modules: isTest ? 'commonjs' : false }, "@babel/react"]],
  plugins: [
    'syntax-dynamic-import',
    'transform-class-properties',
    '@babel/plugin-proposal-object-rest-spread',
  ],
}

이것은 나의 문제를 해결한다.

내 .babelrc 전에

플러그인을 사용하고 있었습니다.["transform-object-rest-spread", { "useBuiltIns": true }],

그리고 나서 나는 그것을 로."@babel/plugin-proposal-object-rest-spread"그 모든 경고들이 사라졌고, 그건 정말 좋은 일이었어.`

제 경우 웹 팩 설정을 구현하지 않았는데 오류가 발생하였습니다.많은 솔루션을 실장하면, 에러가 같거나, 에러가 삭제되면, 다른 에러가 표시됩니다.마지막으로 삭제했습니다..bablerc,.babelrc그리고.package-lock.json파일 및 실행rm -rf node_modules && npm install그리고 달려갔다.react-native run-android효과가 있었어요. :-)

여기 아무 것도 안 되면 그냥 오래된 바벨에서 플러그 인만 빼면 돼.제 경우, 다음 스프레드 플러그인이 제거되어 버렸습니다.

   plugins: ["transform-object-rest-spread"]

언급URL : https://stackoverflow.com/questions/53326986/trace-the-node-type-spreadproperty-has-been-renamed-to-spreadelement-at-object

반응형