From 3d7f39f1c3f19b96c1c3de4d9bb16282e27db568 Mon Sep 17 00:00:00 2001 From: kongjiacong Date: Tue, 10 Dec 2024 14:18:10 +0800 Subject: [PATCH] docs: add changeset --- .changeset/eleven-otters-cry.md | 7 +++++++ .../document/main-doc/docs/en/configure/app/server/ssr.mdx | 2 -- .../document/main-doc/docs/zh/configure/app/server/ssr.mdx | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changeset/eleven-otters-cry.md diff --git a/.changeset/eleven-otters-cry.md b/.changeset/eleven-otters-cry.md new file mode 100644 index 000000000000..dc0db5b93744 --- /dev/null +++ b/.changeset/eleven-otters-cry.md @@ -0,0 +1,7 @@ +--- +'@modern-js/runtime': patch +'@modern-js/server-core': patch +--- + +feat: add server.useJsonScript , for instead ssr.inlineScript +feat: 添加 server.useJsonScript 配置,代替 ssr.inlineScript diff --git a/packages/document/main-doc/docs/en/configure/app/server/ssr.mdx b/packages/document/main-doc/docs/en/configure/app/server/ssr.mdx index 0e80b84b492a..d476d107cd09 100644 --- a/packages/document/main-doc/docs/en/configure/app/server/ssr.mdx +++ b/packages/document/main-doc/docs/en/configure/app/server/ssr.mdx @@ -29,7 +29,6 @@ When the value type is `Object`, the following properties can be configured: | ---------------- | ------------------------------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------- | | mode | `string` | `string` | which defaults to using `renderToString` for rendering. Configure `stream` to enable streaming rendering | | forceCSR | `boolean` | `false` | which is off by default for forcing CSR rendering. Configure `true` to force CSR by adding `?csr=true` or adding `x-modern-ssr-fallback` header when accessing the page | -| inlineScript | `boolean` | `true` | By default, SSR data is injected into HTML as inline scripts and assigned directly to global variables. Configure `false` to distribute JSON instead of assigning to global variables, this configuration doesn't work in Streaming SSR | | disablePrerender | `boolean` | `fasle` | To ensure compatibility with the old data request method (`useLoader`), by default, Modern.js performs pre-rendering of components.However, if developers want to reduce one rendering when there is no use of the useLoader API in your project, you can set the configuration `disablePrerender=true` | | unsafeHeaders | `string[]` | `[]` | For safety reasons, Modern.js does not add excessive content to SSR_DATA. Developers can use this configuration to specify the headers that need to be injected | | scriptLoading | `defer \| blocking \| module \| async` | `defer` | The configuration is the same as [html.scriptLoading](/configure/app/html/script-loading), supporting SSR injected script set to `async` loading. The priority is `ssr.scriptLoading` > `html.scriptLoading` | @@ -42,7 +41,6 @@ export default defineConfig({ ssr: { forceCSR: true, mode: 'stream', - inlineScript: false, unsafeHeaders: ['User-Agent'], scriptLoading: 'async', }, diff --git a/packages/document/main-doc/docs/zh/configure/app/server/ssr.mdx b/packages/document/main-doc/docs/zh/configure/app/server/ssr.mdx index f6214c70a2c5..bbb007e9a410 100644 --- a/packages/document/main-doc/docs/zh/configure/app/server/ssr.mdx +++ b/packages/document/main-doc/docs/zh/configure/app/server/ssr.mdx @@ -30,7 +30,6 @@ export default defineConfig({ | mode | `string` | `string` | 默认为使用 `renderToString` 渲染。配置为 `stream` 开启流式渲染 | | forceCSR | `boolean` | `false` | 默认关闭强制 CSR 渲染。配置为 `true` 后,在页面访问时添加 `?csr=true` 或添加请求头 `x-modern-ssr-fallback` 即可强制 CSR | | inlineScript | `boolean` | `true` | 默认情况下,SSR 的数据会以内联脚本的方式注入到 HTML 中,并且直接赋值给全局变量。配置为 `false` 后,会下发 JSON,而不是赋值给全局变量,Streaming SSR 下,该配置不会生效 | -| disablePrerender | `boolean` | `fasle` | 为了兼容旧数据请求方式 - `useLoader`, 默认情况下 Modern.js 会对组件进行一次预渲染即有两次渲染 | | unsafeHeaders | `string[]` | `[]` | 为了安全考虑,Modern.js 不会往 SSR_DATA 添加过多的内容。开发者可以通过该配置,对需要注入的 headers 进行配置 | | scriptLoading | `defer \| blocking \| module \| async` | `defer` | 配置同 [html.scriptLoading](/configure/app/html/script-loading),支持 ssr 注入的 script 设置为 async 加载方式。优先级为 `ssr.scriptLoading` > `html.scriptLoading` | | loaderFailureMode| `clientRender \| errorBoundary` | `errorBoundary` | 当 [data loader](/guides/basic-features/data/data-fetch.html#data-loader推荐) 中出错时,默认会渲染路由 [`Error`](/guides/basic-features/routes.html#错误处理) 组件,配置为 `'clientRender'` 时,有一个 data loader 抛错,就降级到客户端渲染,可以与 [Client Loader](/guides/basic-features/data/data-fetch.html#client-loader) 配合使用 | @@ -43,7 +42,6 @@ export default defineConfig({ forceCSR: true, mode: 'stream', inlineScript: false, - disablePrerender: true, unsafeHeaders: ['User-Agent'], scriptLoading: 'async', },