Home > Enterprise >  My react app not running in IE11 after migrated Webpack from v4 to v5
My react app not running in IE11 after migrated Webpack from v4 to v5

Time:11-03

I changed the configuration of my app following the webpack documentation: enter image description here

I have a .browserslistrc file with IE11 inside, also changed target: ['web', 'es5'], then add import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable'; to src/index.js but the problem is still there. I use the following babel configuration:

  "presets": [
    [
      "@babel/preset-env", 
      { 
        "useBuiltIns": "entry",
        "corejs": 3
      }
    ],
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-transform-object-assign", 
    "@babel/plugin-proposal-object-rest-spread", 
    "@babel/plugin-transform-regenerator", 
    "@babel/plugin-proposal-class-properties", 
    "@babel/plugin-transform-runtime"
  ]
}

CodePudding user response:

After a lot of investigations I found this:

https://github.com/feross/buffer/commit/840160f352ff0d8e88d4ac308a1640fd278f50fc

So the solution to my problem was to configure babel-loader to transpile this package:

{
    test: /\.js$/,
    include: [
       path.join(__dirname, 'src'),
       path.join(__dirname, 'node_modules/buffer'),
    ],
    loader: 'babel-loader',
}
  • Related