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

umi-plugin-local 为 <= ie9 自动处理 Intl 补丁 #1151

Closed
xiaohuoni opened this issue Sep 28, 2018 · 6 comments
Closed

umi-plugin-local 为 <= ie9 自动处理 Intl 补丁 #1151

xiaohuoni opened this issue Sep 28, 2018 · 6 comments

Comments

@xiaohuoni
Copy link
Member

重现步骤

umi配置

export default {
  plugins: [
    ['umi-plugin-react', {
      routes: {
        exclude: [
          /exclude/,
        ],
      },
      dva:true,
      antd: true,
      polyfills: ["ie9"],
      locale: {
          enable: true, // default false
          default: 'zh-CN', // default zh-CN
          baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
      },
    }],
  ],
}

约定目录

├── /locales/   
│ ├── zh-CN.js   
│ └── en-US.js    

如果在ie9-10上出现

[React Intl] The `Intl` APIs must be available in the runtime, and do not appear to be built-in. An `Intl` polyfill should be loaded.

最新的兼容方案是放到了target 里面了,考虑到umi的版本更新时间和线上项目暂时稳定为主,不适合跟进升级测试版本,所以可以简单的使用一下的方法处理一下。

临时解决方案

yarn add intl

src/global.js

import 'intl'

另外使用antd-pro的朋友,如果出现find方法错误的,
可以在src/global.js增加

import 'core-js/es6/array';
@xiaohuoni
Copy link
Member Author

#1146
#993
ant-design/ant-design-pro#2422
ant-design/ant-design-pro#2297
ant-design/ant-design-pro#2149

@xiaohuoni
Copy link
Member Author

@sorrycc
Copy link
Member

sorrycc commented Sep 28, 2018

我觉得应该在 umi-plugin-local 里检测 targets 配置,如果 targets.ie <= 10,则自动加上补丁。 @yutingzhao1991

@yutingzhao1991
Copy link
Contributor

targets 如果加上了就会有 polyfills 这个问题就应该解决了吧,umi-plugin-local 好像不需要再打补丁。

@xiaohuoni
Copy link
Member Author

intl不在babel里面

@sorrycc
Copy link
Member

sorrycc commented Sep 29, 2018

  1. intl 不在 ecma 标准里, babel 不包含
  2. 用户没有用 umi-plugin-locale,通常是不需要 intl 的补丁的,不应该加上

@sorrycc sorrycc changed the title 关于'Intl'错误的重现步骤及临时解决方案 umi-plugin-local 为 <= ie9 自动处理 Intl 补丁 Oct 12, 2018
xiaohuoni added a commit that referenced this issue Oct 13, 2018
Close: #1151
@xiaohuoni xiaohuoni mentioned this issue Oct 13, 2018
sorrycc pushed a commit that referenced this issue Oct 14, 2018
* add intl
Close: #1151

* fix targets

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

No branches or pull requests

3 participants