@modern-js/main-doc 0.0.0-nightly-20240923170640 → 0.0.0-nightly-20240925070419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,28 +153,9 @@ The `--config` parameter needs to use a JSON string.
153
153
  pnpm does not support the use of JSON strings as parameter values currently. Use `npm new` to turn on.【[Relate Issue](https://github.com/pnpm/pnpm/issues/3876)】
154
154
  :::
155
155
 
156
- ## modern serve
156
+ import ServeCommand from "@site-docs-en/components/serve-command";
157
157
 
158
- The `modern serve` command is used to start a Modern.js project in the production environment. It can also be used to preview the artifacts built for the production environment locally. Please note that you need to execute the [`build`](/apis/app/commands#modern-build) command beforehand to generate the corresponding artifacts.
159
-
160
- ```bash
161
- Usage: modern serve [options]
162
-
163
- Options:
164
- -c --config <config> specify the configuration file, which can be a relative or absolute path
165
- -h, --help show command help
166
- --api-only only run API service
167
- ```
168
-
169
- By default, the project will run in `localhost:8080`, you can modify the server port number with `server.port`:
170
-
171
- ```js
172
- export default defineConfig({
173
- server: {
174
- port: 8081,
175
- },
176
- });
177
- ```
158
+ <ServeCommand />
178
159
 
179
160
  ## modern upgrade
180
161
 
@@ -252,4 +233,4 @@ Inspect config succeed, open following files to view the content:
252
233
 
253
234
  import DeployCommand from "@site-docs-en/components/deploy-command";
254
235
 
255
- <DeployCommand />
236
+ <DeployCommand />
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: NoSSRCache
3
+ ---
4
+ # NoSSRCache
5
+
6
+ With the NoSSRCache component, Modern.js does not cache the server-side rendering (SSR) results of the current page.
7
+
8
+ :::note
9
+ This component is currently only available if `ssr.mode` is `string`.
10
+ :::
11
+
12
+ ## Usage
13
+
14
+ ```tsx
15
+ import { NoSSRCache } from '@modern-js/runtime/ssr';
16
+
17
+ export default () => {
18
+ return (
19
+ <div>
20
+ <NoSSRCache />
21
+ ...
22
+ </div>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ## Example
28
+
29
+ In the following code, after using `useLoaderData` to fetch data, the current page is cached or not based on the data fetched. For this case, use `NoSSRCache`:
30
+
31
+ ```tsx
32
+ import { useLoaderData } from '@modern-js/runtim/router';
33
+ import { NoSSRCache } from '@modern-js/runtime/ssr';
34
+
35
+ function User() {
36
+ const { data } = useLoaderData();
37
+ return (
38
+ <div>
39
+ { !data ? <NoSSRCache /> : null }
40
+ ...
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ ## Scene
47
+
48
+ This can be used if you need to decide whether the current page needs to cache the server-side rendering (SSR) results based on the current page fetching the data (e.g., whether the request was successful or whether a field exists in the returned result).
@@ -0,0 +1,22 @@
1
+ ## modern serve
2
+
3
+ The `modern serve` command is used to start a Modern.js project in the production environment. It can also be used to preview the artifacts built for the production environment locally. Please note that you need to execute the [`build`](/apis/app/commands#modern-build) command beforehand to generate the corresponding artifacts.
4
+
5
+ ```bash
6
+ Usage: modern serve [options]
7
+
8
+ Options:
9
+ -c --config <config> specify the configuration file, which can be a relative or absolute path
10
+ -h, --help show command help
11
+ --api-only only run API service
12
+ ```
13
+
14
+ By default, the project will run in `localhost:8080`, you can modify the server port number with `server.port`:
15
+
16
+ ```js
17
+ export default defineConfig({
18
+ server: {
19
+ port: 8081,
20
+ },
21
+ });
22
+ ```
@@ -153,28 +153,9 @@ pnpm 暂不支持使用 JSON 字符串作为参数值,可使用 `npm new` 开
153
153
 
154
154
  :::
155
155
 
156
- ## modern serve
156
+ import ServeCommand from "@site-docs/components/serve-command";
157
157
 
158
- `modern serve` 命令用于在生产环境下启动 Modern.js 工程, 也可以用于在本地预览生产环境构建的产物。注意你需要提前执行 [`build`](/apis/app/commands#modern-build) 命令构建出对应产物。
159
-
160
- ```bash
161
- Usage: modern serve [options]
162
-
163
- Options:
164
- -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
165
- -h, --help 显示命令帮助
166
- --api-only 仅启动 API 接口服务
167
- ```
168
-
169
- 默认情况下,应用将会在 `localhost:8080` 启动,可以通过 `server.port` 修改 Server 端口号:
170
-
171
- ```js
172
- export default defineConfig({
173
- server: {
174
- port: 8081,
175
- },
176
- });
177
- ```
158
+ <ServeCommand />
178
159
 
179
160
  ## modern upgrade
180
161
 
@@ -252,4 +233,4 @@ Inspect config succeed, open following files to view the content:
252
233
 
253
234
  import DeployCommand from "@site-docs/components/deploy-command";
254
235
 
255
- <DeployCommand />
236
+ <DeployCommand />
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: NoSSRCache
3
+ ---
4
+ # NoSSRCache
5
+
6
+ 使用了 NoSSRCache 组件后,Modern.js 不会将当前页面的服务器端渲染(SSR)结果进行缓存。
7
+
8
+ :::note
9
+ 该组件目前仅在 `ssr.mode` 为 `string` 的情况可以使用。
10
+ :::
11
+
12
+ ## 使用姿势
13
+
14
+ ```tsx
15
+ import { NoSSRCache } from '@modern-js/runtime/ssr';
16
+
17
+ export default () => {
18
+ return (
19
+ <div>
20
+ <NoSSRCache />
21
+ ...
22
+ </div>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ## 示例
28
+
29
+ 下列代码中,使用 `useLoaderData` 获取数据后,根据请求数据的结果决定是否缓存当前页面的服务端渲染结果。针对这种情况可以使用 `NoSSRCache` 组件:
30
+
31
+ ```tsx
32
+ import { useLoaderData } from '@modern-js/runtim/router';
33
+ import { NoSSRCache } from '@modern-js/runtime/ssr';
34
+
35
+ function User() {
36
+ const { data } = useLoaderData();
37
+ return (
38
+ <div>
39
+ { !data ? <NoSSRCache /> : null }
40
+ ...
41
+ </div>
42
+ );
43
+ }
44
+ ```
45
+
46
+ ## 使用场景
47
+
48
+ 如果需要根据当前页面获取数据的情况(比如是否请求成功或者返回结果中是否存在某个字段),决定是否需要将当前页面的服务端渲染(SSR)结果进行缓存,则可以使用这种方式来解决。
@@ -0,0 +1,22 @@
1
+ ## modern serve
2
+
3
+ `modern serve` 命令用于在生产环境下启动 Modern.js 工程, 也可以用于在本地预览生产环境构建的产物。注意你需要提前执行 [`build`](/apis/app/commands#modern-build) 命令构建出对应产物。
4
+
5
+ ```bash
6
+ Usage: modern serve [options]
7
+
8
+ Options:
9
+ -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
10
+ -h, --help 显示命令帮助
11
+ --api-only 仅启动 API 接口服务
12
+ ```
13
+
14
+ 默认情况下,应用将会在 `localhost:8080` 启动,可以通过 `server.port` 修改 Server 端口号:
15
+
16
+ ```js
17
+ export default defineConfig({
18
+ server: {
19
+ port: 8081,
20
+ },
21
+ });
22
+ ```
package/package.json CHANGED
@@ -15,14 +15,14 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20240923170640",
18
+ "version": "0.0.0-nightly-20240925070419",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "dependencies": {
25
- "@modern-js/sandpack-react": "0.0.0-nightly-20240923170640"
25
+ "@modern-js/sandpack-react": "0.0.0-nightly-20240925070419"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rspress/shared": "1.31.0",