[英]My react app not running in IE11 after migrated Webpack from v4 to v5
我按照 webpack 文檔更改了我的應用程序的配置: https ://webpack.js.org/migrate/5/。 此后,該應用程序在 chrome 和 edge 上成功運行,但在 IE11 中無法運行。
我有一個 .browserslistrc 文件,里面有 IE11,也改變了target: ['web', 'es5']
,然后添加import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';
import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';
到 src/index.js 但問題仍然存在。 我使用以下 babel 配置:
"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"
]
}
經過大量調查,我發現了這一點:
https://github.com/feross/buffer/commit/840160f352ff0d8e88d4ac308a1640fd278f50fc
所以我的問題的解決方案是配置 babel-loader 來轉譯這個包:
{
test: /\.js$/,
include: [
path.join(__dirname, 'src'),
path.join(__dirname, 'node_modules/buffer'),
],
loader: 'babel-loader',
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.