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

fix: page not prerendered should not hydrate #10724

Merged
merged 3 commits into from
Mar 14, 2023

Conversation

MadCcc
Copy link
Contributor

@MadCcc MadCcc commented Mar 10, 2023

Background

当前在 exportStatic 中配置了 prerender: false 的页面仍然会在客户端注水,因为 dom 不匹配会导致 SSR 警告转为 CSR。

比如 antd 官网的 demo 页:https://ant-design.antgroup.com/~demos/components-button-demo-basic

image

Solution

配置了 prerender: false 的页面直接客户端渲染,不走注水逻辑。

@vercel
Copy link

vercel bot commented Mar 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
umi ⬜️ Ignored (Inspect) Mar 13, 2023 at 7:44AM (UTC)

});

api.addRuntimePlugin(() => {
return [withTmpPath({ api, path: 'exportStaticRuntimePlugin.ts' })];
Copy link
Contributor

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'))]

或者把 withTmpPathpreset-umi/src/utils 也 copy 一份。

Copy link
Contributor Author

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@umijs/utils 里导入 Mustache ,这是运行时的写法,在 node 环境不要这么用。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@sorrycc sorrycc merged commit dd19d6b into umijs:master Mar 14, 2023
@github-actions
Copy link

感谢 PR!如果有兴趣一起参与维护 Umi,可加入我们的 Umi Contributor 群。加入方式是先用钉钉扫下方二维码加我钉钉,记得注明 github id,然后我会拉你到群里。

@MadCcc MadCcc deleted the fix/client-render-static-ignored branch March 14, 2023 07:58
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.

4 participants