Trace: The node type SpreadProperty has been renamed to SpreadElement at Object.isSpreadProperty

后端 未结 5 834
一整个雨季
一整个雨季 2020-12-17 07:54

I\'m launching a react app, and here\'s my Webpack configuration:

\'use strict\'

const ExtractPlugin = require(\'extract-text-webpack-plugin\')
const HTMLPl         


        
相关标签:
5条回答
  • 2020-12-17 08:19

    Before in my .babelrc

    i was using the plugin: ["transform-object-rest-spread", { "useBuiltIns": true }],

    then i switch it to "@babel/plugin-proposal-object-rest-spread" and all those warnings went away, which has been very nice. `

    0 讨论(0)
  • 2020-12-17 08:19

    In my case, I was not implementing the Webpack configuration and still error was there. After so many solutions implementation, the error was same or once an error was removed another appeared. Finally, I deleted .bablerc, .babelrc and package-lock.json files and ran rm -rf node_modules && npm install and then ran react-native run-android and it worked for me. :-)

    0 讨论(0)
  • 2020-12-17 08:19

    If nothing up here worked, Just remove plugins from old babel. In my case removing following spread plugin had disappeared the thing.

       plugins: ["transform-object-rest-spread"]
    
    0 讨论(0)
  • 2020-12-17 08:25

    This issue is occurring due to using outdated

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

    update this in package.json

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

    and update your .babelrc.js file in my case it looks like this

    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',
      ],
    }
    

    this solves my problem

    0 讨论(0)
  • 2020-12-17 08:39

    here is the final setting that solved problem for me.

    .babelrc

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

    For a better understanding, here is my package.json's devDependencies:

    "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"
      }
    

    Here is my webpack.config.js module's section:

    module: {
            rules: [
                {
                    test: /\.(js|jsx)$/ ,
                    exclude: /node_modules/,
                    loaders: "babel-loader"
                }
            ]
        }
    
    0 讨论(0)
提交回复
热议问题