Updating React 17 and Webpack 5




In this post, we will see how to upgrade to React 17 and webpack 5

Updating packages

Run the below command,

yarn upgrade [email protected] [email protected]

Next,

yarn upgrade -D @babel/{core,preset-{env,react}}

Next,

yarn add -D @babel/plugin-transform-react-jsx

Go to .babelrc and change the code as below

{
  "presets": [
    "@babel/preset-env",
    ["@babel/preset-react", {
      "runtime": "automatic"
    }]
  ]
}

Updating webpack

yarn upgrade webpack{,-cli} --latest

Change the start script as below

"start": "webpack serve --mode='development'"