@modern-js/main-doc 2.58.3 → 2.60.0
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.
- package/docs/en/_meta.json +10 -5
- package/docs/en/apis/app/hooks/api/lambda.mdx +4 -48
- package/docs/en/apis/app/hooks/api/middleware.mdx +11 -0
- package/docs/en/apis/app/runtime/core/use-loader.mdx +1 -1
- package/docs/en/community/blog/v2-release-note.mdx +1 -1
- package/docs/en/components/enable-bff.mdx +19 -2
- package/docs/en/components/extend-bff-function.mdx +5 -0
- package/docs/en/components/init-app.mdx +0 -1
- package/docs/en/components/init-rspack-app.mdx +0 -1
- package/docs/en/components/other-plugins.mdx +0 -0
- package/docs/en/components/ssr-monitor.mdx +3 -0
- package/docs/en/configure/app/auto-load-plugin.mdx +4 -0
- package/docs/en/configure/app/output/ssg.mdx +52 -141
- package/docs/en/configure/app/plugins.mdx +2 -2
- package/docs/en/configure/app/tools/esbuild.mdx +1 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -1
- package/docs/en/configure/app/tools/tailwindcss.mdx +1 -1
- package/docs/en/guides/_meta.json +0 -5
- package/docs/en/guides/advanced-features/_meta.json +3 -8
- package/docs/en/guides/advanced-features/bff/_meta.json +1 -1
- package/docs/en/guides/advanced-features/bff/extend-server.mdx +154 -0
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +52 -123
- package/docs/en/guides/advanced-features/bff/function.mdx +108 -80
- package/docs/en/guides/advanced-features/bff/sdk.mdx +40 -51
- package/docs/en/guides/advanced-features/build-performance.mdx +6 -21
- package/docs/en/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/en/guides/advanced-features/rspack-start.mdx +6 -14
- package/docs/en/guides/basic-features/_meta.json +31 -9
- package/docs/en/guides/basic-features/css/_meta.json +1 -0
- package/docs/en/guides/basic-features/css/css-in-js.mdx +34 -0
- package/docs/en/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -4
- package/docs/en/guides/basic-features/css/css.mdx +25 -0
- package/docs/en/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +5 -66
- package/docs/en/guides/basic-features/data/data-fetch.mdx +134 -235
- package/docs/en/guides/basic-features/data/data-write.mdx +66 -77
- package/docs/en/guides/basic-features/debug/_meta.json +1 -0
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +57 -0
- package/docs/en/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +2 -0
- package/docs/en/guides/basic-features/render/_meta.json +1 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +208 -0
- package/docs/en/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +38 -50
- package/docs/en/guides/basic-features/render/ssr.mdx +301 -0
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +230 -0
- package/docs/en/guides/basic-features/routes.mdx +274 -263
- package/docs/en/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/en/guides/basic-features/static-assets.mdx +2 -2
- package/docs/en/guides/basic-features/testing/_meta.json +1 -0
- package/docs/en/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/en/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/en/guides/basic-features/testing/playwright.mdx +111 -0
- package/docs/en/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/en/guides/concept/entries.mdx +9 -2
- package/docs/en/guides/deprecated.md +2 -0
- package/docs/en/guides/get-started/quick-start.mdx +1 -1
- package/docs/en/guides/get-started/tech-stack.mdx +4 -4
- package/docs/en/guides/topic-detail/_meta.json +0 -6
- package/docs/en/guides/topic-detail/generator/create/config.mdx +0 -10
- package/docs/en/guides/topic-detail/generator/create/use.mdx +0 -1
- package/docs/en/plugin/_meta.json +19 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -0
- package/docs/en/plugin/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/en/plugin/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/en/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +7 -0
- package/docs/en/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
- package/docs/en/plugin/cli-plugins.mdx +6 -0
- package/docs/en/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +36 -11
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
- package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
- package/docs/en/plugin/rsbuild-plugins/_meta.json +1 -0
- package/docs/en/plugin/rsbuild-plugins.mdx +3 -0
- package/docs/en/tutorials/first-app/c03-css.mdx +1 -1
- package/docs/zh/_meta.json +10 -5
- package/docs/zh/apis/app/hooks/api/lambda.mdx +5 -48
- package/docs/zh/apis/app/hooks/api/middleware.mdx +11 -0
- package/docs/zh/apis/app/runtime/core/use-loader.mdx +1 -1
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/components/enable-bff.mdx +19 -2
- package/docs/zh/components/extend-bff-function.mdx +5 -0
- package/docs/zh/components/init-app.mdx +0 -1
- package/docs/zh/components/init-rspack-app.mdx +0 -1
- package/docs/zh/components/other-plugins.mdx +0 -0
- package/docs/zh/components/ssr-monitor.mdx +3 -0
- package/docs/zh/configure/app/auto-load-plugin.mdx +4 -0
- package/docs/zh/configure/app/output/ssg.mdx +49 -139
- package/docs/zh/configure/app/plugins.mdx +2 -2
- package/docs/zh/configure/app/tools/esbuild.mdx +1 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -1
- package/docs/zh/configure/app/tools/tailwindcss.mdx +1 -1
- package/docs/zh/guides/_meta.json +0 -5
- package/docs/zh/guides/advanced-features/_meta.json +3 -8
- package/docs/zh/guides/advanced-features/bff/_meta.json +1 -1
- package/docs/zh/guides/advanced-features/bff/extend-server.mdx +156 -0
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +51 -117
- package/docs/zh/guides/advanced-features/bff/function.mdx +69 -59
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +27 -36
- package/docs/zh/guides/advanced-features/build-performance.mdx +6 -21
- package/docs/zh/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/zh/guides/advanced-features/rspack-start.mdx +8 -17
- package/docs/zh/guides/basic-features/_meta.json +31 -9
- package/docs/zh/guides/basic-features/alias.mdx +5 -11
- package/docs/zh/guides/basic-features/css/_meta.json +1 -0
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +34 -0
- package/docs/zh/guides/basic-features/css/css.mdx +25 -0
- package/docs/zh/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +3 -64
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +96 -211
- package/docs/zh/guides/basic-features/data/data-write.mdx +54 -55
- package/docs/zh/guides/basic-features/debug/_meta.json +1 -0
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +57 -0
- package/docs/zh/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +1 -1
- package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
- package/docs/zh/guides/basic-features/render/_meta.json +1 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +210 -0
- package/docs/zh/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +16 -26
- package/docs/zh/guides/basic-features/render/ssr.mdx +309 -0
- package/docs/zh/guides/{advanced-features/ssr/stream.mdx → basic-features/render/streaming-ssr.mdx} +22 -37
- package/docs/zh/guides/basic-features/routes.mdx +251 -237
- package/docs/zh/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/zh/guides/basic-features/static-assets.mdx +3 -7
- package/docs/zh/guides/basic-features/testing/_meta.json +1 -0
- package/docs/zh/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/zh/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/zh/guides/basic-features/testing/playwright.mdx +112 -0
- package/docs/zh/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/zh/guides/concept/entries.mdx +6 -3
- package/docs/zh/guides/deprecated.md +4 -0
- package/docs/zh/guides/get-started/quick-start.mdx +1 -1
- package/docs/zh/guides/get-started/tech-stack.mdx +8 -8
- package/docs/zh/guides/topic-detail/_meta.json +0 -6
- package/docs/zh/guides/topic-detail/generator/create/config.mdx +0 -10
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +0 -1
- package/docs/zh/plugin/_meta.json +19 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -0
- package/docs/zh/plugin/cli-plugins/plugin-bff.mdx +5 -0
- package/docs/zh/plugin/cli-plugins/plugin-ssg.mdx +5 -0
- package/docs/zh/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +7 -0
- package/docs/zh/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
- package/docs/zh/plugin/cli-plugins.mdx +6 -0
- package/docs/zh/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +38 -13
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
- package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
- package/docs/zh/plugin/rsbuild-plugins/_meta.json +1 -0
- package/docs/zh/plugin/rsbuild-plugins.mdx +4 -0
- package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/i18n.json +42 -6
- package/package.json +7 -6
- package/rspress.config.ts +1 -58
- package/src/components/Footer/index.tsx +1 -1
- package/src/pages/index.tsx +0 -1
- package/docs/en/apis/app/hooks/api/api.mdx +0 -80
- package/docs/en/apis/app/hooks/api/app.mdx +0 -12
- package/docs/en/apis/app/hooks/config/storybook.mdx +0 -37
- package/docs/en/guides/advanced-features/bff/type.mdx +0 -46
- package/docs/en/guides/advanced-features/eslint.mdx +0 -148
- package/docs/en/guides/advanced-features/ssg.mdx +0 -116
- package/docs/en/guides/advanced-features/ssr/_meta.json +0 -1
- package/docs/en/guides/advanced-features/ssr/index.mdx +0 -23
- package/docs/en/guides/advanced-features/ssr/stream.mdx +0 -248
- package/docs/en/guides/advanced-features/ssr/usage.mdx +0 -341
- package/docs/en/guides/advanced-features/ssr.mdx +0 -555
- package/docs/zh/apis/app/hooks/api/api.mdx +0 -81
- package/docs/zh/apis/app/hooks/api/app.mdx +0 -12
- package/docs/zh/apis/app/hooks/config/storybook.mdx +0 -38
- package/docs/zh/guides/advanced-features/bff/type.mdx +0 -46
- package/docs/zh/guides/advanced-features/eslint.mdx +0 -152
- package/docs/zh/guides/advanced-features/ssg.mdx +0 -116
- package/docs/zh/guides/advanced-features/ssr/_meta.json +0 -1
- package/docs/zh/guides/advanced-features/ssr/index.mdx +0 -23
- package/docs/zh/guides/advanced-features/ssr/usage.mdx +0 -329
- /package/docs/en/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
- /package/docs/en/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
- /package/docs/en/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
- /package/docs/en/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
- /package/docs/en/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
- /package/docs/en/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
- /package/docs/en/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
- /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
- /package/docs/en/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +0 -0
- /package/docs/zh/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
- /package/docs/zh/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
- /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
- /package/docs/zh/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +0 -0
package/docs/en/_meta.json
CHANGED
|
@@ -4,21 +4,26 @@
|
|
|
4
4
|
"link": "/guides/get-started/introduction",
|
|
5
5
|
"activeMatch": "/guides/"
|
|
6
6
|
},
|
|
7
|
-
{
|
|
8
|
-
"text": "tutorials",
|
|
9
|
-
"link": "/tutorials/foundations/introduction",
|
|
10
|
-
"activeMatch": "/tutorials/"
|
|
11
|
-
},
|
|
12
7
|
{
|
|
13
8
|
"text": "configure",
|
|
14
9
|
"link": "/configure/app/usage",
|
|
15
10
|
"activeMatch": "/configure/"
|
|
16
11
|
},
|
|
12
|
+
{
|
|
13
|
+
"text": "plugin-menu",
|
|
14
|
+
"link": "/plugin/introduction",
|
|
15
|
+
"activeMatch": "/plugin/"
|
|
16
|
+
},
|
|
17
17
|
{
|
|
18
18
|
"text": "apis",
|
|
19
19
|
"link": "/apis/app/commands",
|
|
20
20
|
"activeMatch": "/apis/"
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
"text": "tutorials",
|
|
24
|
+
"link": "/tutorials/foundations/introduction",
|
|
25
|
+
"activeMatch": "/tutorials/"
|
|
26
|
+
},
|
|
22
27
|
{
|
|
23
28
|
"text": "community",
|
|
24
29
|
"link": "/community/showcase",
|
|
@@ -4,54 +4,10 @@ sidebar_position: 3
|
|
|
4
4
|
---
|
|
5
5
|
# lambda/*.[tj]s
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
:::info
|
|
10
|
-
Using the `api` directory requires enabling the BFF function, and you need to run the new command to enable the "BFF" function under the project.
|
|
7
|
+
After enabling BFF, the files under the `lambda/` directory will be registered as BFF routes according to conventions.
|
|
11
8
|
|
|
9
|
+
:::note
|
|
10
|
+
The files can be written in `js` or `ts` languages, but they must use `esm` syntax to export functions.
|
|
12
11
|
:::
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
This file supports using `js` or `ts` language, but must export functions using `esm` syntax.
|
|
16
|
-
|
|
17
|
-
:::
|
|
18
|
-
|
|
19
|
-
## Routing File Convention
|
|
20
|
-
|
|
21
|
-
### Default Routing
|
|
22
|
-
|
|
23
|
-
The routing system will map files named `index` to the previous directory.
|
|
24
|
-
|
|
25
|
-
- `api/lambda/index.ts` -> `$BASENAME/`
|
|
26
|
-
- `api/lambda/user/index.ts` -> `$BASENAME/user`
|
|
27
|
-
|
|
28
|
-
### Nested Routing
|
|
29
|
-
|
|
30
|
-
The routing system also supports parsing nested files. If you create a nested folder structure, the files will still automatically resolve routes in the same way.
|
|
31
|
-
|
|
32
|
-
- `api/lambda/hello.ts` -> `$BASENAME/hello`
|
|
33
|
-
- `api/lambda/user/list.ts` -> `$BASENAME/user/list`
|
|
34
|
-
|
|
35
|
-
### Dynamic Routing
|
|
36
|
-
|
|
37
|
-
The routing system supports generating dynamic routes through file directories named with `[]`.
|
|
38
|
-
|
|
39
|
-
- `api/lambda/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
|
|
40
|
-
- `api/lambda/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
|
|
41
|
-
- `api/lambda/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
|
|
42
|
-
|
|
43
|
-
The `$BASENAME` can be configured in `modern.config.js`, and the default value is `/api`.
|
|
44
|
-
|
|
45
|
-
### Allow List
|
|
46
|
-
|
|
47
|
-
By default, all files in the `lambda` directory are parsed as BFF function files, but we also set up a whitelist so that these files are not parsed:
|
|
48
|
-
|
|
49
|
-
- Files named starting with `_`. For example: `_utils.ts`.
|
|
50
|
-
- All files in a folder named starting with `_`. For example: `_utils/index.ts`, `_utils/cp.ts`.
|
|
51
|
-
- Test files. For example: `foo.test.ts`.
|
|
52
|
-
- TypeScript type files. For example: `hello.d.ts`.
|
|
53
|
-
- Files under `node_module`.
|
|
54
|
-
|
|
55
|
-
## Function Definition
|
|
56
|
-
|
|
57
|
-
Completely consistent with the [Function Definition](/apis/app/hooks/api/api#function-definition) under the function mode.
|
|
13
|
+
For detailed information, refer to [BFF API Routes](/guides/advanced-features/bff/function.html#api-routes).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: _app.[tj]s
|
|
3
|
+
sidebar_position: 2
|
|
4
|
+
---
|
|
5
|
+
# _app.[tj]s
|
|
6
|
+
|
|
7
|
+
This file can add pre-middleware to BFF functions. For detailed information, refer to [Extend BFF Server](/guides/advanced-features/bff/extend-server).
|
|
8
|
+
|
|
9
|
+
:::note
|
|
10
|
+
For specific examples, please refer to [hook](/apis/app/runtime/bff/hook).
|
|
11
|
+
:::
|
|
@@ -52,7 +52,7 @@ function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
|
|
|
52
52
|
- `initialData`: the initial data before the first execution,.
|
|
53
53
|
- `skip`: when the value is `true`, the function does not execute.
|
|
54
54
|
- `params`: when the result of the `params` serialization changes, the function is re-executed. `params` is also passed in as the second argument of the function.
|
|
55
|
-
- `static`: when the value is `true`, `useLoader` is used for [SSG](/guides/
|
|
55
|
+
- `static`: when the value is `true`, `useLoader` is used for [SSG](/guides/basic-features/render/ssg).
|
|
56
56
|
|
|
57
57
|
### Return Value
|
|
58
58
|
|
|
@@ -132,7 +132,7 @@ Modern.js 可以划分为三个核心部分:**CLI 工具、服务端和运行
|
|
|
132
132
|
|
|
133
133
|
在字节跳动内部,我们借助这些插件 API,结合公司内的基建和平台,封装出内部的企业级框架。如果你需要对 Modern.js 框架进行深度定制,也可以借助这些插件 API 来完成。
|
|
134
134
|
|
|
135
|
-
> 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/
|
|
135
|
+
> 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/plugin/plugin-system/introduction.html)文档。
|
|
136
136
|
|
|
137
137
|
### 嵌套路由
|
|
138
138
|
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { PackageManagerTabs } from '@theme';
|
|
2
|
+
|
|
3
|
+
1. Execute the `new` command:
|
|
4
|
+
|
|
5
|
+
<PackageManagerTabs command="run new" />
|
|
6
|
+
|
|
7
|
+
2. Follow the prompts to **enable BFF functionality**:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
? Please select the operation you want to perform Enable optional features
|
|
11
|
+
? Please select the feature to enable Enable "BFF"
|
|
12
|
+
? Please select BFF type Framework mode
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
:::note
|
|
16
|
+
Currently, it is recommended to create BFF in framework mode. We will remove the BFF type concept in the future.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
3. Depending on the chosen runtime framework, add the following code to `modern.config.[tj]s`:
|
|
3
20
|
|
|
4
21
|
import { Tabs, Tab as TabItem } from "@theme";
|
|
5
22
|
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
? Please select the type of project you want to create: Web App
|
|
5
5
|
? Please select the programming language: TS
|
|
6
6
|
? Please select the package manager: pnpm
|
|
7
|
-
? Please select the bundler: webpack
|
|
8
7
|
```
|
|
9
8
|
|
|
10
9
|
After create the project, Modern.js will automatically install dependencies and create a git repository.
|
|
File without changes
|
|
@@ -9,6 +9,10 @@ sidebar_position: 22
|
|
|
9
9
|
|
|
10
10
|
Used to configure whether Modern.js enables auto-registration of plugins.
|
|
11
11
|
|
|
12
|
+
:::warning
|
|
13
|
+
This configuration is not recommended. Compared with manually registering plugin, this configuration is relatively black box and cannot add custom configurations to plugin.
|
|
14
|
+
:::
|
|
15
|
+
|
|
12
16
|
### Manual Registration Plugin
|
|
13
17
|
|
|
14
18
|
By default, installing the plugin requires you to register the plugin manually in the `modern.config.ts`.
|
|
@@ -4,46 +4,24 @@ title: ssg
|
|
|
4
4
|
|
|
5
5
|
# output.ssg
|
|
6
6
|
|
|
7
|
-
- **Type:** `boolean` | `object`
|
|
8
|
-
- **Default:** `undefined`
|
|
7
|
+
- **Type:** `boolean` | `object`
|
|
8
|
+
- **Default Value:** `undefined`
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Configuration to enable the application’s SSG (Static Site Generation) feature.
|
|
11
11
|
|
|
12
|
-
:::
|
|
13
|
-
This configuration
|
|
12
|
+
:::tip Enabling SSG
|
|
13
|
+
This configuration takes effect only when SSG is enabled. Please read the [Static Site Generation](/guides/basic-features/render/ssg) documentation to understand how to enable SSG and its use cases.
|
|
14
14
|
:::
|
|
15
15
|
|
|
16
|
-
:::info
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
:::info Recommended Reading
|
|
17
|
+
The SSG feature is closely related to routing. It is recommended to understand the [routing solution](/guides/basic-features/routes) before using SSG.
|
|
19
18
|
:::
|
|
20
19
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
### Single Entry
|
|
24
|
-
|
|
25
|
-
When the configuration is set to `true`, the SSG of all entries will be enabled by default.
|
|
26
|
-
|
|
27
|
-
For **self-controlled routing**, the root route of the entry will be rendered. For **convention routing**, every route in the entry will be rendered.
|
|
28
|
-
|
|
29
|
-
For example, the `src/` directory has the following file structure that satisfies **conventional routing**:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
.
|
|
33
|
-
├── src
|
|
34
|
-
│ └── routes
|
|
35
|
-
│ ├── layout.tsx
|
|
36
|
-
│ ├── page.tsx
|
|
37
|
-
│ └── user
|
|
38
|
-
│ ├── layout.tsx
|
|
39
|
-
│ ├── page.tsx
|
|
40
|
-
│ └── profile
|
|
41
|
-
│ └── page.tsx
|
|
42
|
-
```
|
|
20
|
+
## Boolean Type
|
|
43
21
|
|
|
44
|
-
|
|
22
|
+
When this configuration is set to `true`, the SSG feature will be enabled for all entries by default. For **manual routing**, the root route of the entry will be rendered. For **conventional routing**, each route in the entry will be rendered.
|
|
45
23
|
|
|
46
|
-
```
|
|
24
|
+
```js
|
|
47
25
|
export default defineConfig({
|
|
48
26
|
output: {
|
|
49
27
|
ssg: true,
|
|
@@ -51,39 +29,20 @@ export default defineConfig({
|
|
|
51
29
|
});
|
|
52
30
|
```
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
For example the following **self-controlled routing**:
|
|
57
|
-
|
|
58
|
-
import SelfRouteExample from "@site-docs/components/self-route-example";
|
|
59
|
-
|
|
60
|
-
<SelfRouteExample />
|
|
61
|
-
|
|
62
|
-
Also using the above configuration, after executing `pnpm run build`, only the entry route `/` will generate the rendered HTML.
|
|
32
|
+
`output.ssg` can also be configured per entry, with the rules for effective configurations determined by the entry's routing method.
|
|
63
33
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
`output.ssg` can also be configured according to the entries, and the rules that the configuration takes effect are also determined by the entries routing method.
|
|
67
|
-
|
|
68
|
-
For example the following directory structure:
|
|
34
|
+
For example, given the following directory structure, there are conventional routing entry `entryA` and manual routing entry `entryB`:
|
|
69
35
|
|
|
70
36
|
```bash
|
|
71
37
|
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
│
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
│ │ └── user
|
|
78
|
-
│ │ ├── layout.tsx
|
|
79
|
-
│ │ ├── page.tsx
|
|
80
|
-
│ │ └── profile
|
|
81
|
-
│ │ └── page.tsx
|
|
82
|
-
│ └── entryB
|
|
83
|
-
│ └── App.tsx
|
|
38
|
+
└── src
|
|
39
|
+
├── entryA
|
|
40
|
+
│ └── routes
|
|
41
|
+
└── entryB
|
|
42
|
+
└── App.tsx
|
|
84
43
|
```
|
|
85
44
|
|
|
86
|
-
|
|
45
|
+
You can specify different SSG configurations for `entryA` and `entryB`:
|
|
87
46
|
|
|
88
47
|
```js
|
|
89
48
|
export default defineConfig({
|
|
@@ -96,107 +55,59 @@ export default defineConfig({
|
|
|
96
55
|
});
|
|
97
56
|
```
|
|
98
57
|
|
|
99
|
-
### Configure Route
|
|
100
|
-
|
|
101
|
-
As mentioned above, **Self-Controlled Routing** only enables SSG configuration for entries route by default.
|
|
102
|
-
|
|
103
|
-
Set specific routes in `output.ssg` can tell Modern.js to enable the SSG of these client side routes. For example, the content of the above `src/App.tsx` file is:
|
|
104
|
-
|
|
105
|
-
<SelfRouteExample />
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
When set like this in `modern.config.[jt]s`, the `/about` route will also enable SSG:
|
|
109
|
-
|
|
110
|
-
```js
|
|
111
|
-
export default defineConfig({
|
|
112
|
-
output: {
|
|
113
|
-
ssg: {
|
|
114
|
-
routes: ['/', '/about'],
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Modern.js will automatically concat the complete URL according to the entry and hand it over to the SSG plugin to complete the rendering.
|
|
121
|
-
|
|
122
|
-
Request headers can also be configured for specific entries or routes, for example:
|
|
123
|
-
|
|
124
|
-
```js
|
|
125
|
-
export default defineConfig({
|
|
126
|
-
output: {
|
|
127
|
-
ssg: {
|
|
128
|
-
headers: {},
|
|
129
|
-
routes: [
|
|
130
|
-
'/',
|
|
131
|
-
{
|
|
132
|
-
url: '/about',
|
|
133
|
-
headers: {},
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
```
|
|
140
|
-
|
|
141
58
|
:::info
|
|
142
|
-
|
|
143
|
-
|
|
59
|
+
For more information on the default behavior of **conventional routing** and **manual routing** after enabling SSG, please read [Static Site Generation](/guides/basic-features/render/ssg).
|
|
144
60
|
:::
|
|
145
61
|
|
|
146
|
-
|
|
62
|
+
## Object Type
|
|
147
63
|
|
|
148
|
-
|
|
64
|
+
When the value type is `Object`, the following attributes can be configured.
|
|
149
65
|
|
|
150
|
-
|
|
66
|
+
### Configuration Type
|
|
151
67
|
|
|
152
|
-
```bash
|
|
153
|
-
.
|
|
154
|
-
├── src
|
|
155
|
-
│ └── routes
|
|
156
|
-
│ ├── layout.tsx
|
|
157
|
-
│ ├── page.tsx
|
|
158
|
-
│ └── user
|
|
159
|
-
│ ├── layout.tsx
|
|
160
|
-
│ ├── page.tsx
|
|
161
|
-
│ └── profile
|
|
162
|
-
│ └── page.tsx
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
You can set this to disable the default behavior of a client-side route:
|
|
166
68
|
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
69
|
+
```ts
|
|
70
|
+
type SSGRouteOptions = string | {
|
|
71
|
+
url: string;
|
|
72
|
+
params?: Record<string, any>[];
|
|
73
|
+
headers?: Record<string, any>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type SSGOptions = {
|
|
77
|
+
preventDefault?: string[];
|
|
78
|
+
headers?: Record<string, any>;
|
|
79
|
+
routes?: SSGRouteOptions[];
|
|
80
|
+
};
|
|
175
81
|
```
|
|
176
82
|
|
|
177
|
-
###
|
|
83
|
+
### Example
|
|
178
84
|
|
|
179
|
-
|
|
85
|
+
In the example configuration below, SSG will render the pages corresponding to the `/`, `/about`, and `/user/:id` routes.
|
|
180
86
|
|
|
181
|
-
|
|
87
|
+
For the `/user/:id` route, `cookies` will be added to the request headers, and the `id` in `params` will be replaced with `modernjs`.
|
|
182
88
|
|
|
183
|
-
```
|
|
89
|
+
```ts title="modern.config.ts"
|
|
184
90
|
export default defineConfig({
|
|
185
91
|
output: {
|
|
186
92
|
ssg: {
|
|
187
93
|
routes: [
|
|
94
|
+
'/',
|
|
95
|
+
'/about',
|
|
188
96
|
{
|
|
189
97
|
url: '/user/:id',
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
98
|
+
headers: {
|
|
99
|
+
cookies: "name=modernjs"
|
|
100
|
+
},
|
|
101
|
+
params: [{
|
|
102
|
+
id: 'modernjs',
|
|
103
|
+
}],
|
|
104
|
+
}
|
|
196
105
|
],
|
|
197
|
-
}
|
|
198
|
-
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
199
108
|
});
|
|
200
109
|
```
|
|
201
110
|
|
|
202
|
-
|
|
111
|
+
:::note
|
|
112
|
+
The configuration method for multiple entries is the same as for a single entry, so it will not be explained further here.
|
|
113
|
+
:::
|
|
@@ -9,7 +9,7 @@ sidebar_position: 9
|
|
|
9
9
|
|
|
10
10
|
Used to configure custom Modern.js framework plugins.
|
|
11
11
|
|
|
12
|
-
Refer to [How to Develop Plugins](/
|
|
12
|
+
Refer to [How to Develop Plugins](/plugin/plugin-system/implement) for how to write custom plugins.
|
|
13
13
|
|
|
14
14
|
## Note
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ Currently, Modern.js has opened up the ability to customize CLI plugins, and Ser
|
|
|
33
33
|
|
|
34
34
|
By default, custom plugins are executed in the order of the `plugins` array, and the execution time of built-in Modern.js plugins is earlier than that of custom plugins.
|
|
35
35
|
|
|
36
|
-
When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [Relationship between plugins](/
|
|
36
|
+
When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [Relationship between plugins](/plugin/plugin-system/relationship) for more information.
|
|
37
37
|
|
|
38
38
|
## Example
|
|
39
39
|
|
|
@@ -41,4 +41,4 @@ export default defineConfig({
|
|
|
41
41
|
});
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
For config details, please refer to [Esbuild Plugin Configuration](/
|
|
44
|
+
For config details, please refer to [Esbuild Plugin Configuration](/plugin/rsbuild-plugins/plugin-esbuild.html#config).
|
|
@@ -77,4 +77,4 @@ export default defineConfig({
|
|
|
77
77
|
});
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
For config details, please refer to [SWC Plugin Configuration](/
|
|
80
|
+
For config details, please refer to [SWC Plugin Configuration](/plugin/cli-plugins/plugin-swc.html#config).
|
|
@@ -23,7 +23,7 @@ Used to modify the configuration of [Tailwind CSS](https://tailwindcss.com/docs/
|
|
|
23
23
|
|
|
24
24
|
Before using `tools.tailwindcss`, you need to enable the Tailwind CSS plugin for Modern.js.
|
|
25
25
|
|
|
26
|
-
Please refer to the section [Using Tailwind CSS](/guides/basic-features/css
|
|
26
|
+
Please refer to the section [Using Tailwind CSS](/guides/basic-features/css/tailwindcss) for instructions on how to enable it.
|
|
27
27
|
|
|
28
28
|
### Function Type
|
|
29
29
|
|
|
@@ -6,21 +6,16 @@
|
|
|
6
6
|
"label": "use-bff",
|
|
7
7
|
"collapsed": true
|
|
8
8
|
},
|
|
9
|
-
"code-split",
|
|
10
9
|
{
|
|
11
10
|
"type": "dir",
|
|
12
|
-
"name": "
|
|
13
|
-
"label": "
|
|
11
|
+
"name": "page-performance",
|
|
12
|
+
"label": "page-performance",
|
|
14
13
|
"collapsed": true
|
|
15
14
|
},
|
|
16
|
-
"
|
|
15
|
+
"build-performance",
|
|
17
16
|
"compatibility",
|
|
18
17
|
"eslint",
|
|
19
18
|
"low-level",
|
|
20
19
|
"source-build",
|
|
21
|
-
"build-performance",
|
|
22
|
-
"inline-assets",
|
|
23
|
-
"optimize-bundle",
|
|
24
|
-
"using-storybook",
|
|
25
20
|
"web-server"
|
|
26
21
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
["function", "
|
|
1
|
+
["function", "frameworks", "extend-server", "sdk"]
|