[英]fetch and Headers are undefined in IE11.0.9600 with babel-polyfill when process.env.NODE_ENV=='production'
When process.env.NODE_ENV=='development'
- it is OK! 当
process.env.NODE_ENV=='development'
- 没关系!
But our production build failed in IE 11 (11.0.9600). 但我们的生产版本在IE 11(11.0.9600)中失败了。 All work fine in chrome 55.
铬55都可以正常工作。
devDependencies: devDependencies:
...
babel-core: "6.22.0",
babel-eslint: "^7.0.0",
babel-loader: "^6.2.5",
babel-preset-env: "^1.5.2",
babel-preset-es2015: "^6.16.0",
babel-preset-es2016: "^6.22.0",
babel-preset-es2017: "^6.16.0",
babel-preset-react: "^6.16.0",
babel-preset-stage-0: "^6.22.0"
...
dependencies: 依赖关系:
...
babel-polyfill: "^6.16.0"
...
.babelrc: .babelrc:
{
"presets": [
"react",
["env", {
"useBuiltIns": true
}],
"stage-0"
]
}
Try "useBuiltIns": false
, es2016, es2015, es2017 presets. 尝试
"useBuiltIns": false
,es2016,es2015,es2017预设。 Nothing changes. 没有什么变化。
index.js: index.js:
"use strict";
import 'babel-polyfill'
...
webpack.config module.exports.entry: webpack.config module.exports.entry:
vendor: ['babel-polyfill', 'immutable', 'react', 'react-dom', ...],
...
bundle: [path.resolve(__dirname, srcPath + ""index.js)]
vendor is the first script in index.html. vendor是index.html中的第一个脚本。
Typing _babelPolyfill in ie console return true. 在控制台中键入_babelPolyfill返回true。 But Headers, fetch are undefined...
但是Headers,fetch是未定义的......
Why process.env.NODE_ENV=='production'
broke my app in IE11? 为什么
process.env.NODE_ENV=='production'
在IE11中破坏了我的应用程序? How to fix my config? 如何修复我的配置?
core.js do not have polyfill for Headers() and fetch, so babel-polyfill don't. core.js没有针对Headers()和fetch的polyfill,所以babel-polyfill没有。 Use one of fetch polyfills:
使用其中一个fetch polyfill:
For more info: 欲了解更多信息:
https://github.com/zloirock/core-js https://github.com/zloirock/core-js
What is the difference between isomorphic-fetch and fetch? isomorphic-fetch和fetch有什么区别?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.