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
refactor: more cache #45302
refactor: more cache #45302
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没看出是怎么优化缓存命中性能的,@zombieJ ,可以解释一下实现思路吗?
size-limit report 📦
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
有没有可测的 ci 性能数据? |
CPU 时间片是不稳定的,~10ms 的变化机器卡一卡就会超。 |
如果要加测试,可以加组件加载卸载,token 执行次数 |
嗯。不过这样要给 token 对象合成加钩子,打包的时候会留脏的空函数。不太建议为了测试,加这个损耗。 |
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #45302 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 692 692
Lines 11670 11671 +1
Branches 3117 3117
=========================================
+ Hits 11670 11671 +1
☔ View full report in Codecov by Sentry. |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
resolve #45296
💡 Background and solution
在组件渲染时都会经过 CSS-in-JS 的 flatten token 逻辑,原实现为
useMemo
缓存,但是对于重新创建的 Node 而言,memo 总是会重新生成。而对于 CSS-in-JS 而言,相同 token 一定出相同的 flatten key,所以在跨组件之间可以复用v4
Before
After
📝 Changelog
☑️ Self-Check before Merge
🚀 Summary
🤖 Generated by Copilot at 2142bb3
The pull request enhances the design token system of the
ConfigProvider
component and its related hooks and types. It introduces a newoverride
prop that allows users to specify both alias tokens and component-specific tokens in one object. It also improves the code readability and consistency by refactoring some imports and types.🔍 Walkthrough
🤖 Generated by Copilot at 2142bb3
override
prop toDesignTokenProviderProps
anddefaultConfig
to support customizing design tokens and component-specific tokens (link, link, link)token
prop inConfigProvider
by extractingmergedToken
constant and passing it tooverride
prop (link)index.tsx
anduseToken.ts
to group related modules and follow alphabetical order (link, link)