-
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
fix: page not prerendered should not hydrate #10724
fix: page not prerendered should not hydrate #10724
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
}); | ||
|
||
api.addRuntimePlugin(() => { | ||
return [withTmpPath({ api, path: 'exportStaticRuntimePlugin.ts' })]; |
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.
手拼下,不要这么用 withTmpPath
,就幽灵依赖了:
return [winPath(join(api.paths.absTmpPath, `plugin-${api.plugin.key}` , 'exportStaticRuntimePlugin.ts'))]
或者把 withTmpPath
在 preset-umi/src/utils
也 copy 一份。
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.
done
import { getMarkup } from '@umijs/server'; | ||
import { lodash, logger, winPath } from '@umijs/utils'; | ||
import assert from 'assert'; | ||
import { dirname, join, relative } from 'path'; | ||
import { Mustache } from 'umi/plugin-utils'; |
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/utils
里导入 Mustache
,这是运行时的写法,在 node 环境不要这么用。
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.
done
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.
+1
Background
当前在
exportStatic
中配置了prerender: false
的页面仍然会在客户端注水,因为 dom 不匹配会导致 SSR 警告转为 CSR。比如 antd 官网的 demo 页:https://ant-design.antgroup.com/~demos/components-button-demo-basic
Solution
配置了
prerender: false
的页面直接客户端渲染,不走注水逻辑。