https://github.com/frejs/fre-ie
Make Fre work in IE8+ (NOT IE7)
https://github.com/frejs/fre-ie
Last synced: 8 months ago
JSON representation
Make Fre work in IE8+ (NOT IE7)
- Host: GitHub
- URL: https://github.com/frejs/fre-ie
- Owner: frejs
- License: mit
- Created: 2020-05-08T10:43:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T05:18:56.000Z (over 3 years ago)
- Last Synced: 2025-04-11T14:57:41.491Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.34 MB
- Stars: 9
- Watchers: 0
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fre ie
> fre + webpack4 + babel7 兼容 IE(IE8+. Not IE7)
### Run
```console
yarn start
```
### Use
```shell
yarn add webpack-ie8-plugin -D
```
```js
const IE8 = require('webpack-ie8-plugin')
plugins: [
...
new IE8() // 配置文件引入 webpack 的 polyfill
]
import 'fre/ie' // 业务入口引入 fre 的 polyfill
```
### 动机
目前主流前端框架都不支持 ie,react16 已经不可能支持 ie8 了,vue 更是想都别想
然而 ie8+ 在国内仍有很高的占有率
fre 代码量非常小,没有用到几个高级 API,所以兼容起来十分简单
### 兼容思路
- webpack 兼容
webpack 最新版本自身不支持 ie8,所以我们要打补丁,幸运的是,webpack4 高级 API 也不多
`Object.defineproperty`、 `Object.create` 、`Function.bind`
- fre 兼容
`Array.forEach`、 `Array.isArray` 、`Array.some`、`Performance.now`
以上是 fre 用到的高级 API,也需要打补丁,幸好也不多
- text 的处理
重写 createTextNode 为 `x-text`,然后将 textContent 改为 `innerText`
- 模拟事件
主要是对 addEventListener 和 removeEventListener 的模拟
### 不足
- 不能使用 webpack-dev-server
由于 ie8 并不支持 webSocket(webpack 是 eventSource),所以基本上所有的通信插件都用不了
- 没有并入 fre 主库
fre2 重构会适当照顾到兼容,达到一个极佳的平衡,然后会放到主库里维护