Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug] MFSU x Valtio 报错 #10560

Closed
sorrycc opened this issue Feb 21, 2023 · 5 comments
Closed

[Bug] MFSU x Valtio 报错 #10560

sorrycc opened this issue Feb 21, 2023 · 5 comments
Assignees

Comments

@sorrycc
Copy link
Member

sorrycc commented Feb 21, 2023

复现步骤:

1、git clone umijs/umi 后切换到 sorrycc-14dt 分支(如果这个分支没了,那应该是已合并到 master)
2、修改 ui/.umirc.ts,删除 mfsu: false
3、执行 pnpm --filter @umijs/ui dev,报错如下

image

期望:

不报错。

@stormslowly
Copy link
Member

stormslowly commented Feb 23, 2023

https://github.com/umijs/umi/blob/master/packages/mfsu/src/babelPlugins/awaitImport/checkMatch.ts#L11-L16

valito 的位置 packages 之外,所以就认定成项目依赖, 然后就 React 多实例了。

解法 1

把 libs 也放进 isUmiLocalDev (PR) or 把 valito 目录 挪进 packages PR

解法 2(临时)

mfsu: { shared : {react: { singleton: true , strictVersion: false}}}

@fz6m
Copy link
Contributor

fz6m commented Feb 24, 2023

mfsu 可以默认配置 react singleton true 吗,因为 react 必然要是单实例的。

@stormslowly
Copy link
Member

react 就需要两边都编译 有一定的性能损耗

@fz6m
Copy link
Contributor

fz6m commented Feb 24, 2023

react 只有 10kb ,相比损耗貌似出现这个问题的概率要大一些。

@stormslowly
Copy link
Member

可以考虑 benchmark 看下 决定搞不搞

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants