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 hmrGuardian 的功能 #931

Closed
sorrycc opened this issue Mar 5, 2024 · 0 comments
Closed

实现类 umi hmrGuardian 的功能 #931

sorrycc opened this issue Mar 5, 2024 · 0 comments
Assignees

Comments

@sorrycc
Copy link
Member

sorrycc commented Mar 5, 2024

背景

React 的 Fast Refresh 热更功能对于匿名函数是不生效的,所以需要自动为响应的匿名函数增加命名。

实现

1、如果 #923 没有合并,提 pr 到 refact/build,否则提 pr 到 master
2、在 crates/mako/src/visitors 下新增 hmr_default_rename.rs,功能实现参考 https://github.com/umijs/umi/blob/master/packages/preset-umi/src/features/hmrGuardian/babelPlugin.ts

比如。

export default function() {} 

   ↓ ↓ ↓ ↓ ↓

export default function ComponentB() {}

参考:
https://github.com/umijs/umi/tree/master/packages/preset-umi/src/features/hmrGuardian

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

2 participants