@bleedingdev/modern-js-main-doc 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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/apis/app/commands.mdx +41 -51
- package/docs/en/community/blog/2022-0708-updates.md +1 -1
- package/docs/en/community/blog/2022-0910-updates.md +2 -2
- package/docs/en/community/contributing-guide.mdx +2 -3
- package/docs/en/community/releases.mdx +1 -5
- package/docs/en/components/init-app.mdx +40 -66
- package/docs/en/components/init-rspack-app.mdx +1 -1
- package/docs/en/components/prerequisites.mdx +1 -2
- package/docs/en/components/serve-command.mdx +1 -1
- package/docs/en/configure/app/bff/effect.mdx +27 -3
- package/docs/en/configure/app/bff/runtime-framework.mdx +1 -1
- package/docs/en/configure/app/performance/rsdoctor.mdx +7 -4
- package/docs/en/configure/app/tools/ts-checker.mdx +30 -2
- package/docs/en/guides/advanced-features/bff/data-platform.mdx +3 -1
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +3 -1
- package/docs/en/guides/advanced-features/international/api.mdx +4 -1
- package/docs/en/guides/advanced-features/international/configuration.mdx +1 -0
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +1 -1
- package/docs/en/guides/advanced-features/international/routing.mdx +45 -2
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +2 -3
- package/docs/en/guides/basic-features/deploy.mdx +1 -1
- package/docs/en/guides/basic-features/render/_meta.json +1 -10
- package/docs/en/guides/basic-features/render/overview.mdx +0 -1
- package/docs/en/guides/basic-features/render/rsc.mdx +0 -1
- package/docs/en/guides/basic-features/routes/routes.mdx +24 -9
- package/docs/en/guides/basic-features/testing/_meta.json +1 -1
- package/docs/en/guides/concept/server.mdx +2 -2
- package/docs/en/guides/get-started/quick-start.mdx +1 -1
- package/docs/en/guides/get-started/tech-stack.mdx +10 -4
- package/docs/en/guides/get-started/ultramodern.mdx +94 -20
- package/docs/en/guides/upgrade/config.mdx +1 -2
- package/docs/en/guides/upgrade/other.mdx +4 -4
- package/docs/zh/apis/app/commands.mdx +38 -48
- package/docs/zh/community/blog/2022-0708-updates.md +1 -1
- package/docs/zh/community/blog/2022-0910-updates.md +2 -2
- package/docs/zh/community/contributing-guide.mdx +2 -3
- package/docs/zh/community/releases.mdx +1 -5
- package/docs/zh/components/init-app.mdx +33 -62
- package/docs/zh/components/init-rspack-app.mdx +1 -1
- package/docs/zh/components/prerequisites.mdx +1 -2
- package/docs/zh/components/serve-command.mdx +1 -1
- package/docs/zh/configure/app/bff/effect.mdx +26 -2
- package/docs/zh/configure/app/bff/runtime-framework.mdx +1 -1
- package/docs/zh/configure/app/performance/rsdoctor.mdx +7 -4
- package/docs/zh/configure/app/tools/ts-checker.mdx +30 -2
- package/docs/zh/configure/app/usage.mdx +1 -1
- package/docs/zh/guides/advanced-features/bff/data-platform.mdx +3 -1
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +3 -1
- package/docs/zh/guides/advanced-features/international/api.mdx +4 -1
- package/docs/zh/guides/advanced-features/international/configuration.mdx +1 -0
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +1 -1
- package/docs/zh/guides/advanced-features/international/routing.mdx +45 -2
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +2 -3
- package/docs/zh/guides/basic-features/deploy.mdx +2 -2
- package/docs/zh/guides/basic-features/render/_meta.json +1 -10
- package/docs/zh/guides/basic-features/render/overview.mdx +0 -1
- package/docs/zh/guides/basic-features/render/rsc.mdx +0 -1
- package/docs/zh/guides/basic-features/routes/routes.mdx +24 -9
- package/docs/zh/guides/basic-features/testing/_meta.json +1 -1
- package/docs/zh/guides/concept/server.mdx +2 -2
- package/docs/zh/guides/get-started/quick-start.mdx +1 -1
- package/docs/zh/guides/get-started/tech-stack.mdx +10 -4
- package/docs/zh/guides/get-started/ultramodern.mdx +88 -4
- package/docs/zh/guides/upgrade/config.mdx +1 -2
- package/docs/zh/guides/upgrade/other.md +4 -5
- package/package.json +15 -14
- package/rspress.config.ts +17 -5
- package/src/components/Footer/index.tsx +3 -3
- package/src/components/SecondaryTitle/index.module.css +7 -2
- package/src/components/ShowcaseList/useShowcases.ts +23 -65
- package/src/i18n/enUS.ts +0 -9
- package/src/i18n/zhCN.ts +0 -9
- package/src/sandbox/csr-auth/src/routes/page-tsx.txt +1 -1
- package/static/img/logo.svg +7 -0
- package/static/img/social-card.svg +12 -0
- package/builder-doc/docs/en/config/performance/rsdoctor.md +0 -37
- package/builder-doc/docs/zh/config/performance/rsdoctor.md +0 -37
- package/docs/en/guides/basic-features/render/tanstack-rsc.mdx +0 -226
- package/docs/en/guides/basic-features/testing/cypress.mdx +0 -95
- package/docs/en/guides/basic-features/testing/jest.mdx +0 -148
- package/docs/en/guides/basic-features/testing/vitest.mdx +0 -100
- package/docs/zh/guides/basic-features/render/tanstack-rsc.mdx +0 -226
- package/docs/zh/guides/basic-features/testing/cypress.mdx +0 -95
- package/docs/zh/guides/basic-features/testing/jest.mdx +0 -148
- package/docs/zh/guides/basic-features/testing/vitest.mdx +0 -100
- package/main-doc/docs/en/guides/get-started/ultramodern.mdx +0 -320
- package/main-doc/docs/zh/guides/get-started/ultramodern.mdx +0 -304
|
@@ -4,9 +4,9 @@ sidebar_position: 1
|
|
|
4
4
|
|
|
5
5
|
# Commands
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
UltraModern.js has some built-in commands that can help you quickly start a development server, build production environment code, and more.
|
|
8
8
|
|
|
9
|
-
Through this chapter, you can learn about the built-in commands of
|
|
9
|
+
Through this chapter, you can learn about the built-in commands of UltraModern.js and how to use them.
|
|
10
10
|
|
|
11
11
|
## modern dev
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@ Options:
|
|
|
23
23
|
--api-only only start API service
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
After running `modern dev`,
|
|
26
|
+
After running `modern dev`, UltraModern.js will watch source file changes and apply hot module replacement.
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
$ modern dev
|
|
@@ -80,77 +80,67 @@ Options:
|
|
|
80
80
|
-w --watch turn on watch mode, watch for changes and rebuild
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
## modern
|
|
83
|
+
## modern runtime status
|
|
84
84
|
|
|
85
|
-
The `modern
|
|
86
|
-
|
|
87
|
-
For example, add application entry, enable some optional features such as BFF, micro frontend, etc.
|
|
85
|
+
The `modern runtime status` command reads the runtime status endpoint and prints the response. It targets `http://127.0.0.1:8080/_modern/runtime/status` by default.
|
|
88
86
|
|
|
89
87
|
```bash
|
|
90
|
-
Usage: modern
|
|
88
|
+
Usage: modern runtime status [options]
|
|
91
89
|
|
|
92
90
|
Options:
|
|
93
|
-
--
|
|
94
|
-
--
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
--
|
|
98
|
-
--
|
|
99
|
-
-h, --help
|
|
91
|
+
--endpoint <endpoint> runtime status endpoint URL or path
|
|
92
|
+
--token <token> runtime status auth token
|
|
93
|
+
--token-env <name> environment variable name that stores runtime status auth token (default: "MODERN_RUNTIME_SIGNAL_TOKEN")
|
|
94
|
+
--header-name <name> auth header name (default: "x-modernjs-runtime-signal-token")
|
|
95
|
+
--timeout <ms> request timeout in milliseconds (default: "5000")
|
|
96
|
+
--json output as JSON format for machine reading
|
|
97
|
+
-h, --help display help for command
|
|
100
98
|
```
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
If `--endpoint` is a path, it is resolved against `http://127.0.0.1:8080`. If `--token` is omitted, the command reads the token from the environment variable named by `--token-env`.
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
By default, the command formats the response as readable key/value lines. Add `--json` to print the raw JSON payload.
|
|
105
103
|
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
? Please select the operation you want: Create Element
|
|
109
|
-
? Please select the type of element to create: New "entry"
|
|
110
|
-
? Please fill in the entry name: entry
|
|
104
|
+
```bash
|
|
105
|
+
modern runtime status --json
|
|
111
106
|
```
|
|
112
107
|
|
|
113
|
-
|
|
108
|
+
## modern runtime fallback-signal
|
|
114
109
|
|
|
115
|
-
|
|
110
|
+
The `modern runtime fallback-signal` command posts a runtime fallback signal to the canary contract-gate endpoint. It targets `http://127.0.0.1:8080/_modern/contract-gates/runtime-fallback` by default.
|
|
116
111
|
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
```bash
|
|
113
|
+
Usage: modern runtime fallback-signal [options]
|
|
114
|
+
|
|
115
|
+
Options:
|
|
116
|
+
--app <appName> remote app name
|
|
117
|
+
--endpoint <endpoint> runtime fallback signal endpoint URL or path
|
|
118
|
+
--reason <reason> fallback reason (default: "runtime_fallback")
|
|
119
|
+
--phase <phase> fallback phase (default: "load")
|
|
120
|
+
--entry <entry> remote entry URL
|
|
121
|
+
--runtime-digest <digest> runtime digest value
|
|
122
|
+
--metadata <json> metadata JSON object string
|
|
123
|
+
--token <token> runtime signal auth token
|
|
124
|
+
--token-env <name> environment variable name that stores runtime signal auth token (default: "MODERN_RUNTIME_SIGNAL_TOKEN")
|
|
125
|
+
--header-name <name> auth header name (default: "x-modernjs-runtime-signal-token")
|
|
126
|
+
--timeout <ms> request timeout in milliseconds (default: "5000")
|
|
127
|
+
--json output as JSON format for machine reading
|
|
128
|
+
-h, --help display help for command
|
|
124
129
|
```
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
The `--config` parameter needs to use a JSON string.
|
|
131
|
+
The request body always includes `appName`, `reason`, and `phase`. It includes `entry`, `runtimeDigest`, and `metadata` only when those options are provided. `--metadata` must be a JSON object string.
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
```bash
|
|
134
|
+
modern runtime fallback-signal --app crm-shell --reason remote_load_failed --phase load --json
|
|
135
|
+
```
|
|
131
136
|
|
|
132
137
|
import ServeCommand from '@site-docs-en/components/serve-command';
|
|
133
138
|
|
|
134
139
|
<ServeCommand />
|
|
135
140
|
|
|
136
|
-
## modern upgrade
|
|
137
|
-
|
|
138
|
-
Execute the command `npx modern upgrade` in the project, by default, dependencies in the `package.json` are updated to the latest version.
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
Usage: modern upgrade [options]
|
|
142
|
-
|
|
143
|
-
Options:
|
|
144
|
-
--config <config> specify the configuration file, which can be a relative or absolute path
|
|
145
|
-
--registry <registry> specify npm registry (default: "")
|
|
146
|
-
-d,--debug using debug mode to log something (default: false)
|
|
147
|
-
--cwd <cwd> app directory (default: "")
|
|
148
|
-
-h, --help show command help
|
|
149
|
-
```
|
|
150
|
-
|
|
151
141
|
## modern inspect
|
|
152
142
|
|
|
153
|
-
The `modern inspect` command is used to view the
|
|
143
|
+
The `modern inspect` command is used to view the UltraModern.js config, [Rsbuild config](https://v2.rsbuild.rs/config/index) and Rspack config of the project.
|
|
154
144
|
|
|
155
145
|
```bash
|
|
156
146
|
Usage: modern inspect [options]
|
|
@@ -17,7 +17,7 @@ Modern.js 7 ~ 8 月的最新版本为 v1.17.0,本双月的主要更新有:
|
|
|
17
17
|
|
|
18
18
|
Modern.js 框架和相关插件完成对 React 18 的适配。现在,只需要将项目中的 `react`、`react-dom` 两个包的版本,升级到最新的 React 18 大版本,就可以使用 React 18 的新功能。
|
|
19
19
|
|
|
20
|
-
注意,使用 `@modern-js
|
|
20
|
+
注意,使用 `@bleedingdev/modern-js-create` 命令默认创建的项目,安装的依赖 `react`、`react-dom` 的版本仍然为 17,如果希望使用 React 18,请手动升级这两个包的版本。
|
|
21
21
|
|
|
22
22
|
另外,SSR 流式渲染功能,目前尚在开发中,暂不支持。
|
|
23
23
|
|
|
@@ -15,7 +15,7 @@ Modern.js 9 ~ 10 月的最新版本为 v1.21.0,本双月的主要更新有:
|
|
|
15
15
|
|
|
16
16
|
Modern.js 框架完成了对 pnpm v7 的变更适配。
|
|
17
17
|
|
|
18
|
-
使用 `
|
|
18
|
+
使用 `pnpm dlx @bleedingdev/modern-js-create` 创建项目时会根据用户当前环境的 pnpm 版本进行安装依赖操作,并且在初始化项目中会在 `.npmrc` 中添加
|
|
19
19
|
`strict-peer-dependencies=false` 配置,避免安装时由于 `peerDependencies` 缺失导致安装依赖失败问题。
|
|
20
20
|
同时适配 `release`、`deploy` 命令对 pnpm v7 的支持。
|
|
21
21
|
|
|
@@ -67,7 +67,7 @@ pnpm run command --options
|
|
|
67
67
|
|
|
68
68
|
- husky 升级至 v8
|
|
69
69
|
|
|
70
|
-
使用 `
|
|
70
|
+
使用 `pnpm dlx @bleedingdev/modern-js-create` 创建项目时,husky 会默认安装 v8 版本,并移除 `package.json` 中 husky 的配置,使用 `.husky` 文件夹的形式管理 husky 配置。
|
|
71
71
|
|
|
72
72
|
在初次安装依赖时需要执行 `npx husky install` 进行 husky 初始化,默认项目会在 prepare 命令中完成,如果 husky 配置未生效,可通过手动执行完成 husky 配置。
|
|
73
73
|
|
|
@@ -39,8 +39,7 @@ nvm use 22
|
|
|
39
39
|
### Install pnpm
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
|
|
43
|
-
corepack enable
|
|
42
|
+
mise install
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
### Install Dependencies
|
|
@@ -125,7 +124,7 @@ pnpm run reset
|
|
|
125
124
|
|
|
126
125
|
If you've fixed a bug or added code that should be tested, then add some tests.
|
|
127
126
|
|
|
128
|
-
You can add
|
|
127
|
+
Modern.js uses [Rstest](https://rstest.rs/) for unit tests across the repository. You can add test cases in the `<PACKAGE_DIR>/tests` folder, using Rstest syntax.
|
|
129
128
|
|
|
130
129
|
### Run Unit Tests
|
|
131
130
|
|
|
@@ -24,8 +24,4 @@ Modern.js follows the [Semantic Versioning](https://semver.org) specification.
|
|
|
24
24
|
|
|
25
25
|
## Version Upgrade
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npx modern upgrade
|
|
31
|
-
```
|
|
27
|
+
Modern.js 3.0 no longer ships the `modern upgrade` command. When you need to upgrade a project, follow the manual migration steps in [Upgrade](/guides/get-started/upgrade).
|
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
UltraModern.js provides the BleedingDev create package to create SuperApp
|
|
2
|
+
workspaces. It does not require global installation and can be run on-demand
|
|
3
|
+
using `pnpm dlx`.
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
The supported pnpm command is the scoped package specifier:
|
|
6
|
+
`pnpm dlx @bleedingdev/modern-js-create <target>`. Do not shorten it to
|
|
7
|
+
`pnpm dlx modern-js-create`; there is no unscoped package by that name.
|
|
8
|
+
|
|
9
|
+
You can initialize the empty directory you are already in:
|
|
4
10
|
|
|
5
11
|
```bash
|
|
6
12
|
mkdir myapp && cd myapp
|
|
7
|
-
|
|
13
|
+
pnpm dlx @bleedingdev/modern-js-create .
|
|
8
14
|
```
|
|
9
15
|
|
|
10
16
|
You can also create a project directly in a new directory:
|
|
11
17
|
|
|
12
18
|
```bash
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
To initialize a TanStack Router template:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npx @modern-js/create@latest myapp --router tanstack
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
To initialize with Tailwind CSS v4 scaffold:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npx @modern-js/create@latest myapp --tailwind
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
To initialize TanStack Router with Tailwind CSS v4:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npx @modern-js/create@latest myapp --router tanstack --tailwind
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
To initialize BFF scaffold with the current default runtime:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npx @modern-js/create@latest myapp --bff
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
To initialize BFF scaffold with Effect HttpApi runtime:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npx @modern-js/create@latest myapp --bff-runtime effect
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
To initialize BFF scaffold with Hono runtime:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npx @modern-js/create@latest myapp --bff-runtime hono
|
|
19
|
+
pnpm dlx @bleedingdev/modern-js-create my-super-app
|
|
50
20
|
```
|
|
51
21
|
|
|
52
22
|
To initialize with workspace protocol dependencies (for local monorepo testing of unreleased Modern.js packages):
|
|
53
23
|
|
|
54
24
|
```bash
|
|
55
|
-
|
|
25
|
+
pnpm dlx @bleedingdev/modern-js-create my-super-app --workspace
|
|
56
26
|
```
|
|
57
27
|
|
|
58
|
-
|
|
28
|
+
The BleedingDev create package will directly create the application without providing an interactive Q & A interface:
|
|
59
29
|
|
|
60
30
|
```bash
|
|
61
|
-
🚀 Welcome to
|
|
31
|
+
🚀 Welcome to UltraModern.js
|
|
62
32
|
|
|
63
|
-
📦 Creating project "
|
|
33
|
+
📦 Creating project "my-super-app"...
|
|
64
34
|
|
|
65
35
|
✨ Project created successfully! 🎉
|
|
66
36
|
|
|
@@ -68,7 +38,7 @@ npx @modern-js/create@latest myapp --router tanstack --bff-runtime effect --work
|
|
|
68
38
|
|
|
69
39
|
📁 Enter the project directory:
|
|
70
40
|
|
|
71
|
-
cd
|
|
41
|
+
cd my-super-app
|
|
72
42
|
|
|
73
43
|
🔧 Initialize Git repository:
|
|
74
44
|
|
|
@@ -87,33 +57,37 @@ Now, the project structure is as follows:
|
|
|
87
57
|
|
|
88
58
|
```
|
|
89
59
|
.
|
|
90
|
-
├──
|
|
91
|
-
|
|
60
|
+
├── apps
|
|
61
|
+
│ └── shell-super-app
|
|
92
62
|
├── package.json
|
|
93
|
-
├──
|
|
94
|
-
├──
|
|
95
|
-
│ ├──
|
|
96
|
-
│
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
│ └── page.tsx
|
|
101
|
-
└── tsconfig.json
|
|
63
|
+
├── packages
|
|
64
|
+
│ ├── shared-contracts
|
|
65
|
+
│ ├── shared-design-tokens
|
|
66
|
+
│ └── shared-effect-client
|
|
67
|
+
├── scripts
|
|
68
|
+
├── topology
|
|
69
|
+
└── verticals
|
|
102
70
|
```
|
|
103
71
|
|
|
104
|
-
|
|
72
|
+
The default workspace starts shell-only and installs the published BleedingDev
|
|
73
|
+
package aliases:
|
|
105
74
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
75
|
+
```bash
|
|
76
|
+
pnpm dlx @bleedingdev/modern-js-create my-super-app
|
|
77
|
+
```
|
|
109
78
|
|
|
110
|
-
|
|
111
|
-
package. It defaults to the canonical Effect + TanStack + SSR + Micro Verticals
|
|
112
|
-
workspace and published BleedingDev package aliases:
|
|
79
|
+
From a generated SuperApp workspace, add a business MicroVertical in place:
|
|
113
80
|
|
|
114
81
|
```bash
|
|
115
|
-
pnpm dlx @bleedingdev/modern-js-create
|
|
82
|
+
pnpm dlx @bleedingdev/modern-js-create transportation --vertical
|
|
116
83
|
```
|
|
117
84
|
|
|
118
|
-
The
|
|
119
|
-
and
|
|
85
|
+
The `--vertical` command mutates the current workspace: it adds the vertical
|
|
86
|
+
package and wires topology, ownership metadata, shell Module Federation,
|
|
87
|
+
development overlays, package dependencies, generated contracts, route-owned
|
|
88
|
+
i18n, CSS isolation, and the Effect BFF/client surface.
|
|
89
|
+
|
|
90
|
+
The lower-level `--ultramodern-package-*` flags are reserved for release
|
|
91
|
+
engineering and local package-source testing. BleedingDev packages are published
|
|
92
|
+
through GitHub Actions trusted publishing; do not publish them manually from a
|
|
93
|
+
developer machine.
|
|
@@ -9,8 +9,7 @@ import NodeVersion from '@site-docs-en/components/nodeVersion.mdx';
|
|
|
9
9
|
It is recommended to use [pnpm](https://pnpm.io/installation) to manage dependencies:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
13
|
-
corepack prepare pnpm@11.1.2 --activate
|
|
12
|
+
mise use pnpm@11.4.0
|
|
14
13
|
```
|
|
15
14
|
|
|
16
15
|
:::note
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## modern serve
|
|
2
2
|
|
|
3
|
-
The `modern serve` command is used to start
|
|
3
|
+
The `modern serve` command is used to start an UltraModern.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
4
|
|
|
5
5
|
```bash
|
|
6
6
|
Usage: modern serve [options]
|
|
@@ -123,13 +123,35 @@ export default defineConfig({
|
|
|
123
123
|
}
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
- **Default:**
|
|
126
|
+
- **Default:**
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
{
|
|
130
|
+
enabled: true,
|
|
131
|
+
requireEnvelope: false,
|
|
132
|
+
envelopeHeader: 'x-modernjs-data-envelope',
|
|
133
|
+
validateOrigin: true,
|
|
134
|
+
requireTraceContext: false,
|
|
135
|
+
batch: {
|
|
136
|
+
enabled: true,
|
|
137
|
+
endpoint: '/_data/batch',
|
|
138
|
+
maxBatchSize: 16,
|
|
139
|
+
maxBatchBytes: 64 * 1024,
|
|
140
|
+
flushIntervalMs: 8,
|
|
141
|
+
maxConcurrency: 4,
|
|
142
|
+
requestTimeoutMs: 10000,
|
|
143
|
+
allowedMethods: ['GET'],
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
```
|
|
127
147
|
|
|
128
148
|
Configure request-envelope validation for Effect runtime.
|
|
129
149
|
|
|
130
150
|
Generated Effect client requests batching against `${bff.prefix}${batch.endpoint}` (for example, `/bff-api/_data/batch`).
|
|
131
151
|
|
|
132
|
-
|
|
152
|
+
Envelope validation is enabled by default but optional: requests without an envelope pass unless `requireEnvelope` is `true`. If an envelope is present, runtime validates it against the configured namespace, origin, trace, and selection policy. `expectedNamespace` is unset by default, and `selection` has no default limits unless configured.
|
|
153
|
+
|
|
154
|
+
Origin validation is enabled by default. Runtime compares envelope origin with request `Origin` header first, then falls back to request URL origin; set `validateOrigin: false` to disable that comparison.
|
|
133
155
|
|
|
134
156
|
```ts title="modern.config.ts"
|
|
135
157
|
export default defineConfig({
|
|
@@ -149,4 +171,6 @@ export default defineConfig({
|
|
|
149
171
|
});
|
|
150
172
|
```
|
|
151
173
|
|
|
152
|
-
`batch.flushIntervalMs` controls client-side micro-batch window in generated Effect client. `maxConcurrency` and `requestTimeoutMs` are applied by the server batch gateway when dispatching items.
|
|
174
|
+
`batch.flushIntervalMs` controls the client-side micro-batch window in the generated Effect client. `maxConcurrency` and `requestTimeoutMs` are applied by the server batch gateway when dispatching items.
|
|
175
|
+
|
|
176
|
+
The generated `effectBff.client.*` API only exists for loader-materialized `@api/effect/*` imports. Directly importing the server entry (`api/effect/index`) exposes the Effect BFF definition; its `client` property is a placeholder that fails on operation access.
|
|
@@ -25,4 +25,4 @@ export default defineConfig({
|
|
|
25
25
|
- Set to `'hono'` to run BFF only from file-convention handlers under `api/lambda/**`.
|
|
26
26
|
|
|
27
27
|
There is no implicit fallback between runtimes. Choose one runtime mode per app.
|
|
28
|
-
|
|
28
|
+
Generated UltraModern apps use the Effect lane by default; set `runtimeFramework: 'hono'` only for the compatibility runtime.
|
|
@@ -11,22 +11,23 @@ type RsdoctorConfig =
|
|
|
11
11
|
| boolean
|
|
12
12
|
| {
|
|
13
13
|
enabled?: boolean;
|
|
14
|
+
disableClientServer?: boolean;
|
|
14
15
|
};
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
- **Default:** `
|
|
18
|
+
- **Default:** `undefined`, Rsdoctor is disabled unless this option is configured.
|
|
18
19
|
|
|
19
|
-
Configure Rsdoctor diagnostics in Modern.js build.
|
|
20
|
+
Configure Rsdoctor diagnostics in Modern.js build. Set this option to `true` to enable Rsdoctor:
|
|
20
21
|
|
|
21
22
|
```ts title="modern.config.ts"
|
|
22
23
|
export default defineConfig({
|
|
23
24
|
performance: {
|
|
24
|
-
rsdoctor:
|
|
25
|
+
rsdoctor: true,
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
You can also use object form
|
|
30
|
+
You can also use object form. When an object is provided, Rsdoctor is enabled unless `enabled` is set to `false`:
|
|
30
31
|
|
|
31
32
|
```ts title="modern.config.ts"
|
|
32
33
|
export default defineConfig({
|
|
@@ -37,3 +38,5 @@ export default defineConfig({
|
|
|
37
38
|
},
|
|
38
39
|
});
|
|
39
40
|
```
|
|
41
|
+
|
|
42
|
+
To disable Rsdoctor after enabling it in shared config, set `rsdoctor` to `false` or set `enabled` to `false`.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
title: tsChecker
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { PackageManagerTabs } from '@theme';
|
|
6
|
+
|
|
5
7
|
# tools.tsChecker
|
|
6
8
|
|
|
7
9
|
- **Type:** `Object | Function`
|
|
@@ -14,6 +16,8 @@ const defaultOptions = {
|
|
|
14
16
|
memoryLimit: 8192,
|
|
15
17
|
// use tsconfig of user project
|
|
16
18
|
configFile: tsconfigPath,
|
|
19
|
+
// use TypeScript Go checker by default
|
|
20
|
+
tsgo: true,
|
|
17
21
|
// use TS-Go native preview of user project
|
|
18
22
|
typescriptPath: require.resolve('@typescript/native-preview/package.json'),
|
|
19
23
|
},
|
|
@@ -35,7 +39,7 @@ const defaultOptions = {
|
|
|
35
39
|
},
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
By default,
|
|
42
|
+
By default, the [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) is enabled for type checking. You can use `output.disableTsChecker` config to disable it.
|
|
39
43
|
|
|
40
44
|
## Example
|
|
41
45
|
|
|
@@ -53,4 +57,28 @@ export default {
|
|
|
53
57
|
};
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
## TypeScript Go by Default
|
|
61
|
+
|
|
62
|
+
Type checking runs on [TypeScript Go](https://github.com/microsoft/typescript-go) (`tsgo`) by default in this fork. The capability is provided by [`ts-checker-rspack-plugin`](https://github.com/rstackjs/ts-checker-rspack-plugin), which is integrated by [`@rsbuild/plugin-type-check`](https://github.com/rstackjs/rsbuild-plugin-type-check), and reduces type-checking time by about 5-10x.
|
|
63
|
+
|
|
64
|
+
`@typescript/native-preview` ships with the builder, so no extra install is needed. To pin your own version, install it in your project:
|
|
65
|
+
|
|
66
|
+
<PackageManagerTabs command="install @typescript/native-preview -D" />
|
|
67
|
+
|
|
68
|
+
When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `@typescript/native-preview/package.json`. If you manually set `typescript.typescriptPath`, it must be an absolute path to `@typescript/native-preview/package.json`.
|
|
69
|
+
|
|
70
|
+
To fall back to the classic TypeScript checker, set `typescript.tsgo` to `false` and make sure `typescript` is installed in your project:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
export default {
|
|
74
|
+
tools: {
|
|
75
|
+
tsChecker: {
|
|
76
|
+
typescript: {
|
|
77
|
+
tsgo: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For supported options and limitations, please refer to [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
|
|
@@ -55,12 +55,14 @@ export default defineConfig({
|
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Envelope validation is enabled by default but does not require an envelope unless `requireEnvelope` is set. Origin validation is enabled by default; set `validateOrigin: false` to skip comparing the envelope origin against the incoming `Origin` header, or the request URL origin when the header is absent.
|
|
59
59
|
|
|
60
60
|
## Generated Effect client behavior
|
|
61
61
|
|
|
62
62
|
When using the generated Effect client (`@api/effect/index`), Modern.js automatically attaches a serialized data envelope header (`x-modernjs-data-envelope`) for same-origin requests.
|
|
63
63
|
|
|
64
|
+
The generated client is loader-materialized. Import it from `@api/effect/*` in browser or client-bundled code; direct imports of the server entry (`api/effect/index`) expose the Effect BFF definition and only provide a placeholder `client`.
|
|
65
|
+
|
|
64
66
|
The envelope includes:
|
|
65
67
|
|
|
66
68
|
- operation metadata
|
|
@@ -105,7 +105,7 @@ const layer = HttpApiBuilder.layer(bffEffectApi).pipe(
|
|
|
105
105
|
export default defineEffectBff({ api: bffEffectApi, layer });
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Call Effect endpoints from
|
|
108
|
+
Call Effect endpoints from browser code via `@api/effect/index`:
|
|
109
109
|
|
|
110
110
|
```ts title="src/routes/page.tsx"
|
|
111
111
|
import effectBff from '@api/effect/index';
|
|
@@ -113,6 +113,8 @@ import effectBff from '@api/effect/index';
|
|
|
113
113
|
const response = await effectBff.client.hello.ping({});
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
The `effectBff.client.*` surface is materialized by the BFF loader for `@api/effect/*` imports. Do not import `api/effect/index` directly and expect `client` to run in server code, scripts, or tests; direct entry imports expose the server runtime definition, and `client` is only a typed placeholder there.
|
|
117
|
+
|
|
116
118
|
import Hono from '@site-docs-en/components/hono';
|
|
117
119
|
|
|
118
120
|
<Hono />
|
|
@@ -15,10 +15,13 @@ title: API Reference
|
|
|
15
15
|
| `language` | `string` | Current language code |
|
|
16
16
|
| `changeLanguage` | `(lang: string) => Promise<void>` | Switches language |
|
|
17
17
|
| `supportedLanguages` | `string[]` | Supported language list, from `localeDetection.languages` |
|
|
18
|
+
| `localisedUrls` | `boolean \| Record<string, Record<string, string>>` | Localised URL mapping from `localeDetection.localisedUrls` |
|
|
18
19
|
| `isLanguageSupported` | `(lang: string) => boolean` | Checks whether a language is in the supported list |
|
|
19
20
|
| `isResourcesReady` | `boolean` | Whether translation resources for the current language have finished loading |
|
|
20
21
|
| `i18nInstance` | `I18nInstance` | i18next instance for advanced scenarios |
|
|
21
22
|
|
|
23
|
+
When `localePathRedirect` is enabled and `localisedUrls` is omitted, Modern.js keeps prefix-only paths such as `/en/about`. Translated path segments are enabled only by a non-empty `localisedUrls` map. Route generation validates every localisable path and every configured language only while that map is enabled.
|
|
24
|
+
|
|
22
25
|
### Basic Usage
|
|
23
26
|
|
|
24
27
|
```tsx
|
|
@@ -91,7 +94,7 @@ A route link component with a locale prefix.
|
|
|
91
94
|
| `children` | `React.ReactNode` | Yes | Link content |
|
|
92
95
|
| `replace` | `boolean` | No | Uses `history.replace` instead of `push` |
|
|
93
96
|
| `state` | `any` | No | State passed to the target route |
|
|
94
|
-
| Other Link props | - | No |
|
|
97
|
+
| Other Link props | - | No | Passed to the active router link when a router is available |
|
|
95
98
|
|
|
96
99
|
### Usage
|
|
97
100
|
|
|
@@ -49,6 +49,7 @@ export default defineConfig({
|
|
|
49
49
|
| `languages` | `string[]` | `[]` | Supported language list |
|
|
50
50
|
| `fallbackLanguage` | `string` | `''` | Fallback language when detection fails |
|
|
51
51
|
| `localePathRedirect` | `boolean` | `false` | Handles URL locale prefix recognition, redirects, and switching. See [Routing Integration](./routing.md#enable-locale-path-prefixes) |
|
|
52
|
+
| `localisedUrls` | `boolean \| Record<string, Record<string, string>>` | Prefix-only behavior | Localised route path map. Only a non-empty map enables translated path segments; omitted, `true`, `false`, and `{}` keep locale prefixes without translating path segments. |
|
|
52
53
|
| `i18nextDetector` | `boolean` | `false` | Enables the i18next detector (Cookie / Header, etc.) |
|
|
53
54
|
| `detection` | `LanguageDetectorOptions` | - | Detailed i18next detector configuration. See [Locale Detection](./locale-detection.md) |
|
|
54
55
|
| `ignoreRedirectRoutes` | `string[] \| Function` | - | Routes that skip redirects. See [Locale Detection](./locale-detection.md#ignoreredirectroutes) |
|
|
@@ -113,7 +113,7 @@ i18nPlugin({
|
|
|
113
113
|
|
|
114
114
|
## ignoreRedirectRoutes
|
|
115
115
|
|
|
116
|
-
Specify which paths should skip locale path redirects.
|
|
116
|
+
Specify which additional paths should skip locale path redirects. Modern.js automatically skips server API routes, the default `/api` BFF prefix when BFF is configured, and custom `bff.prefix` values. Use `ignoreRedirectRoutes` for non-API application paths that also do not need a locale prefix.
|
|
117
117
|
|
|
118
118
|
**Syntax 1: string array** (supports exact match and prefix match)
|
|
119
119
|
|