@bleedingdev/modern-js-main-doc 3.2.0-ultramodern.120 → 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 +59 -69
- package/docs/en/community/blog/v2-release-note.mdx +5 -5
- package/docs/en/community/blog/v3-release-note.mdx +1 -1
- package/docs/en/community/releases.mdx +1 -5
- package/docs/en/components/build-output.mdx +1 -1
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/deploy-command.mdx +3 -3
- package/docs/en/components/init-app.mdx +4 -0
- package/docs/en/components/serve-command.mdx +3 -3
- package/docs/en/configure/app/bff/effect.mdx +27 -3
- package/docs/en/configure/app/performance/rsdoctor.mdx +7 -4
- package/docs/en/configure/app/usage.mdx +6 -6
- 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 +1 -1
- package/docs/en/guides/advanced-features/international/configuration.mdx +1 -1
- package/docs/en/guides/advanced-features/international/locale-detection.mdx +1 -1
- package/docs/en/guides/advanced-features/international/routing.mdx +5 -3
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +2 -3
- package/docs/en/guides/basic-features/debug/using-storybook.mdx +1 -1
- package/docs/en/guides/basic-features/deploy.mdx +14 -14
- package/docs/en/guides/basic-features/env-vars.mdx +2 -2
- 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/config-routes.mdx +2 -2
- package/docs/en/guides/basic-features/routes/routes.mdx +7 -7
- 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/ultramodern.mdx +10 -4
- package/docs/en/guides/topic-detail/module-federation/application.mdx +1 -1
- package/docs/en/guides/topic-detail/module-federation/deploy.mdx +2 -2
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +5 -5
- package/docs/en/guides/troubleshooting/builder.mdx +1 -1
- 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 +56 -66
- package/docs/zh/community/blog/v2-release-note.mdx +5 -5
- package/docs/zh/community/blog/v3-release-note.mdx +1 -1
- package/docs/zh/community/releases.mdx +1 -5
- package/docs/zh/components/build-output.mdx +1 -1
- package/docs/zh/components/debug-app.mdx +1 -1
- package/docs/zh/components/deploy-command.mdx +3 -3
- package/docs/zh/components/init-app.mdx +16 -47
- package/docs/zh/components/serve-command.mdx +3 -3
- package/docs/zh/configure/app/bff/effect.mdx +26 -2
- package/docs/zh/configure/app/performance/rsdoctor.mdx +7 -4
- package/docs/zh/configure/app/usage.mdx +6 -6
- 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 +1 -1
- package/docs/zh/guides/advanced-features/international/configuration.mdx +1 -1
- package/docs/zh/guides/advanced-features/international/locale-detection.mdx +1 -1
- package/docs/zh/guides/advanced-features/international/routing.mdx +5 -3
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +2 -3
- package/docs/zh/guides/basic-features/debug/using-storybook.mdx +1 -1
- package/docs/zh/guides/basic-features/deploy.mdx +13 -13
- package/docs/zh/guides/basic-features/env-vars.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/config-routes.mdx +2 -2
- package/docs/zh/guides/basic-features/routes/routes.mdx +7 -7
- 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/ultramodern.mdx +17 -22
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +1 -1
- package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +2 -2
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +5 -5
- package/docs/zh/guides/troubleshooting/builder.mdx +1 -1
- package/docs/zh/guides/upgrade/config.mdx +1 -2
- package/docs/zh/guides/upgrade/other.md +4 -4
- package/package.json +5 -4
- 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/zh/guides/basic-features/render/tanstack-rsc.mdx +0 -226
- package/main-doc/docs/en/guides/get-started/ultramodern.mdx +0 -403
- package/main-doc/docs/zh/guides/get-started/ultramodern.mdx +0 -363
|
@@ -15,12 +15,12 @@ Currently, Modern.js only supports running in a Node.js environment. Support for
|
|
|
15
15
|
|
|
16
16
|
## Build Deployment Products
|
|
17
17
|
|
|
18
|
-
Running the `
|
|
18
|
+
Running the `modern deploy` command will automatically produce deployment products. This process includes optimizing Bundler build products and their dependencies, detecting the current deployment platform, and automatically generating deployment products that can run on that platform.
|
|
19
19
|
|
|
20
|
-
If you want to generate and test the output locally for a specific deployment platform, you can specify the platform by setting the environment variable: `
|
|
20
|
+
If you want to generate and test the output locally for a specific deployment platform, you can specify the platform by setting the environment variable: `modern deploy`:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
MODERNJS_DEPLOY=netlify npx
|
|
23
|
+
MODERNJS_DEPLOY=netlify npx modern deploy
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
:::info
|
|
@@ -36,10 +36,10 @@ By default, Modern.js outputs builds that can be run in a Node.js environment wh
|
|
|
36
36
|
Use the following command to build the project:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
npx
|
|
39
|
+
npx modern deploy
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
When running the `
|
|
42
|
+
When running the `modern deploy` command, UltraModern.js will generate runnable products and output the following content in terminal:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
45
|
Static directory: `.output/static`
|
|
@@ -67,7 +67,7 @@ Assume that the name in the `package.json` of the current project is `app`. Taki
|
|
|
67
67
|
{
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
70
|
-
"deploy": "pnpm run build:packages &&
|
|
70
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
```
|
|
@@ -78,7 +78,7 @@ If you use Rush as your Monorepo management tool, you can add the following comm
|
|
|
78
78
|
{
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build:packages": "rush rebuild --to-except app",
|
|
81
|
-
"deploy": "rushx build:packages &&
|
|
81
|
+
"deploy": "rushx build:packages && modern deploy"
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
```
|
|
@@ -108,7 +108,7 @@ Add the following content to `netlify.toml`:
|
|
|
108
108
|
```toml
|
|
109
109
|
[build]
|
|
110
110
|
publish = "dist"
|
|
111
|
-
command = "
|
|
111
|
+
command = "modern deploy"
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
:::info
|
|
@@ -125,7 +125,7 @@ Full-stack projects refer to projects that use Custom Web Server, SSR or BFF. Th
|
|
|
125
125
|
```toml title="netlify.toml"
|
|
126
126
|
[build]
|
|
127
127
|
publish = "dist"
|
|
128
|
-
command = "
|
|
128
|
+
command = "modern deploy"
|
|
129
129
|
|
|
130
130
|
[functions]
|
|
131
131
|
directory = ".netlify/functions"
|
|
@@ -173,7 +173,7 @@ Add the following script in `packages/app/package.json`, before executing the de
|
|
|
173
173
|
{
|
|
174
174
|
"scripts": {
|
|
175
175
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
176
|
-
"deploy": "pnpm run build:packages &&
|
|
176
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
```
|
|
@@ -213,7 +213,7 @@ Add the following content to `vercel.json`:
|
|
|
213
213
|
|
|
214
214
|
```json title="vercel.json"
|
|
215
215
|
{
|
|
216
|
-
"buildCommand": "
|
|
216
|
+
"buildCommand": "modern deploy",
|
|
217
217
|
"outputDirectory": ".vercel/output"
|
|
218
218
|
}
|
|
219
219
|
```
|
|
@@ -281,7 +281,7 @@ Add the following script to `packages/app/package.json` to run `build` command o
|
|
|
281
281
|
{
|
|
282
282
|
"scripts": {
|
|
283
283
|
"build:packages": "pnpm --filter 'app^...' run build",
|
|
284
|
-
"deploy": "pnpm run build:packages &&
|
|
284
|
+
"deploy": "pnpm run build:packages && modern deploy"
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
```
|
|
@@ -326,7 +326,7 @@ For branch deployment, follow these steps:
|
|
|
326
326
|
```
|
|
327
327
|
"scripts": {
|
|
328
328
|
//...
|
|
329
|
-
"deploy:gh-pages": "MODERNJS_DEPLOY=ghPages
|
|
329
|
+
"deploy:gh-pages": "MODERNJS_DEPLOY=ghPages modern deploy && gh-pages -d .output"
|
|
330
330
|
}
|
|
331
331
|
```
|
|
332
332
|
|
|
@@ -334,7 +334,7 @@ For branch deployment, follow these steps:
|
|
|
334
334
|
|
|
335
335
|
:::info
|
|
336
336
|
|
|
337
|
-
1. Running `MODERNJS_DEPLOY=ghPages
|
|
337
|
+
1. Running `MODERNJS_DEPLOY=ghPages modern deploy` will build the production output for GitHub in the .output directory.
|
|
338
338
|
2. You can refer to the [project](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr)
|
|
339
339
|
:::
|
|
340
340
|
|
|
@@ -16,8 +16,8 @@ The current path prefix of the asset, which is a read-only environment variable.
|
|
|
16
16
|
|
|
17
17
|
The current execution environment and is a **read-only** environment variable whose have different values under different execution commands:
|
|
18
18
|
|
|
19
|
-
- `production`: Default value when running `
|
|
20
|
-
- `development`: Default value when running `
|
|
19
|
+
- `production`: Default value when running `modern build` or `modern serve`.
|
|
20
|
+
- `development`: Default value when running `modern dev`, also the default value in other cases.
|
|
21
21
|
|
|
22
22
|
### MODERN_ENV
|
|
23
23
|
|
|
@@ -47,6 +47,5 @@ Modern.js supports combining multiple rendering modes:
|
|
|
47
47
|
- [Server-Side Rendering (SSR)](/guides/basic-features/render/ssr)
|
|
48
48
|
- [Streaming Server-Side Rendering (Streaming SSR)](/guides/basic-features/render/streaming-ssr)
|
|
49
49
|
- [React Server Components (RSC)](/guides/basic-features/render/rsc)
|
|
50
|
-
- [TanStack Router RSC](/guides/basic-features/render/tanstack-rsc)
|
|
51
50
|
- [Static Site Generation (SSG)](/guides/basic-features/render/ssg)
|
|
52
51
|
- [Rendering Cache](/guides/basic-features/render/ssr-cache)
|
|
@@ -531,4 +531,3 @@ The project's bundle has introduced a non-19 React version, commonly seen in mon
|
|
|
531
531
|
- [Data Cache](/guides/basic-features/data/data-cache)
|
|
532
532
|
- [Server-Side Rendering (SSR)](/guides/basic-features/render/ssr)
|
|
533
533
|
- [Streaming SSR](/guides/basic-features/render/streaming-ssr)
|
|
534
|
-
- [TanStack Router RSC](/guides/basic-features/render/tanstack-rsc)
|
|
@@ -271,7 +271,7 @@ Config routes can be used together with convention routes. You can merge routes
|
|
|
271
271
|
|
|
272
272
|
:::info
|
|
273
273
|
|
|
274
|
-
Current route structure can be viewed through the [`
|
|
274
|
+
Current route structure can be viewed through the [`modern routes`](#debugging-routes) command
|
|
275
275
|
|
|
276
276
|
:::
|
|
277
277
|
|
|
@@ -319,7 +319,7 @@ Since the final structure after route merging may not be intuitive, Modern.js pr
|
|
|
319
319
|
|
|
320
320
|
```bash
|
|
321
321
|
# Generate route structure analysis report
|
|
322
|
-
npx
|
|
322
|
+
npx modern routes
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
This command will generate the final route structure in the `dist/routes-inspect.json` file, helping you understand the complete route information after merging.
|
|
@@ -474,27 +474,27 @@ For applications with higher performance requirements, prefetching can further e
|
|
|
474
474
|
|
|
475
475
|
:::tip
|
|
476
476
|
|
|
477
|
-
|
|
477
|
+
In SSR projects, same-origin route data returned by the [Data Loader](/guides/basic-features/data/data-fetch) is prefetched for matched routes with callable loaders. Set `handle.navigationWarmup.data` to `false` on a route when its loader data should not be requested before navigation.
|
|
478
478
|
|
|
479
479
|
:::
|
|
480
480
|
|
|
481
|
-
By default, same-origin links prefetch the route module when the `<Link>` renders
|
|
481
|
+
By default, same-origin links prefetch the route module and matching loader data when the `<Link>` renders. Modern.js skips these automatic warmups on Save-Data or slow network connections.
|
|
482
482
|
|
|
483
483
|
The `prefetch` attribute has four optional values:
|
|
484
484
|
|
|
485
485
|
- `render`: The default value. When the `<Link>` component is rendered, it begins warming the corresponding route module.
|
|
486
486
|
- `intent`: When users focus, hover, or touch the link, it starts warming the corresponding route module. If the intent is canceled before warmup starts, the warmup is canceled.
|
|
487
487
|
- `viewport`: When the `<Link>` component enters the viewport, it begins warming the corresponding route module.
|
|
488
|
-
- `none`: Disables automatic
|
|
488
|
+
- `none`: Disables automatic prefetching. It also disables implicit preload unless an explicit `preload` value is provided.
|
|
489
489
|
|
|
490
|
-
The `preload` attribute accepts the same timing values and defaults to `
|
|
490
|
+
The `preload` attribute accepts the same timing values and defaults to the `prefetch` timing. Explicit `preload` values always win, and `preload={false}` disables preload behavior.
|
|
491
491
|
|
|
492
|
-
To opt a route
|
|
492
|
+
To opt a route out of SSR data warmup:
|
|
493
493
|
|
|
494
494
|
```ts title="routes/page.config.ts"
|
|
495
495
|
export const handle = {
|
|
496
496
|
navigationWarmup: {
|
|
497
|
-
data:
|
|
497
|
+
data: false,
|
|
498
498
|
},
|
|
499
499
|
};
|
|
500
500
|
```
|
|
@@ -503,7 +503,7 @@ export const handle = {
|
|
|
503
503
|
|
|
504
504
|
- `render` allows you to control route-module warmup with the position of the `<Link>` component in the tree.
|
|
505
505
|
- `viewport` lets you defer module warmup until the link is close to becoming actionable.
|
|
506
|
-
- SSR data prefetching is
|
|
506
|
+
- SSR data prefetching is enabled by default; use `handle.navigationWarmup.data = false` for routes whose loader data is not safe or useful to fetch before navigation.
|
|
507
507
|
|
|
508
508
|
:::
|
|
509
509
|
|
|
@@ -26,10 +26,10 @@ Static asset files can be directly hosted by Modern.js' server, but it is highly
|
|
|
26
26
|
|
|
27
27
|
Modern.js supports running built artifacts in any Node.js environment. Typically, the CI environment has already installed all application dependencies.
|
|
28
28
|
|
|
29
|
-
You can run the [`
|
|
29
|
+
You can run the [`modern build`](/apis/app/commands#modern-build) command to build the application and the [`modern serve`](/apis/app/commands#modern-serve) command to run the Web server, starting the UltraModern.js application.
|
|
30
30
|
|
|
31
31
|
## Running in Production Environments
|
|
32
32
|
|
|
33
33
|
When deploying to production, the artifact size should be as small as possible. The aforementioned method for running in CI environments keeps all artifacts from the original project. Therefore, it is not recommended to run the application using the above commands in a production environment.
|
|
34
34
|
|
|
35
|
-
UltraModern.js offers a standalone deployment solution. When running the [`
|
|
35
|
+
UltraModern.js offers a standalone deployment solution. When running the [`modern deploy`](/apis/app/commands#modern-deploy) command, the artifacts will include an entry file for running the Web server.
|
|
@@ -48,7 +48,7 @@ After running `pnpm run dev` again, you can find that the project has completed
|
|
|
48
48
|
|
|
49
49
|
In a newly created project, the `@modern-js/app-tools` npm package is installed by default. It is the core package of the Modern.js framework and provides the following capabilities:
|
|
50
50
|
|
|
51
|
-
- It offers commonly used CLI commands such as `
|
|
51
|
+
- It offers commonly used CLI commands such as `modern dev`, `modern build`, and more.
|
|
52
52
|
- It integrates Rsbuild, providing build capabilities.
|
|
53
53
|
- It integrates Modern.js Server, providing capabilities for development and production servers.
|
|
54
54
|
|
|
@@ -30,7 +30,7 @@ UltraModern.js additions are designed as the default product surface for new Sup
|
|
|
30
30
|
|
|
31
31
|
| Area | Modern.js 3.0 baseline | UltraModern.js 3.0 |
|
|
32
32
|
| --- | --- | --- |
|
|
33
|
-
| Build diagnostics | RsDoctor is generally opt-in | Adds `performance.rsdoctor
|
|
33
|
+
| Build diagnostics | RsDoctor is generally opt-in | Adds a first-class `performance.rsdoctor` config surface (opt-in; the earlier default-on behavior and diagnostics contract artifact were reverted) |
|
|
34
34
|
| Output and static serving | Precompression behavior is app-defined | Enables `output.precompress` by default and serves `.br` / `.gz` variants via `Accept-Encoding` negotiation |
|
|
35
35
|
| BFF runtime and contracts | Standard BFF runtime/client generation | Adds `requestId`-aware producer isolation, fail-fast initialization checks, and operation/trace correlation headers |
|
|
36
36
|
| BFF runtime choices | Hono runtime path only in Modern.js 3.0 baseline (no built-in Effect runtime path) | Sets Effect as default runtime, enforces strict runtime split (`effect` -> `api/effect`, `hono` -> `api/lambda`), and adds Effect-Schema-first contracts plus MF failure-injection reliability coverage |
|
|
@@ -103,9 +103,15 @@ every app.
|
|
|
103
103
|
|
|
104
104
|
Each app emits `src/routes/ultramodern-route-metadata` with
|
|
105
105
|
`ultramodernLocalisedUrls`. The i18n plugin reads that map in
|
|
106
|
-
`localeDetection.localisedUrls
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
`localeDetection.localisedUrls`; this is the explicit non-empty map that enables
|
|
107
|
+
translated path segments on top of `localePathRedirect`. The i18n plugin also
|
|
108
|
+
serves dynamic backend JSON from `/locales/{{lng}}/{{ns}}.json`. The route owner
|
|
109
|
+
changes localized paths and locale resource JSON together.
|
|
110
|
+
|
|
111
|
+
JSON-LD is optional route metadata, not inferred output. Private and
|
|
112
|
+
non-indexable routes emit no JSON-LD by default. Public route owners can add
|
|
113
|
+
`jsonLd` beside localized paths and use the generated
|
|
114
|
+
`src/routes/ultramodern-jsonld.ts` helpers for common schema.org shapes.
|
|
109
115
|
|
|
110
116
|
The generated contract writes `.modernjs/ultramodern-generated-contract.json`
|
|
111
117
|
with a `cssFederation` section:
|
|
@@ -103,7 +103,7 @@ export default RemoteApp;
|
|
|
103
103
|
|
|
104
104
|
## Start the Application
|
|
105
105
|
|
|
106
|
-
Now, both the producer and consumer applications are set up. We can run `
|
|
106
|
+
Now, both the producer and consumer applications are set up. We can run `modern dev` locally to start both applications.
|
|
107
107
|
|
|
108
108
|
After startup, when the consumer application accesses the `/remote` route, it will enter the producer application. Accessing `http://localhost:8080/remote` will display a complete page of the producer's remote module in the browser.
|
|
109
109
|
|
|
@@ -88,10 +88,10 @@ export default createModuleFederationConfig({
|
|
|
88
88
|
|
|
89
89
|
## Local Deployment Verification
|
|
90
90
|
|
|
91
|
-
Modern.js provides the `
|
|
91
|
+
Modern.js provides the `modern deploy` command, which can easily generate products that can run in a Node.js environment.
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
|
|
94
|
+
modern deploy
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
After executing the command, you can see the following output in the console:
|
|
@@ -154,7 +154,7 @@ The second part, `remoteExpose`, is the `key` configured in the `exposes` field
|
|
|
154
154
|
|
|
155
155
|
## Start the Applications
|
|
156
156
|
|
|
157
|
-
Now, both the producer and consumer applications are set up. You can run `
|
|
157
|
+
Now, both the producer and consumer applications are set up. You can run `modern dev` locally to start both applications.
|
|
158
158
|
|
|
159
159
|
Once started, the imports of the producer's modules in the consumer will no longer throw errors, and the types will be downloaded to the consumer application.
|
|
160
160
|
|
|
@@ -164,7 +164,7 @@ After modifying the producer's code, the consumer will automatically fetch the p
|
|
|
164
164
|
|
|
165
165
|
Access `http://localhost:8080/remote`, and you will see that the page includes the `Button` component from the producer's remote module.
|
|
166
166
|
|
|
167
|
-
We can also execute `
|
|
167
|
+
We can also execute `modern serve` locally to simulate the production environment.
|
|
168
168
|
|
|
169
169
|
Because the Module Federation plugin will automatically read Modern.js's `output.assetPrefix` configuration as the access address for remote modules, and this value defaults to `/` after building in the production environment.
|
|
170
170
|
|
|
@@ -180,7 +180,7 @@ export default defineConfig({
|
|
|
180
180
|
port: 3051,
|
|
181
181
|
},
|
|
182
182
|
output: {
|
|
183
|
-
// Now this configuration is only used in the local when you run
|
|
183
|
+
// Now this configuration is only used in the local when you run modern serve command.
|
|
184
184
|
// If you want to deploy the application to the platform, use your own domain name.
|
|
185
185
|
// Module federation will automatically write it to mf-manifest.json, which influences consumer to fetch remoteEntry.js.
|
|
186
186
|
assetPrefix: 'http://127.0.0.1:3051',
|
|
@@ -189,10 +189,10 @@ export default defineConfig({
|
|
|
189
189
|
});
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Now, in the producer, run `
|
|
192
|
+
Now, in the producer, run `modern build && MODERN_MF_AUTO_CORS=true modern serve`, and in the consumer, run `modern build && modern serve` to simulate the production environment locally and access the remote modules.
|
|
193
193
|
|
|
194
194
|
:::tip
|
|
195
|
-
When using the `
|
|
195
|
+
When using the `modern serve` command, you need to set the `MODERN_MF_AUTO_CORS=true` environment variable when starting the producer project to automatically handle CORS issues and ensure that consumers can properly access the producer's remote module resources.
|
|
196
196
|
:::
|
|
197
197
|
|
|
198
198
|
You can refer to this example: [Modern.js & Module Federation Basic Example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/module-federation/base).
|
|
@@ -23,7 +23,7 @@ Modern.js is internally based on [Rsbuild](https://v2.rsbuild.rs/) and encapsula
|
|
|
23
23
|
Modern.js provides [inspect command](https://modernjs.dev/en/apis/app/commands.html) to view the final Modern.js configuration and Rspack configuration generated by the project.
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
➜ npx
|
|
26
|
+
➜ npx modern inspect
|
|
27
27
|
|
|
28
28
|
Inspect config succeed, open following files to view the content:
|
|
29
29
|
|
|
@@ -334,7 +334,7 @@ export default {
|
|
|
334
334
|
|
|
335
335
|
### tools.rsdoctor
|
|
336
336
|
|
|
337
|
-
**Change**: This configuration has been deprecated. In v3,
|
|
337
|
+
**Change**: This configuration has been deprecated. In v3, use [`performance.rsdoctor`](/configure/app/performance/rsdoctor) to opt in to Rsdoctor diagnostics.
|
|
338
338
|
|
|
339
339
|
**Migration Example**:
|
|
340
340
|
|
|
@@ -350,7 +350,6 @@ tools: {
|
|
|
350
350
|
// v3
|
|
351
351
|
export default {
|
|
352
352
|
performance: {
|
|
353
|
-
// enabled by default in production build
|
|
354
353
|
rsdoctor: {
|
|
355
354
|
enabled: true,
|
|
356
355
|
},
|
|
@@ -94,7 +94,7 @@ Modern.js 3.0 no longer supports creating Monorepo projects and Modern.js Module
|
|
|
94
94
|
**Changes**:
|
|
95
95
|
|
|
96
96
|
- In [v2.53.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.53.0), the functionality to create Monorepo projects using `@bleedingdev/modern-js-create` was removed
|
|
97
|
-
- In [v2.61.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.61.0), the functionality to create Modern.js Module projects using `@bleedingdev/modern-js-create` and `
|
|
97
|
+
- In [v2.61.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.61.0), the functionality to create Modern.js Module projects using `@bleedingdev/modern-js-create` and `modern new` commands was removed
|
|
98
98
|
|
|
99
99
|
**Handling**:
|
|
100
100
|
|
|
@@ -103,12 +103,12 @@ Modern.js 3.0 no longer supports creating Monorepo projects and Modern.js Module
|
|
|
103
103
|
|
|
104
104
|
## new and upgrade Commands Removed
|
|
105
105
|
|
|
106
|
-
Modern.js 3.0 removed the `
|
|
106
|
+
Modern.js 3.0 removed the `modern new` and `modern upgrade` commands, and you need to perform operations manually according to the documentation.
|
|
107
107
|
|
|
108
108
|
**Changes**:
|
|
109
109
|
|
|
110
|
-
- The `
|
|
111
|
-
- The `
|
|
110
|
+
- The `modern new` command is no longer supported in Modern.js 3.0, and you cannot add entries or enable features through commands
|
|
111
|
+
- The `modern upgrade` command is no longer supported in Modern.js 3.0, and you cannot automatically upgrade dependencies through commands
|
|
112
112
|
|
|
113
113
|
**Handling**:
|
|
114
114
|
|
|
@@ -8,12 +8,12 @@ UltraModern.js 内置了一些命令,可以帮助你快速启动开发服务
|
|
|
8
8
|
|
|
9
9
|
通过本章节,你可以了解到 UltraModern.js 内置的命令有哪些,以及如何使用这些命令。
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## modern dev
|
|
12
12
|
|
|
13
|
-
`
|
|
13
|
+
`modern dev` 命令用于启动一个本地开发服务器,对源代码进行开发环境编译。
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
Usage:
|
|
16
|
+
Usage: modern dev [options]
|
|
17
17
|
|
|
18
18
|
Options:
|
|
19
19
|
-e --entry <entry> 指定入口,只编译特定的页面
|
|
@@ -23,10 +23,10 @@ Options:
|
|
|
23
23
|
--api-only 仅启动 API 接口服务
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
运行 `
|
|
26
|
+
运行 `modern dev` 后,UltraModern.js 会监听源文件变化并进行模块热更新。
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
$
|
|
29
|
+
$ modern dev
|
|
30
30
|
|
|
31
31
|
info Starting dev server...
|
|
32
32
|
|
|
@@ -38,10 +38,10 @@ info Starting dev server...
|
|
|
38
38
|
|
|
39
39
|
在多页面(MPA)项目中,可以添加 `--entry` 参数来指定编译其中的一个或多个页面。这样可以只编译项目中的部分代码,从而提升 dev 启动速度。
|
|
40
40
|
|
|
41
|
-
比如执行 `
|
|
41
|
+
比如执行 `modern dev --entry`,在命令行界面中会展示入口选择框:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
$
|
|
44
|
+
$ modern dev --entry
|
|
45
45
|
|
|
46
46
|
? 请选择需要构建的入口
|
|
47
47
|
❯ ◯ foo
|
|
@@ -57,22 +57,22 @@ $ ultramodern dev --entry
|
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
# 编译 foo 页面
|
|
60
|
-
|
|
60
|
+
modern dev --entry foo
|
|
61
61
|
|
|
62
62
|
# 编译 foo 和 bar 页面
|
|
63
|
-
|
|
63
|
+
modern dev --entry foo,bar
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
##
|
|
66
|
+
## modern start
|
|
67
67
|
|
|
68
|
-
`
|
|
68
|
+
`modern start` 是 `modern dev` 命令的别名,两者的功能和用法完全一致。
|
|
69
69
|
|
|
70
|
-
##
|
|
70
|
+
## modern build
|
|
71
71
|
|
|
72
|
-
`
|
|
72
|
+
`modern build` 命令默认会在 `dist/` 目录下构建出可用于生产环境的产物。你可以通过修改配置 [`output.distPath`](/configure/app/output/dist-path) 指定产物的输出目录。
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
Usage:
|
|
75
|
+
Usage: modern build [options]
|
|
76
76
|
|
|
77
77
|
Options:
|
|
78
78
|
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
|
|
@@ -80,80 +80,70 @@ Options:
|
|
|
80
80
|
-w --watch 开启 watch 模式, 监听文件变更并重新构建
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
##
|
|
83
|
+
## modern runtime status
|
|
84
84
|
|
|
85
|
-
`
|
|
86
|
-
|
|
87
|
-
比如添加应用入口、启用一些可选功能如 BFF、微前端开发模式等。
|
|
85
|
+
`modern runtime status` 命令用于读取运行时状态端点并打印响应。默认请求 `http://127.0.0.1:8080/_modern/runtime/status`。
|
|
88
86
|
|
|
89
87
|
```bash
|
|
90
|
-
Usage:
|
|
88
|
+
Usage: modern runtime status [options]
|
|
91
89
|
|
|
92
90
|
Options:
|
|
93
|
-
--
|
|
94
|
-
--
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
--
|
|
98
|
-
--
|
|
91
|
+
--endpoint <endpoint> 运行时状态端点 URL 或路径
|
|
92
|
+
--token <token> 运行时状态鉴权 Token
|
|
93
|
+
--token-env <name> 保存运行时状态鉴权 Token 的环境变量名称 (default: "MODERN_RUNTIME_SIGNAL_TOKEN")
|
|
94
|
+
--header-name <name> 鉴权请求头名称 (default: "x-modernjs-runtime-signal-token")
|
|
95
|
+
--timeout <ms> 请求超时时间,单位毫秒 (default: "5000")
|
|
96
|
+
--json 以 JSON 格式输出,便于机器读取
|
|
99
97
|
-h, --help 显示命令帮助
|
|
100
98
|
```
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
如果 `--endpoint` 是路径,命令会基于 `http://127.0.0.1:8080` 解析该路径。如果省略 `--token`,命令会从 `--token-env` 指定的环境变量中读取 Token。
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
默认情况下,命令会将响应格式化为可读的键值行。添加 `--json` 后会打印原始 JSON 载荷。
|
|
105
103
|
|
|
106
104
|
```bash
|
|
107
|
-
|
|
108
|
-
? 请选择你想要的操作 创建工程元素
|
|
109
|
-
? 请选择创建元素类型 新建「应用入口」
|
|
110
|
-
? 请填写入口名称 entry
|
|
105
|
+
modern runtime status --json
|
|
111
106
|
```
|
|
112
107
|
|
|
113
|
-
|
|
108
|
+
## modern runtime fallback-signal
|
|
114
109
|
|
|
115
|
-
|
|
110
|
+
`modern runtime fallback-signal` 命令用于向金丝雀 contract-gate 端点发送运行时 fallback 信号。默认请求 `http://127.0.0.1:8080/_modern/contract-gates/runtime-fallback`。
|
|
116
111
|
|
|
117
112
|
```bash
|
|
118
|
-
|
|
119
|
-
? 请选择你想要的操作 启用可选功能
|
|
120
|
-
? 请选择功能名称 (Use arrow keys)
|
|
121
|
-
❯ 启用「BFF」功能
|
|
122
|
-
启用「微前端」模式
|
|
123
|
-
```
|
|
113
|
+
Usage: modern runtime fallback-signal [options]
|
|
124
114
|
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
Options:
|
|
116
|
+
--app <appName> 远程应用名称
|
|
117
|
+
--endpoint <endpoint> 运行时 fallback 信号端点 URL 或路径
|
|
118
|
+
--reason <reason> fallback 原因 (default: "runtime_fallback")
|
|
119
|
+
--phase <phase> fallback 阶段 (default: "load")
|
|
120
|
+
--entry <entry> 远程入口 URL
|
|
121
|
+
--runtime-digest <digest> 运行时 digest 值
|
|
122
|
+
--metadata <json> metadata JSON 对象字符串
|
|
123
|
+
--token <token> 运行时信号鉴权 Token
|
|
124
|
+
--token-env <name> 保存运行时信号鉴权 Token 的环境变量名称 (default: "MODERN_RUNTIME_SIGNAL_TOKEN")
|
|
125
|
+
--header-name <name> 鉴权请求头名称 (default: "x-modernjs-runtime-signal-token")
|
|
126
|
+
--timeout <ms> 请求超时时间,单位毫秒 (default: "5000")
|
|
127
|
+
--json 以 JSON 格式输出,便于机器读取
|
|
128
|
+
-h, --help 显示命令帮助
|
|
129
|
+
```
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
请求体始终包含 `appName`、`reason` 和 `phase`。只有在提供对应选项时,才会包含 `entry`、`runtimeDigest` 和 `metadata`。`--metadata` 必须是 JSON 对象字符串。
|
|
129
132
|
|
|
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/components/serve-command';
|
|
133
138
|
|
|
134
139
|
<ServeCommand />
|
|
135
140
|
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
在项目根目录下执行命令 `npx ultramodern upgrade`,会默认将当前执行命令项目的 `package.json` 中的 UltraModern.js 相关依赖更新至最新版本。
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
Usage: ultramodern upgrade [options]
|
|
142
|
-
|
|
143
|
-
Options:
|
|
144
|
-
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
|
|
145
|
-
--registry <registry> 定制 npm registry (default: "")
|
|
146
|
-
-d,--debug 开启 Debug 模式,打印调试日志信息 (default: false)
|
|
147
|
-
--cwd <cwd> 项目路径 (default: "")
|
|
148
|
-
-h, --help display help for command
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## ultramodern inspect
|
|
141
|
+
## modern inspect
|
|
152
142
|
|
|
153
|
-
`
|
|
143
|
+
`modern inspect` 命令用于查看项目的 UltraModern.js 配置、[Rsbuild 配置](https://v2.rsbuild.rs/zh/config/index) 以及 Rspack 配置。
|
|
154
144
|
|
|
155
145
|
```bash
|
|
156
|
-
Usage:
|
|
146
|
+
Usage: modern inspect [options]
|
|
157
147
|
|
|
158
148
|
Options:
|
|
159
149
|
--env <env> 查看指定环境下的配置 (default: "development")
|
|
@@ -163,14 +153,14 @@ Options:
|
|
|
163
153
|
-h, --help 显示命令帮助
|
|
164
154
|
```
|
|
165
155
|
|
|
166
|
-
在项目根目录下执行命令 `npx
|
|
156
|
+
在项目根目录下执行命令 `npx modern inspect` 后,会在项目的 `dist` 目录生成以下文件:
|
|
167
157
|
|
|
168
158
|
- `modern.js.config.mjs`: 表示当前使用的 Modern.js 配置。
|
|
169
159
|
- `rsbuild.config.mjs`: 表示在构建时使用的 Rsbuild 配置。
|
|
170
160
|
- `rspack.config.web.mjs`: 表示在构建时使用的 Rspack 配置。
|
|
171
161
|
|
|
172
162
|
```bash
|
|
173
|
-
➜ npx
|
|
163
|
+
➜ npx modern inspect
|
|
174
164
|
|
|
175
165
|
Inspect config succeed, open following files to view the content:
|
|
176
166
|
|
|
@@ -184,7 +174,7 @@ Inspect config succeed, open following files to view the content:
|
|
|
184
174
|
默认情况下,inspect 命令会输出开发环境的配置,你可以添加 `--env production` 选项来输出生产环境的配置:
|
|
185
175
|
|
|
186
176
|
```bash
|
|
187
|
-
|
|
177
|
+
modern inspect --env production
|
|
188
178
|
```
|
|
189
179
|
|
|
190
180
|
### 完整内容
|
|
@@ -192,7 +182,7 @@ ultramodern inspect --env production
|
|
|
192
182
|
默认情况下,inspect 命令会省略配置对象中的函数内容,你可以添加 `--verbose` 选项来输出函数的完整内容:
|
|
193
183
|
|
|
194
184
|
```bash
|
|
195
|
-
|
|
185
|
+
modern inspect --verbose
|
|
196
186
|
```
|
|
197
187
|
|
|
198
188
|
### SSR 构建配置
|
|
@@ -200,7 +190,7 @@ ultramodern inspect --verbose
|
|
|
200
190
|
如果项目开启了 SSR 能力,则在 `dist` 目录会另外生成一份 `rspack.config.node.mjs` 文件,对应 SSR 构建时的 Rspack 配置。
|
|
201
191
|
|
|
202
192
|
```bash
|
|
203
|
-
➜ npx
|
|
193
|
+
➜ npx modern inspect
|
|
204
194
|
|
|
205
195
|
Inspect config succeed, open following files to view the content:
|
|
206
196
|
|