-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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(helmet): support to disable react-helmet-async to reduce size #10633
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Size Change: +30.5 kB (0%) Total Size: 9.62 MB
ℹ️ View Unchanged
|
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #10633 +/- ##
==========================================
- Coverage 28.98% 28.98% -0.01%
==========================================
Files 453 458 +5
Lines 13461 13615 +154
Branches 3168 3187 +19
==========================================
+ Hits 3902 3946 +44
- Misses 8890 8993 +103
- Partials 669 676 +7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
import React, { type FC, type ReactNode } from 'react'; | ||
|
||
// fake provider for renderer-react | ||
export const HelmetProvider: FC<{ children: ReactNode }> = (props) => ( |
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.
这个文件要不要放到 @umijs/renderer-react
里,preset-umi
有直接依赖,这样所有浏览器里的都在一起清真一点。
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.
感觉有点绕,不是 helmet: false 时不加入 helmet 的 provider 吗?
那样要把 render-react 都处理成 tpl file,实现成本会高很多 |
这样呢?renderer-react 里只 reexport Helmet 和 HelmetProvider,然后 umi tpl 里判断 config.helmet 然后决定是否套一个 HelmetProvider。 |
已换成 |
配置
react-helmet-async
的集成,当设置为false
时,不会集成react-helmet-async
,此时无法从框架中import { Helmet }
使用,同时构建产物也会减少相应的尺寸两个注意点:
src/client
是编译到dist/client
而不是其他包的client/client
,在合理性和一致性中选择了前者,看看要不要改helmet: false
禁用,存在反逻辑(先 alias 指向空组件插件再去掉 alias),但相对于disableHelmet: true
和helmet: { disable: false }
,对用户来说更简单