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

feat: fastRefresh support anonymous default export function #6211

Merged
merged 15 commits into from
Mar 9, 2021

Conversation

ycjcl868
Copy link
Contributor

@ycjcl868 ycjcl868 commented Mar 4, 2021

kap

ref:

Checklist
  • npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

View rendered docs/docs/fast-refresh.md
View rendered docs/docs/fast-refresh.zh-CN.md

@ycjcl868 ycjcl868 changed the title feat(fastRefresh): support anonymous function [WIP] feat(fastRefresh): support anonymous function Mar 4, 2021
@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #6211 (443e94d) into master (b0bd3c3) will increase coverage by 0.05%.
The diff coverage is 87.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6211      +/-   ##
==========================================
+ Coverage   84.40%   84.45%   +0.05%     
==========================================
  Files         153      154       +1     
  Lines        3470     3507      +37     
  Branches      942      952      +10     
==========================================
+ Hits         2929     2962      +33     
- Misses        531      535       +4     
  Partials       10       10              
Impacted Files Coverage Δ
...ackages/bundler-webpack/src/getConfig/getConfig.ts 84.81% <0.00%> (ø)
...reset-built-in/src/plugins/features/fastRefresh.ts 42.85% <25.00%> (-4.21%) ⬇️
...el-plugin-no-anonymous-default-export/src/index.ts 96.87% <96.87%> (ø)
packages/babel-preset-umi/src/index.ts 86.95% <100.00%> (+0.59%) ⬆️
...set-built-in/src/plugins/commands/buildDevUtils.ts 78.57% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0bd3c3...443e94d. Read the comment docs.

@ycjcl868 ycjcl868 changed the title [WIP] feat(fastRefresh): support anonymous function feat(fastRefresh): support anonymous function Mar 5, 2021
@sorrycc
Copy link
Member

sorrycc commented Mar 6, 2021

  1. babel 插件和其他 babel 插件一样,提一个单独的 npm 包到最外层,通过 @umijs/babel-preset-umi 露出
  2. 加下 babel 插件的测试用例,场景太多了
  3. 考虑 hoc,比如 export default connect(mapStateToProps)(() => {});,或者更多层级的高阶函数导出
  4. 非 export default 导出的函数需要加名字吗?
  5. next.js 的实现在哪?加个 ref 看下

@ycjcl868
Copy link
Contributor Author

ycjcl868 commented Mar 6, 2021

  1. babel 插件和其他 babel 插件一样,提一个单独的 npm 包到最外层,通过 @umijs/babel-preset-umi 露出

  2. 加下 babel 插件的测试用例,场景太多了

  3. 考虑 hoc,比如 export default connect(mapStateToProps)(() => {});,或者更多层级的高阶函数导出

  4. 非 export default 导出的函数需要加名字吗?

  5. next.js 的实现在哪?加个 ref 看下

1、单独 npm 会有问题,这样 fast refresh 功能需要两个 babel 插件并且是有顺序的(babel-plugin-modify-anonymous + react-refresh/babel
2、ok
3、Fast Refresh 不支持 HOC,试了下改名也没用
4、不需要加名字,只针对 export default 的匿名函数
5、next.js 只是 warning,不会修改

@ycjcl868 ycjcl868 closed this Mar 6, 2021
@ycjcl868 ycjcl868 reopened this Mar 6, 2021
@sorrycc
Copy link
Member

sorrycc commented Mar 7, 2021

单独 npm 会有问题

可以两个都放过去。

Fast Refresh 不支持 HOC,试了下改名也没用

是 fast refresh 本身声明不支持还是我们使用方式的问题?

不需要加名字,只针对 export default 的匿名函数

非 export default 是不支持还是不需要加?

@ycjcl868
Copy link
Contributor Author

ycjcl868 commented Mar 7, 2021

单独 npm 会有问题

可以两个都放过去。

Fast Refresh 不支持 HOC,试了下改名也没用

是 fast refresh 本身声明不支持还是我们使用方式的问题?

不需要加名字,只针对 export default 的匿名函数

非 export default 是不支持还是不需要加?

非 export default 是不需要加

@ycjcl868 ycjcl868 requested a review from sorrycc March 8, 2021 03:55
@sorrycc sorrycc changed the title feat(fastRefresh): support anonymous function feat: fastRefresh support anonymous function Mar 8, 2021
@sorrycc sorrycc changed the title feat: fastRefresh support anonymous function feat: fastRefresh support anonymous default export Mar 8, 2021
@sorrycc sorrycc changed the title feat: fastRefresh support anonymous default export feat: fastRefresh support anonymous default export function Mar 8, 2021
@ycjcl868
Copy link
Contributor Author

ycjcl868 commented Mar 8, 2021

ping @sorrycc

@sorrycc
Copy link
Member

sorrycc commented Mar 9, 2021

解下冲突。

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

Successfully merging this pull request may close these issues.

2 participants