Skip to content

Commit

Permalink
Merge pull request umijs#658 from wuomzfx/feat/plugin-polyfill
Browse files Browse the repository at this point in the history
feat: improve umi-plugin-polyfill, reduce bundle size
  • Loading branch information
sorrycc authored Jun 26, 2018
2 parents eca020f + 52c765f commit 2ebb151
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/umi-plugin-polyfill/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# umi-plugin-polyfill

umi的兼容插件,主要是为了umi兼容ie而创建的,所以现在内置了babel/polyfill和setprototypeof和window.NodeList,处理在ie下的兼容,但考虑到后续的扩展和可能存在的其他兼容问题,增加了extend配置。
umi的兼容插件,主要是为了umi兼容ie而创建的,所以现在内置了react在ie下所需要的polyfill和setprototypeof和window.NodeList,处理在ie下的兼容,但考虑到后续的扩展和可能存在的其他兼容问题,增加了extend配置。

经测试,在IE9下能语法兼容。
测试发现一个问题:ie9 antd 中的输入框无法输入(antd的iss里面已经有人提了)
Expand Down
1 change: 1 addition & 0 deletions packages/umi-plugin-polyfill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"@babel/polyfill": "7.0.0-beta.46",
"assert": "1.4.1",
"raf": "3.4.0",
"setprototypeof": "1.1.0"
}
}
15 changes: 13 additions & 2 deletions packages/umi-plugin-polyfill/src/global.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import '@babel/polyfill';
import 'core-js/fn/array/for-each';
/**
* 此polyfill仅支持IE9+,因为umi部分底层库版本如react、prop-types版本已经不支持IE8。
*/

// UMI depends on promise
import "core-js/es6/promise";
// React depends on set/map/requestAnimationFrame
// https://reactjs.org/docs/javascript-environment-requirements.html
import "core-js/es6/set";
import "core-js/es6/map";
import "raf/polyfill";

// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
// import 'classlist.js'; // Run `npm install --save classlist.js`.

Expand All @@ -8,6 +18,7 @@ Object.setPrototypeOf = require('setprototypeof');

//https://github.com/ant-design/ant-design/issues/9876
if (window.NodeList && !NodeList.prototype.forEach) {
// forEach IE9 已经支持,无须加polyfill
NodeList.prototype.forEach = function(callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
Expand Down

0 comments on commit 2ebb151

Please sign in to comment.