在我正在编写的这个react-static应用程序中,我注意到上述错误仅发生在 IE11 及以下版本上。它发生在我项目的一些依赖项上,而不是我自己编写的代码上(我正在用 .polly 填充整个应用程序@babel/polyfill
)。所以,我非常确信我没有任何问题。
这让我觉得我也应该@babel/polyfill
依赖依赖,对吗?如果是这样,我该怎么做?
我的 。babelrc
文件:
{
"presets": [
"react-static/babel-preset.js",
["@babel/preset-env", {
"useBuiltIns": "entry",
"debug": true,
"targets": {
"ie": "11"
}
}],
],
"plugins": [
"@babel/transform-runtime",
"@babel/plugin-proposal-class-properties",
"babel-plugin-styled-components",
["minify-dead-code-elimination", { "optimizeRawSize": true }],
[
"module-resolver",
{
"cwd": "babelrc",
"root": ["./src/"],
"extensions": [".jsx", ".js"],
"alias": {
"images": "./public/assets/images"
}
}
]
],
"env": {
"production": {
"plugins": ["transform-remove-console"]
},
"development": {
"plugins": ["@babel/transform-react-jsx-source"]
}
}
}
我的package.json
文件:
{
"name": "react-static-example-blank",
"private": true,
"license": "MIT",
"scripts": {
"start": "react-static start --debug --verbose",
"stage": "react-static build --staging",
"build": "react-static build",
"serve": "serve dist -p 3001 -s"
},
"dependencies": {
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-hot-loader": "^4.3.12",
"react-static": "^6.0.18",
"styled-components": "^4.1.3",
"@fortawesome/fontawesome-svg-core": "^1.2.0-14",
"@fortawesome/free-brands-svg-icons": "^5.1.0-11",
"@fortawesome/free-solid-svg-icons": "^5.1.0-11",
"@fortawesome/react-fontawesome": "^0.1.1",
"@babel/polyfill": "^7.2.5",
"core-js": "2.6.3"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-eslint": "^9.0.0",
"babel-plugin-minify-dead-code-elimination": "^0.4.3",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-styled-components": "^1.10.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^5.12.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-import-resolver-babel-module": "^5.0.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.0",
"eslint-plugin-react": "^7.12.4",
"eslint-config-react-tools": "1.1.6",
"react-devtools": "^3.6.0",
"serve": "^10.1.1"
}
}