Umi: 改进 umi/locale 的提示问题

Created on 19 Dec 2018  ·  11Comments  ·  Source: umijs/umi

方案

之前是

import { formatMessage } from 'umi/locale';

直接用 umi-plugin-locale 的情况下,改成

import { formatMessage } from 'umi-plugin-locale';

如果用 umi-plugin-react,则加一层转发,

import { formatMessage } from 'umi-plugin-react/locale';

对用户暴露的是最后一个写法,虽然有点长,但目前没有更好的方案了。

相关

  • #1499
type(enhancement)

Most helpful comment

关于 umi-plugin-react/antd 名字太长,不好看的问题是不是可以在 npm 上面搞一个 scope @umi 然后插件的包都发里面。用法就变成 @umi/react/antd 这样了。

All 11 comments

@leftstick 有没有兴趣实现下?

还有一个问题,是不是 antd 也应用 umi-plugin-react/antd 这样的方式来用,这样项目就不需要安装 antd 了。

是的,antd、dva 等都是这样,可以一起改了。

umi-plugin-react 有点长,后续可以考虑改个名。

@sorrycc 有点慌啊,等大佬动手先,我跟着打酱油^^

我有个问题比较好奇该如何解决,既然.d.ts文件应该由插件umi-plugin-locale自己提供,那它该如何暴露在umi-plugin-react/locale路径下?

umi-plugin-locale/lib/locale模块可以通过修改webpack. alias来提供暴露路径,.d.tspostInstall拷贝到umi-plugin-react下面去?

umi-plugin-react/locale import from umi-plugin-locale 就好了吧。

其实插件什么的 可以考虑用 ts 来开发;
ts 类型约束 来写底层代码很爽的·

关于 umi-plugin-react/antd 名字太长,不好看的问题是不是可以在 npm 上面搞一个 scope @umi 然后插件的包都发里面。用法就变成 @umi/react/antd 这样了。

@umi + 1

突然发现 import { formatMessage } from 'umi-plugin-locale'; 这样也有一个问题,umi-plugin-locale 这个本身其实是已经存在了一个 src/index.js 的,也就是插件本身。理论上可以用一个别名覆盖,但是总觉得怪怪的。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kitebear picture kitebear  ·  3Comments

mizi-lin picture mizi-lin  ·  3Comments

ironyfive picture ironyfive  ·  3Comments

Artoria-0x04 picture Artoria-0x04  ·  3Comments

y2891663091 picture y2891663091  ·  4Comments