Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial-state 插件引起的兼容性问题 #98

Open
sorrycc opened this issue Mar 17, 2020 · 4 comments
Open

initial-state 插件引起的兼容性问题 #98

sorrycc opened this issue Mar 17, 2020 · 4 comments
Assignees

Comments

@sorrycc
Copy link
Member

sorrycc commented Mar 17, 2020

复现步骤,

  1. yarn create @umijs/umi-app
  2. 安装依赖
  3. 配置 targets 为 { ie: 9 }
  4. COMPRESS=none yarn build,不压缩构建
  5. serve ./dist
  6. 在 IE9 中打开,报错

image

禁用 initialState 后正常,

  1. 配置 initialState: false
  2. 重复前面的 4-6 步骤,正常

image

@ttys026 ttys026 self-assigned this Mar 17, 2020
@ttys026
Copy link
Contributor

ttys026 commented Mar 17, 2020

会不会是 polyfill 有些问题,我这边配置 targets 为 { ie: 11 } 之后,可以在 IE 9 里跑了

@sorrycc
Copy link
Member Author

sorrycc commented Mar 19, 2020

排查过程

仔细排查了下,发现和 plugin-model 依赖的 lodash.isequal 有关,他里面有这么一段,

if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
    (Map && getTag(new Map) != mapTag) ||
    (Promise && getTag(Promise.resolve()) != promiseTag) ||
    (Set && getTag(new Set) != setTag) ||
    (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  // ..
}

其中 new ArrayBuffer(1) 会报错,猜测原因可能是 1) polyfill 有问题 2) ie9 本身对于 ArrayBuffer 的处理问题。

他们引入的补丁方案差异如下,

// ie9
es.array-buffer.constructor { "edge":"13", "ie":"9", "ios":"10", "safari":"10" }
es.array-buffer.is-view { "ie":"9" }
es.array-buffer.slice { "ie":"9", "ios":"10", "safari":"10" }

// ie11
es.array-buffer.constructor { "edge":"13", "ie":"11", "ios":"10", "safari":"10" }
es.array-buffer.slice { "ios":"10", "safari":"10" }

ie9 多一个 is-view 的实现,但看起来不是关键问题。

建议方案

lodash.isequal 实现太复杂了,尺寸也大,有 50K 左右,换个方案吧。

@without-yy
Copy link

请问这个问题什么时候可以解决

@quicklearning123
Copy link

排查过程

仔细排查了下,发现和 plugin-model 依赖的 lodash.isequal 有关,他里面有这么一段,

if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
    (Map && getTag(new Map) != mapTag) ||
    (Promise && getTag(Promise.resolve()) != promiseTag) ||
    (Set && getTag(new Set) != setTag) ||
    (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  // ..
}

其中 new ArrayBuffer(1) 会报错,猜测原因可能是 1) polyfill 有问题 2) ie9 本身对于 ArrayBuffer 的处理问题。

他们引入的补丁方案差异如下,

// ie9
es.array-buffer.constructor { "edge":"13", "ie":"9", "ios":"10", "safari":"10" }
es.array-buffer.is-view { "ie":"9" }
es.array-buffer.slice { "ie":"9", "ios":"10", "safari":"10" }

// ie11
es.array-buffer.constructor { "edge":"13", "ie":"11", "ios":"10", "safari":"10" }
es.array-buffer.slice { "ios":"10", "safari":"10" }

ie9 多一个 is-view 的实现,但看起来不是关键问题。

建议方案

lodash.isequal 实现太复杂了,尺寸也大,有 50K 左右,换个方案吧。

@sorrycc 请问下有解决方案吗? 升级到哪个plugin-model版本能解决呢?我们急需支持IE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants