@bleedingdev/modern-js-main-doc 3.5.0-ultramodern.98 → 3.8.1-ultramodern.1

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.
Files changed (32) hide show
  1. package/docs/en/apis/app/hooks/config/mock.mdx +4 -1
  2. package/docs/en/components/prerequisites.mdx +1 -1
  3. package/docs/en/configure/app/bff/effect.mdx +29 -14
  4. package/docs/en/configure/app/dev/mock-dir.mdx +35 -0
  5. package/docs/en/configure/app/server/rsc.mdx +8 -12
  6. package/docs/en/configure/app/source/react-compiler.mdx +72 -0
  7. package/docs/en/guides/advanced-features/international/api.mdx +41 -8
  8. package/docs/en/guides/basic-features/debug/mock.mdx +11 -0
  9. package/docs/en/guides/basic-features/deploy.mdx +6 -6
  10. package/docs/en/guides/basic-features/render/rsc.mdx +5 -14
  11. package/docs/en/guides/get-started/ai-coding-agents.mdx +19 -4
  12. package/docs/en/guides/get-started/tech-stack.mdx +1 -1
  13. package/docs/en/guides/get-started/ultramodern.mdx +19 -7
  14. package/docs/en/guides/get-started/upgrade.mdx +7 -12
  15. package/docs/en/guides/topic-detail/module-federation/application.mdx +4 -4
  16. package/docs/en/guides/topic-detail/module-federation/usage.mdx +1 -1
  17. package/docs/zh/apis/app/hooks/config/mock.mdx +3 -1
  18. package/docs/zh/components/prerequisites.mdx +1 -1
  19. package/docs/zh/configure/app/bff/effect.mdx +26 -13
  20. package/docs/zh/configure/app/dev/mock-dir.mdx +33 -0
  21. package/docs/zh/configure/app/server/rsc.mdx +8 -12
  22. package/docs/zh/configure/app/source/react-compiler.mdx +72 -0
  23. package/docs/zh/guides/advanced-features/international/api.mdx +39 -8
  24. package/docs/zh/guides/basic-features/debug/mock.mdx +10 -0
  25. package/docs/zh/guides/basic-features/deploy.mdx +1 -1
  26. package/docs/zh/guides/basic-features/render/rsc.mdx +5 -14
  27. package/docs/zh/guides/get-started/ai-coding-agents.mdx +19 -4
  28. package/docs/zh/guides/get-started/ultramodern.mdx +18 -6
  29. package/docs/zh/guides/get-started/upgrade.mdx +7 -12
  30. package/docs/zh/guides/topic-detail/module-federation/application.mdx +4 -4
  31. package/docs/zh/guides/topic-detail/module-federation/usage.mdx +1 -1
  32. package/package.json +20 -5
@@ -4,4 +4,7 @@ sidebar_position: 5
4
4
  ---
5
5
  # mock/
6
6
 
7
- When there is a `config/mock/index.js` file in the project directory, Modern.js will automatically enable the Mock service during development.
7
+ When there is a `config/mock/index.ts` or `config/mock/index.js` file in the
8
+ project directory, Modern.js will automatically enable the Mock service during
9
+ development. Use [`dev.mockDir`](/configure/app/dev/mock-dir) to customize
10
+ this directory.
@@ -9,7 +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
- mise use pnpm@11.17.0
12
+ mise use pnpm@11.21.0
13
13
  ```
14
14
 
15
15
  :::note
@@ -45,6 +45,23 @@ import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
45
45
 
46
46
  `bff.effect` is only effective when `bff.runtimeFramework` is set to `'effect'`.
47
47
 
48
+ :::caution Install the Effect peers yourself
49
+ `effect` and `@effect/opentelemetry` are **optional exact peer dependencies** of
50
+ `@modern-js/plugin-bff`, not dependencies. The plugin no longer bundles a copy —
51
+ Effect 4 derives `Context` / `Service` keys per module instance, so a bundled copy
52
+ would give your app a second Effect identity. Before setting
53
+ `runtimeFramework: 'effect'` or importing `@modern-js/plugin-bff/effect`,
54
+ `/effect-server`, `/effect-edge` or `/effect-client`, install the exact cohort:
55
+
56
+ ```bash
57
+ pnpm add effect@4.0.0-beta.107 @effect/opentelemetry@4.0.0-beta.107
58
+ ```
59
+
60
+ The pin is exact because UltraModern ships Effect as one lockstep cohort. Apps
61
+ using only `runtimeFramework: 'hono'` or the `./data-platform` lane need neither
62
+ package.
63
+ :::
64
+
48
65
  Generated UltraModern workspaces use this runtime as the only generated HTTP API
49
66
  path. The API contract lives at `shared/api.ts`, the server runtime lives at
50
67
  `api/index.ts`, clients live under `src/api/*-client.ts`, and generated checks
@@ -201,27 +218,25 @@ through `pnpm-workspace.yaml` overrides. For the current UltraModern cohort,
201
218
  generated apps use:
202
219
 
203
220
  ```yaml
204
- minimumReleaseAgeExclude:
205
- - 'effect@4.0.0-beta.97'
206
- - '@effect/opentelemetry@4.0.0-beta.97'
207
-
208
221
  trustPolicyExclude:
209
- - 'effect@4.0.0-beta.97'
210
- - '@effect/opentelemetry@4.0.0-beta.97'
222
+ - 'effect@4.0.0-beta.107'
223
+ - '@effect/opentelemetry@4.0.0-beta.107'
211
224
 
212
225
  overrides:
213
- '@effect/opentelemetry': 4.0.0-beta.97
214
- '@effect/vitest': 4.0.0-beta.97
215
- effect: 4.0.0-beta.97
226
+ '@effect/opentelemetry': 4.0.0-beta.107
227
+ '@effect/vitest': 4.0.0-beta.107
228
+ effect: 4.0.0-beta.107
216
229
  ```
217
230
 
218
231
  Do not add a different direct `effect` version in an app package. A mismatched
219
232
  Effect beta can fail while building layers or HTTP middleware because runtime
220
- services come from different package instances. Keep the generated
221
- policy exclusion entries with the same Effect cohort; they handle the
222
- framework-selected Effect beta versions before the 24-hour maturity window and
223
- the `effect`/`@effect/opentelemetry` trusted-publisher to provenance metadata
224
- transition without weakening UltraModern API architecture checks.
233
+ services come from different package instances. The strict 24-hour release-age
234
+ gate applies to installed packages; the current cohort has no Effect age
235
+ exemption, and override-only `@effect/vitest` is not an installed approval
236
+ target. `trustPolicyExclude` is a separate policy:
237
+ its exact `effect` and `@effect/opentelemetry` exceptions cover their
238
+ trusted-publisher to provenance metadata transition and are not release-age
239
+ approvals.
225
240
 
226
241
  ## Contract tests
227
242
 
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: mockDir
3
+ ---
4
+
5
+ # dev.mockDir
6
+
7
+ - **Type:** `string`
8
+ - **Default:** `'./config/mock'`
9
+
10
+ Sets the directory containing the Mock API entry file. Relative paths are
11
+ resolved from the application directory, and absolute paths are also supported.
12
+ Modern.js loads `index.ts` or `index.js` from this directory during development.
13
+
14
+ For example, move the Mock API entry to `mocks/index.ts`:
15
+
16
+ ```js title="modern.config.ts"
17
+ import { defineConfig } from '@modern-js/app-tools';
18
+
19
+ export default defineConfig({
20
+ dev: {
21
+ mockDir: './mocks',
22
+ },
23
+ });
24
+ ```
25
+
26
+ This is also useful in a monorepo when multiple applications share one Mock
27
+ directory:
28
+
29
+ ```js title="modern.config.ts"
30
+ export default defineConfig({
31
+ dev: {
32
+ mockDir: '../../shared/mocks',
33
+ },
34
+ });
35
+ ```
@@ -7,24 +7,20 @@ title: rsc
7
7
  - **Type:** `boolean`
8
8
  - **Default:** `false`
9
9
 
10
- Enable React Server Components (RSC) configuration.
10
+ Configure React Server Components (RSC).
11
11
 
12
- When set to `true`, enables React Server Components support in Modern.js. This allows components to be rendered on the server, providing better performance and developer experience.
12
+ :::warning UltraModern availability
13
+ RSC is not shipped or supported in the current UltraModern company distribution. Keep this option `false`. The Rspack Flight runtime remains under upstream review, and enabling RSC intentionally fails unless an application supplies the complete optional toolchain.
14
+
15
+ Do not install `react-server-dom-rspack` or add an application-level pnpm patch to bypass this boundary.
16
+ :::
13
17
 
14
18
  ```ts title="modern.config.ts"
15
19
  export default defineConfig({
16
20
  server: {
17
- rsc: true,
21
+ rsc: false,
18
22
  },
19
23
  });
20
24
  ```
21
25
 
22
- :::tip Prerequisites
23
- Before enabling RSC, ensure:
24
- 1. React and React DOM are upgraded to version 19 (recommended 19.2.4 or above)
25
- 2. Install the `react-server-dom-rspack@0.0.1-beta.1` dependency
26
-
27
- :::
28
-
29
- For more information about using RSC, see the [React Server Components guide](/guides/basic-features/render/rsc).
30
-
26
+ The [React Server Components guide](/guides/basic-features/render/rsc) is retained as reference material for future upstream adoption.
@@ -0,0 +1,72 @@
1
+ ---
2
+ title: reactCompiler
3
+ ---
4
+
5
+ # source.reactCompiler
6
+
7
+ - **Type:** `boolean | ReactCompilerOptions`
8
+ - **Default:** `undefined` (disabled)
9
+
10
+ Whether to enable [React Compiler](https://react.dev/learn/react-compiler). React Compiler is a build-time tool that optimizes re-rendering performance of React applications through automatic memoization.
11
+
12
+ Modern.js implements this capability based on the Rust-based React Compiler built into Rspack's `builtin:swc-loader` (equivalent to setting SWC's `jsc.transform.reactCompiler`), reusing Rspack's built-in SWC transform chain without introducing Babel.
13
+
14
+ :::tip
15
+ This option is disabled by default. It must be enabled explicitly for any React version, including React 19.
16
+ :::
17
+
18
+ ## Example
19
+
20
+ ### Enable React Compiler (React 19)
21
+
22
+ ```ts title="modern.config.ts"
23
+ import { defineConfig } from '@modern-js/app-tools';
24
+
25
+ export default defineConfig({
26
+ source: {
27
+ reactCompiler: true,
28
+ },
29
+ });
30
+ ```
31
+
32
+ ### Using with React 18
33
+
34
+ The compiled output targets React 19 by default. To use it in React 18 projects, you need to:
35
+
36
+ 1. Install [react-compiler-runtime](https://www.npmjs.com/package/react-compiler-runtime) as a **runtime dependency** (the compiled output references it at runtime):
37
+
38
+ ```bash
39
+ npm add react-compiler-runtime
40
+ ```
41
+
42
+ 2. Specify the React version via `target`:
43
+
44
+ ```ts title="modern.config.ts"
45
+ import { defineConfig } from '@modern-js/app-tools';
46
+
47
+ export default defineConfig({
48
+ source: {
49
+ reactCompiler: {
50
+ target: '18',
51
+ },
52
+ },
53
+ });
54
+ ```
55
+
56
+ ### Customize compilation behavior
57
+
58
+ When passing an object, the options are the same as Rspack's `jsc.transform.reactCompiler`. For example, use `compilationMode: 'annotation'` to only compile functions annotated with the `"use memo"` directive:
59
+
60
+ ```ts title="modern.config.ts"
61
+ import { defineConfig } from '@modern-js/app-tools';
62
+
63
+ export default defineConfig({
64
+ source: {
65
+ reactCompiler: {
66
+ compilationMode: 'annotation',
67
+ },
68
+ },
69
+ });
70
+ ```
71
+
72
+ For the complete list of options, see [Rsbuild - reactCompiler](https://rsbuild.rs/plugins/list/plugin-react#reactcompiler) and the [React Compiler configuration docs](https://react.dev/reference/react-compiler/configuration).
@@ -145,19 +145,52 @@ const myPlugin = (): RuntimePlugin => ({
145
145
 
146
146
  The i18next instance type used by the plugin. It is a subset of the i18next `i18n` type and only lists fields actually used by the plugin:
147
147
 
148
+ :::warning BREAKING (UltraModern)
149
+ `I18nInstance` no longer declares a top-level `[key: string]: unknown` index
150
+ signature: TypeScript never grants an interface an implicit index signature, so
151
+ that member made the documented `runtime: { i18n: { i18nInstance: i18next } }`
152
+ usage fail to typecheck. Reading a property that is not declared below is now a
153
+ type error (TS2339) — cast to the concrete instance type instead. `t` is now a
154
+ REQUIRED member, so object literals that produce an `I18nInstance` must supply
155
+ one.
156
+ :::
157
+
148
158
  ```ts
159
+ type TranslateFn = (
160
+ key: string | string[],
161
+ options?: Record<string, unknown>,
162
+ ) => string;
163
+
149
164
  interface I18nInstance {
150
165
  language: string;
151
- isInitialized: boolean;
152
- init: (options?: I18nInitOptions) => void | Promise<void>;
153
- changeLanguage: (lang: string) => void | Promise<void>;
154
- use: (plugin: any) => void;
155
- createInstance: (options?: I18nInitOptions) => I18nInstance;
166
+ isInitialized?: boolean;
167
+ init(options?: any, callback?: any): Promise<any>;
168
+ changeLanguage?(lng?: string, callback?: any): Promise<any>;
169
+ setLang?: (lang: string) => void | Promise<void>;
170
+ use(plugin: any): unknown;
171
+ t: TranslateFn;
172
+ exists?: (key: string | string[], options?: Record<string, unknown>) => boolean;
173
+ getFixedT?: (
174
+ lng: string | readonly string[] | null,
175
+ ns?: string | readonly string[] | null,
176
+ keyPrefix?: string,
177
+ ) => TranslateFn;
178
+ hasLoadedNamespace?: (
179
+ ns: string | readonly string[],
180
+ options?: Record<string, unknown>,
181
+ ) => boolean;
182
+ dir?: (lng?: string) => string;
183
+ languages?: readonly string[];
184
+ resolvedLanguage?: string;
185
+ createInstance?(options?: any, callback?: any): I18nInstance;
186
+ cloneInstance?(options?: any, callback?: any): I18nInstance;
156
187
  options?: {
157
- backend?: BackendOptions;
158
- supportedLngs?: string[];
159
- [key: string]: any;
188
+ detection?: any;
189
+ backend?: any;
190
+ ns?: any;
191
+ defaultNS?: any;
160
192
  };
193
+ // ...see src/runtime/i18n/instance.ts for the full member list.
161
194
  }
162
195
  ```
163
196
 
@@ -20,6 +20,17 @@ By convention, when there is an `index.ts` in the `config/mock/` directory, mock
20
20
  └── modern.config.ts
21
21
  ```
22
22
 
23
+ You can use [`dev.mockDir`](/configure/app/dev/mock-dir) to place the
24
+ Mock entry in another directory:
25
+
26
+ ```js title="modern.config.ts"
27
+ export default {
28
+ dev: {
29
+ mockDir: './mocks',
30
+ },
31
+ };
32
+ ```
33
+
23
34
  ## Writing Mock Files
24
35
 
25
36
  The `config/mock/index.ts` file only needs to export an object containing all Mock APIs. The properties of the object are composed of the request configuration `method` and `url`, and the corresponding property values can be `Object`, `Array`, or `Function`:
@@ -112,7 +112,7 @@ Add the following content to `netlify.toml`:
112
112
  ```
113
113
 
114
114
  :::info
115
- You can refer to the [deployment project example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr).
115
+ You can refer to the [deployment project example](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-csr).
116
116
 
117
117
  :::
118
118
 
@@ -137,7 +137,7 @@ Full-stack projects refer to projects that use Custom Web Server, SSR or BFF. Th
137
137
  :::info
138
138
 
139
139
  1. Currently, Modern.js does not support deployment on Netlify Edge Functions. We will support it in future versions.
140
- 2. You can refer to the [deployment project example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-ssr).
140
+ 2. You can refer to the [deployment project example](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-ssr).
141
141
 
142
142
  :::
143
143
 
@@ -223,7 +223,7 @@ Commit your project to git, select Framework Preset as `Other` on the Vercel pla
223
223
  <img src="https://sf16-sg.tiktokcdn.com/obj/eden-sg/lmeh7nuptpfnuhd/vercel-framework-preset.png" />
224
224
 
225
225
  :::info
226
- You can refer to the [deployment project examples](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr).
226
+ You can refer to the [deployment project examples](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-csr).
227
227
 
228
228
  :::
229
229
 
@@ -237,7 +237,7 @@ In addition to configuring `vercel.json` in the same way as a [pure front-end pr
237
237
  2. The Node.js version for function execution is determined by the project configuration on the Vercel platform.
238
238
 
239
239
  :::info
240
- You can refer to the [deployment project examples](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-ssr).
240
+ You can refer to the [deployment project examples](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-ssr).
241
241
 
242
242
  :::
243
243
 
@@ -335,10 +335,10 @@ For branch deployment, follow these steps:
335
335
  :::info
336
336
 
337
337
  1. Running `MODERNJS_DEPLOY=ghPages modern deploy` will build the production output for GitHub in the .output directory.
338
- 2. You can refer to the [project](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr)
338
+ 2. You can refer to the [project](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-csr)
339
339
  :::
340
340
 
341
- For GitHub Actions deployment, select Settings > Pages > Source > GitHub Actions, and add a workflow file to the project. You can refer to the [example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr).
341
+ For GitHub Actions deployment, select Settings > Pages > Source > GitHub Actions, and add a workflow file to the project. You can refer to the [example](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-csr).
342
342
 
343
343
  ## Using Self-Built Node.js Server
344
344
 
@@ -21,29 +21,20 @@ Before starting, we recommend reading React's official [Server Components docume
21
21
 
22
22
  ## Quick Start
23
23
 
24
- 1. **Ensure React and React DOM are upgraded to version 19** (recommended version 19.2.4 or above)
25
-
26
- 2. **Install the `react-server-dom-rspack@0.0.1-beta.1` dependency**
27
-
28
- ```bash
29
- npm install react-server-dom-rspack@0.0.1-beta.1
30
- ```
31
-
32
- :::warning Notes
33
-
34
- 1. Currently, [Server Functions](https://react.dev/reference/rsc/server-functions) are not supported in SPA projects
35
- 2. Currently, when building with Rspack, the output chunks and bundle size are not yet optimal. We will further optimize this in the near future
24
+ :::warning UltraModern availability
25
+ RSC is not shipped or supported in the current UltraModern company distribution. The framework keeps [`server.rsc`](/configure/app/server/rsc) disabled while the Rspack Flight runtime is completed upstream. Do not install `react-server-dom-rspack` or carry an application-level pnpm patch to enable it early.
36
26
 
27
+ The remainder of this page is retained as reference material for future upstream adoption.
37
28
  :::
38
29
 
39
- 3. Set [`server.rsc`](/configure/app/server/rsc) to `true`:
30
+ Keep [`server.rsc`](/configure/app/server/rsc) set to `false`:
40
31
 
41
32
  ```ts title="modern.config.ts"
42
33
  import { defineConfig } from '@modern-js/app-tools';
43
34
 
44
35
  export default defineConfig({
45
36
  server: {
46
- rsc: true,
37
+ rsc: false,
47
38
  },
48
39
  });
49
40
  ```
@@ -5,16 +5,31 @@ sidebar_position: 6
5
5
 
6
6
  # Modern.js For AI
7
7
 
8
- Modern.js provides a toolkit for AI agents that helps developers use AI to efficiently complete feature development, dependency upgrades, and version migration for Modern.js applications.
8
+ Modern.js provides a toolkit for AI agents that makes your project agent-ready out of the box, helping you use AI to develop, upgrade, and migrate Modern.js applications more accurately and efficiently.
9
+
10
+ ## Bundled docs
11
+
12
+ Modern.js ships the English docs that match your installed version together with `@modern-js/app-tools`. After you install or upgrade, they live at `node_modules/@modern-js/app-tools/docs/`, available offline with no extra setup.
13
+
14
+ AI agents use them to get APIs, config, and conventions that exactly match your framework version, rather than relying on potentially outdated training data.
15
+
16
+ ## AGENTS.md
17
+
18
+ `AGENTS.md` gives AI coding agents project-level guidance — telling them to read the bundled docs before making changes and to follow Modern.js conventions. A `CLAUDE.md` is generated alongside it, reusing the same guidance for Claude Code via the `@AGENTS.md` import.
19
+
20
+ - **New projects**: `npx @modern-js/create` generates both files by default; pass `--no-agents-md` to skip them.
21
+ - **Existing projects**: run `npx @modern-js/create --agents-md-only` at the project root to create or update them. Re-run it any time; your own additions are preserved.
22
+
23
+ Modern.js only maintains the content inside the `<!-- BEGIN:modernjs-agent-rules -->` markers in `AGENTS.md`; anything you write outside them is left untouched.
9
24
 
10
25
  ## llms.txt
11
26
 
12
- Modern.js docs follow the [llms.txt specification](https://llmstxt.org/), auto-generated by [`@rspress/plugin-llms`](https://rspress.rs/plugin/official-plugins/llms), accessible via `/llms.txt` or `/llms-full.txt`:
27
+ llms.txt is an online documentation index following the [llms.txt specification](https://llmstxt.org/), auto-generated by [`@rspress/plugin-llms`](https://rspress.rs/plugin/official-plugins/llms) for AI tools to retrieve the full docs online:
13
28
 
14
29
  - Index: [`https://modernjs.dev/llms.txt`](https://modernjs.dev/llms.txt)
15
- - Full text: `https://modernjs.dev/llms-full.txt` (large — fetch on demand)
30
+ - Full text: [`https://modernjs.dev/llms-full.txt`](https://modernjs.dev/llms-full.txt) (large — fetch on demand)
16
31
 
17
- Most "what is this API / config" questions can be answered from llms.txt. Just let your agent retrieve it on demand; no need to copy docs into your project.
32
+ Use it when you need content beyond the bundled docs just let your agent retrieve it on demand, no need to copy docs into your project. Typical cases: looking up another framework version, a section not included in the bundle, or getting Modern.js information outside of a project (for example before a project exists, or when researching on its own).
18
33
 
19
34
  ## Skills
20
35
 
@@ -10,7 +10,7 @@ In this document, you can learn about the main technology stack involved in the
10
10
 
11
11
  ## UI Library
12
12
 
13
- Modern.js uses [React 18](https://react.dev/) to build user interfaces and is also compatible with React 17.
13
+ Modern.js uses [React 19](https://react.dev/) to build user interfaces and is also compatible with React 18.
14
14
 
15
15
  Rsbuild supports building Vue applications. If you need to use Vue, you can refer to ["Rsbuild - Vue"](https://v2.rsbuild.rs/guide/framework/vue).
16
16
 
@@ -143,13 +143,25 @@ migration work: move code to `shared/api.ts`, `api/index.ts`, and
143
143
  and `src/effect`.
144
144
 
145
145
  Generated strict Effect workspaces pin the compatible Effect cohort with pnpm
146
- overrides: `effect@4.0.0-beta.97`, `@effect/opentelemetry@4.0.0-beta.97`,
147
- and `@effect/vitest@4.0.0-beta.97`. Do not add app-local direct Effect
148
- versions that disagree with those overrides. They also carry generated pnpm
149
- policy exclusions for `effect@4.0.0-beta.97` and
150
- `@effect/opentelemetry@4.0.0-beta.97` so the framework-selected Effect beta
151
- cohort is not blocked by the 24-hour age gate or trusted-publisher to
152
- provenance metadata transition.
146
+ overrides: `effect@4.0.0-beta.107`, `@effect/opentelemetry@4.0.0-beta.107`,
147
+ and `@effect/vitest@4.0.0-beta.107`. Do not add app-local direct Effect
148
+ versions that disagree with those overrides. The strict 24-hour release-age
149
+ gate applies to installed packages; this cohort carries no Effect age
150
+ exemption, and override-only `@effect/vitest` is not an installed approval
151
+ target. Independently, exact `trustPolicyExclude` entries for `effect`
152
+ and `@effect/opentelemetry` cover their trusted-publisher to provenance
153
+ metadata transition; they are not release-age approvals.
154
+
155
+ ### Current generated dependency baseline
156
+
157
+ | Surface | Pin |
158
+ | --- | --- |
159
+ | Effect runtime and test cohort | `effect`, `@effect/opentelemetry`, and `@effect/vitest`: `4.0.0-beta.107` |
160
+ | Effect compiler | `@effect/tsgo@0.36.2` |
161
+ | TanStack Router | `@tanstack/react-router@1.170.25`, `@tanstack/router-core@1.171.21`, `@tanstack/history@1.162.1` |
162
+ | Module Federation | `bridge-react`, `manifest`, `modern-js-v3`, and `rspack`: `2.8.2`; `@module-federation/node@2.7.49` |
163
+ | React Router | `react-router@7.18.2` |
164
+ | Node and package tooling | Node `26.7.0`, `@types/node@^26.2.0`, pnpm `11.21.0` |
153
165
 
154
166
  Gradual migration means old, unmigrated Modern.js apps can keep their existing
155
167
  runtime until they are converted. Once a surface is generated or migrated as
@@ -24,7 +24,7 @@ All Modern.js official packages are released with a **uniform version number**,
24
24
  - Visit [npm](https://www.npmjs.com/package/@modern-js/app-tools) to check the latest version of `@modern-js/app-tools`
25
25
  - Check [GitHub Releases](https://github.com/web-infra-dev/modern.js/releases)
26
26
 
27
- <ReleaseNote />
27
+ <ReleaseNote />
28
28
 
29
29
  2. **Update package.json**
30
30
 
@@ -46,7 +46,7 @@ All Modern.js official packages are released with a **uniform version number**,
46
46
 
47
47
  After updating `package.json`, reinstall dependencies:
48
48
 
49
- <PackageManagerTabs command="install" />
49
+ <PackageManagerTabs command="install" />
50
50
 
51
51
  :::tip
52
52
  When upgrading, you need to upgrade all packages provided by Modern.js uniformly, rather than upgrading individual dependencies. Ensure that all `@modern-js/**` packages have the same version number.
@@ -72,16 +72,11 @@ When a nested dependency of the project has a problem and Modern.js cannot be up
72
72
 
73
73
  ### pnpm
74
74
 
75
- For projects using pnpm, add the following configuration to the `package.json` in the **root directory** of the project, and then run `pnpm install` again:
75
+ For projects using pnpm, add the following configuration to `pnpm-workspace.yaml` in the **root directory** of the project, and then run `pnpm install` again:
76
76
 
77
- ```json title="package.json"
78
- {
79
- "pnpm": {
80
- "overrides": {
81
- "package-name": "^1.0.0"
82
- }
83
- }
84
- }
77
+ ```yaml title="pnpm-workspace.yaml"
78
+ overrides:
79
+ package-name: ^1.0.0
85
80
  ```
86
81
 
87
82
  ### Yarn
@@ -109,6 +104,6 @@ For projects using Npm, add the following configuration to the `package.json` in
109
104
  ```
110
105
 
111
106
  :::info
112
- For Monorepo repositories, you can only lock dependency versions in the `package.json` in the root directory of the project, and it will affect all packages in the Monorepo.
107
+ For Monorepo repositories, lock dependency versions in the package-manager configuration at the project root. The override affects every package in the Monorepo.
113
108
 
114
109
  :::
@@ -62,7 +62,7 @@ export default createModuleFederationConfig({
62
62
  ```
63
63
 
64
64
  :::info
65
- [`createBridgeComponent`](https://module-federation.io/practice/bridge/react-bridge/export-app.html#createbridgecomponent-api-reference) is used to export application-level modules. Modern.js related APIs can be found at [createRoot](/apis/app/runtime/core/create-root) and [render](/apis/app/runtime/core/render).
65
+ [`createBridgeComponent`](https://module-federation.io/guide/bridge/overview#core-apis) is used to export application-level modules. Modern.js related APIs can be found at [createRoot](/apis/app/runtime/core/create-root) and [render](/apis/app/runtime/core/render).
66
66
  :::
67
67
 
68
68
  ## Using Modules in Consumer
@@ -98,7 +98,7 @@ export default RemoteApp;
98
98
  ```
99
99
 
100
100
  :::info
101
- [`createRemoteAppComponent`](https://module-federation.io/zh/practice/bridge/react-bridge/load-app.html#%E4%BB%80%E4%B9%88%E6%98%AF-createremoteappcomponent) is used to load application-level modules.
101
+ [`createRemoteAppComponent`](https://module-federation.io/guide/bridge/overview#core-apis) is used to load application-level modules.
102
102
  :::
103
103
 
104
104
  ## Start the Application
@@ -109,8 +109,8 @@ After startup, when the consumer application accesses the `/remote` route, it wi
109
109
 
110
110
  You can create new route files in the producer application and add route navigation in the code. These functionalities will also work as expected.
111
111
 
112
- You can refer to the example here: [Modern.js & Module Federation Application-Level Modules](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/module-federation/app-export).
112
+ You can refer to the example here: [Modern.js & Module Federation Application-Level Modules](https://github.com/web-infra-dev/modern.js/tree/main/examples/module-federation/app-export).
113
113
 
114
114
  ## Related Documentation
115
115
 
116
- - [Module Federation Bridge](https://module-federation.io/zh/practice/bridge/index.html)
116
+ - [Module Federation Bridge](https://module-federation.io/guide/bridge/overview)
@@ -195,7 +195,7 @@ Now, in the producer, run `modern build && MODERN_MF_AUTO_CORS=true modern serv
195
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
- 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).
198
+ You can refer to this example: [Modern.js & Module Federation Basic Example](https://github.com/web-infra-dev/modern.js/tree/main/examples/module-federation/base).
199
199
 
200
200
  ## Related Documentation
201
201
 
@@ -4,4 +4,6 @@ sidebar_position: 5
4
4
  ---
5
5
  # mock/
6
6
 
7
- 当项目目录下存在 `config/mock/index.js` 时,Modern.js 在开发环节将自动开启 Mock 服务。
7
+ 当项目目录下存在 `config/mock/index.ts` 或 `config/mock/index.js` 时,Modern.js
8
+ 会在开发环节自动开启 Mock 服务。可以通过
9
+ [`dev.mockDir`](/configure/app/dev/mock-dir) 自定义该目录。
@@ -9,7 +9,7 @@ import NodeVersion from '@site-docs/components/nodeVersion.mdx';
9
9
  推荐使用 [pnpm](https://pnpm.io/installation) 来管理依赖:
10
10
 
11
11
  ```bash
12
- mise use pnpm@11.17.0
12
+ mise use pnpm@11.21.0
13
13
  ```
14
14
 
15
15
  :::note
@@ -45,6 +45,21 @@ import EnableBFFCaution from "@site-docs/components/enable-bff-caution";
45
45
 
46
46
  仅当 `bff.runtimeFramework` 设置为 `'effect'` 时,`bff.effect` 才会生效。
47
47
 
48
+ :::caution 需要自行安装 Effect peer 依赖
49
+ `effect` 与 `@effect/opentelemetry` 是 `@modern-js/plugin-bff` 的**可选精确 peer
50
+ 依赖**,而不是直接依赖。插件不再自带副本——Effect 4 的 `Context` / `Service` 键按模块
51
+ 实例生成,自带副本会让应用出现第二份 Effect 身份。在设置 `runtimeFramework: 'effect'`
52
+ 或引入 `@modern-js/plugin-bff/effect`、`/effect-server`、`/effect-edge`、
53
+ `/effect-client` 之前,请安装精确版本的依赖组:
54
+
55
+ ```bash
56
+ pnpm add effect@4.0.0-beta.107 @effect/opentelemetry@4.0.0-beta.107
57
+ ```
58
+
59
+ 采用精确版本是因为 UltraModern 以锁步依赖组的方式发布 Effect。只使用
60
+ `runtimeFramework: 'hono'` 或 `./data-platform` 通道的应用无需安装这两个包。
61
+ :::
62
+
48
63
  生成的 UltraModern workspace 只把这个运行时作为生成 HTTP API 路径。API 契约固定在
49
64
  `shared/api.ts`,服务端运行时固定在 `api/index.ts`,客户端固定在
50
65
  `src/api/*-client.ts`。生成检查会拒绝 `api/effect`、`api/lambda`、
@@ -198,25 +213,23 @@ UltraModern 生成的 workspace 会通过 `pnpm-workspace.yaml` overrides 锁定
198
213
  Effect 版本组。当前 UltraModern 版本组使用:
199
214
 
200
215
  ```yaml
201
- minimumReleaseAgeExclude:
202
- - 'effect@4.0.0-beta.97'
203
- - '@effect/opentelemetry@4.0.0-beta.97'
204
-
205
216
  trustPolicyExclude:
206
- - 'effect@4.0.0-beta.97'
207
- - '@effect/opentelemetry@4.0.0-beta.97'
217
+ - 'effect@4.0.0-beta.107'
218
+ - '@effect/opentelemetry@4.0.0-beta.107'
208
219
 
209
220
  overrides:
210
- '@effect/opentelemetry': 4.0.0-beta.97
211
- '@effect/vitest': 4.0.0-beta.97
212
- effect: 4.0.0-beta.97
221
+ '@effect/opentelemetry': 4.0.0-beta.107
222
+ '@effect/vitest': 4.0.0-beta.107
223
+ effect: 4.0.0-beta.107
213
224
  ```
214
225
 
215
226
  不要在应用包里添加不同版本的直接 `effect` 依赖。Effect beta 不一致时,Layer 或 HTTP
216
- middleware 构建可能因为运行时 service 来自不同包实例而失败。保留生成的 policy
217
- exclusion 条目并让它跟随同一个 Effect 版本组;它用于处理框架选定 Effect beta 版本在
218
- 24 小时成熟期内的安装,以及 `effect` 和 `@effect/opentelemetry` 从 trusted-publisher
219
- metadata 迁移到 provenance attestation 时的 pnpm no-downgrade 检查。
227
+ middleware 构建可能因为运行时 service 来自不同包实例而失败。严格的 24 小时发布年龄
228
+ 门禁适用于实际安装的包;当前版本组没有 Effect 年龄豁免,且仅用于 override
229
+ `@effect/vitest` 不是已安装的审批目标。
230
+ `trustPolicyExclude` 是另一项独立策略:其中精确的 `effect`
231
+ `@effect/opentelemetry` 例外用于处理 trusted-publisher metadata 向 provenance
232
+ attestation 的迁移,并不等同于 release-age 审批。
220
233
 
221
234
  ## 契约测试
222
235
 
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: mockDir
3
+ ---
4
+
5
+ # dev.mockDir
6
+
7
+ - **类型:** `string`
8
+ - **默认值:** `'./config/mock'`
9
+
10
+ 设置 Mock API 入口文件所在的目录。相对路径基于应用目录解析,同时也支持绝对路径。
11
+ 开发环境下,Modern.js 会加载该目录中的 `index.ts` 或 `index.js`。
12
+
13
+ 例如,将 Mock API 入口移动到 `mocks/index.ts`:
14
+
15
+ ```js title="modern.config.ts"
16
+ import { defineConfig } from '@modern-js/app-tools';
17
+
18
+ export default defineConfig({
19
+ dev: {
20
+ mockDir: './mocks',
21
+ },
22
+ });
23
+ ```
24
+
25
+ 在 Monorepo 中,也可以让多个应用指向一个共享的 Mock 目录:
26
+
27
+ ```js title="modern.config.ts"
28
+ export default defineConfig({
29
+ dev: {
30
+ mockDir: '../../shared/mocks',
31
+ },
32
+ });
33
+ ```
@@ -7,24 +7,20 @@ title: rsc
7
7
  - **类型:** `boolean`
8
8
  - **默认值:** `false`
9
9
 
10
- 启用 React Server Components (RSC) 配置。
10
+ 配置 React Server Components (RSC)
11
11
 
12
- 当设置为 `true` 时,启用 Modern.js 的 React Server Components 支持。这允许组件在服务端渲染,提供更好的性能和开发体验。
12
+ :::warning UltraModern 可用性
13
+ 当前 UltraModern 公司发行版不提供也不支持 RSC。请保持该选项为 `false`。Rspack Flight 运行时仍在上游审查中;除非应用显式提供完整的可选工具链,否则启用 RSC 会按设计失败。
14
+
15
+ 请勿安装 `react-server-dom-rspack`,也不要添加应用级 pnpm 补丁来绕过此边界。
16
+ :::
13
17
 
14
18
  ```ts title="modern.config.ts"
15
19
  export default defineConfig({
16
20
  server: {
17
- rsc: true,
21
+ rsc: false,
18
22
  },
19
23
  });
20
24
  ```
21
25
 
22
- :::tip 前置条件
23
- 在启用 RSC 之前,请确保:
24
- 1. React 和 React DOM 已升级到 19 版本(建议 19.2.4 以上版本)
25
- 2. 已安装 `react-server-dom-rspack@0.0.1-beta.1` 依赖
26
-
27
- :::
28
-
29
- 有关使用 RSC 的更多信息,请参阅 [React Server Components 指南](/guides/basic-features/render/rsc)。
30
-
26
+ [React Server Components 指南](/guides/basic-features/render/rsc) 仅作为未来采用上游实现时的参考资料保留。
@@ -0,0 +1,72 @@
1
+ ---
2
+ title: reactCompiler
3
+ ---
4
+
5
+ # source.reactCompiler
6
+
7
+ - **类型:** `boolean | ReactCompilerOptions`
8
+ - **默认值:** `undefined`(不开启)
9
+
10
+ 是否启用 [React Compiler](https://zh-hans.react.dev/learn/react-compiler)。React Compiler 是一个构建期工具,通过自动记忆化(memoization)优化 React 应用的重渲染性能。
11
+
12
+ Modern.js 基于 Rspack `builtin:swc-loader` 内置的 Rust 版 React Compiler 实现该能力(等价于设置 SWC 的 `jsc.transform.reactCompiler`),复用 Rspack 内置的 SWC 转换链,无需额外引入 Babel。
13
+
14
+ :::tip
15
+ 该配置默认关闭,任何 React 版本下都需要显式开启,包括 React 19。
16
+ :::
17
+
18
+ ## 示例
19
+
20
+ ### 开启 React Compiler(React 19)
21
+
22
+ ```ts title="modern.config.ts"
23
+ import { defineConfig } from '@modern-js/app-tools';
24
+
25
+ export default defineConfig({
26
+ source: {
27
+ reactCompiler: true,
28
+ },
29
+ });
30
+ ```
31
+
32
+ ### 在 React 18 中使用
33
+
34
+ React Compiler 编译产物默认面向 React 19。在 React 18 项目中使用时,需要:
35
+
36
+ 1. 将 [react-compiler-runtime](https://www.npmjs.com/package/react-compiler-runtime) 安装为**运行时依赖**(编译产物会在运行时引用它):
37
+
38
+ ```bash
39
+ npm add react-compiler-runtime
40
+ ```
41
+
42
+ 2. 通过 `target` 指定 React 版本:
43
+
44
+ ```ts title="modern.config.ts"
45
+ import { defineConfig } from '@modern-js/app-tools';
46
+
47
+ export default defineConfig({
48
+ source: {
49
+ reactCompiler: {
50
+ target: '18',
51
+ },
52
+ },
53
+ });
54
+ ```
55
+
56
+ ### 自定义编译行为
57
+
58
+ 传入对象时,选项与 Rspack `jsc.transform.reactCompiler` 一致,例如通过 `compilationMode: 'annotation'` 仅编译带有 `"use memo"` 指令的函数:
59
+
60
+ ```ts title="modern.config.ts"
61
+ import { defineConfig } from '@modern-js/app-tools';
62
+
63
+ export default defineConfig({
64
+ source: {
65
+ reactCompiler: {
66
+ compilationMode: 'annotation',
67
+ },
68
+ },
69
+ });
70
+ ```
71
+
72
+ 完整选项请参考 [Rsbuild - reactCompiler](https://rsbuild.rs/plugins/list/plugin-react#reactcompiler) 与 [React Compiler 配置文档](https://zh-hans.react.dev/reference/react-compiler/configuration)。
@@ -144,19 +144,50 @@ const myPlugin = (): RuntimePlugin => ({
144
144
 
145
145
  插件使用的 i18next 实例类型(i18next `i18n` 类型的子集,仅列出插件实际使用的字段):
146
146
 
147
+ :::warning 破坏性变更(UltraModern)
148
+ `I18nInstance` 不再声明顶层的 `[key: string]: unknown` 索引签名:TypeScript 永远不会
149
+ 为 interface 自动添加隐式索引签名,该成员会让文档中的
150
+ `runtime: { i18n: { i18nInstance: i18next } }` 用法无法通过类型检查。读取下方未声明的
151
+ 属性现在会报类型错误(TS2339),请改为断言到具体的实例类型。`t` 现在是**必需**成员,
152
+ 因此以对象字面量构造 `I18nInstance` 时必须提供 `t`。
153
+ :::
154
+
147
155
  ```ts
156
+ type TranslateFn = (
157
+ key: string | string[],
158
+ options?: Record<string, unknown>,
159
+ ) => string;
160
+
148
161
  interface I18nInstance {
149
162
  language: string;
150
- isInitialized: boolean;
151
- init: (options?: I18nInitOptions) => void | Promise<void>;
152
- changeLanguage: (lang: string) => void | Promise<void>;
153
- use: (plugin: any) => void;
154
- createInstance: (options?: I18nInitOptions) => I18nInstance;
163
+ isInitialized?: boolean;
164
+ init(options?: any, callback?: any): Promise<any>;
165
+ changeLanguage?(lng?: string, callback?: any): Promise<any>;
166
+ setLang?: (lang: string) => void | Promise<void>;
167
+ use(plugin: any): unknown;
168
+ t: TranslateFn;
169
+ exists?: (key: string | string[], options?: Record<string, unknown>) => boolean;
170
+ getFixedT?: (
171
+ lng: string | readonly string[] | null,
172
+ ns?: string | readonly string[] | null,
173
+ keyPrefix?: string,
174
+ ) => TranslateFn;
175
+ hasLoadedNamespace?: (
176
+ ns: string | readonly string[],
177
+ options?: Record<string, unknown>,
178
+ ) => boolean;
179
+ dir?: (lng?: string) => string;
180
+ languages?: readonly string[];
181
+ resolvedLanguage?: string;
182
+ createInstance?(options?: any, callback?: any): I18nInstance;
183
+ cloneInstance?(options?: any, callback?: any): I18nInstance;
155
184
  options?: {
156
- backend?: BackendOptions;
157
- supportedLngs?: string[];
158
- [key: string]: any;
185
+ detection?: any;
186
+ backend?: any;
187
+ ns?: any;
188
+ defaultNS?: any;
159
189
  };
190
+ // ...完整成员列表见 src/runtime/i18n/instance.ts。
160
191
  }
161
192
  ```
162
193
 
@@ -20,6 +20,16 @@ Modern.js 提供了快速生成 Mock 数据的功能,能够让前端独立自
20
20
  └── modern.config.ts
21
21
  ```
22
22
 
23
+ 你可以通过 [`dev.mockDir`](/configure/app/dev/mock-dir) 将 Mock 入口放到其他目录:
24
+
25
+ ```js title="modern.config.ts"
26
+ export default {
27
+ dev: {
28
+ mockDir: './mocks',
29
+ },
30
+ };
31
+ ```
32
+
23
33
  ## 编写 Mock 文件
24
34
 
25
35
  `config/mock/index.ts` 文件只需要导出一个包含所有 Mock API 的对象,对象的属性由请求配置 `method` 和 `url` 组成,对应的属性值可以为 `Object`、`Array`、`Function`:
@@ -317,7 +317,7 @@ Github Pages 支持两种部署方式,通过分支部署或通过 Github Actio
317
317
  :::info
318
318
 
319
319
  1. 执行 `MODERNJS_DEPLOY=ghPages modern deploy`,UltraModern.js 会把可用于 github 部署的产物构建到 `.output` 目录。
320
- 2. 可以参考项目[示例](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/modern-js-deploy-csr)。
320
+ 2. 可以参考仓库内的[示例](https://github.com/web-infra-dev/modern.js/tree/main/examples/modern-js-deploy-csr)。
321
321
 
322
322
  :::
323
323
 
@@ -21,29 +21,20 @@ React Server Components (RSC) 是一种新的组件类型,允许在服务端
21
21
 
22
22
  ## 快速开始
23
23
 
24
- 1. **确保 React 和 React DOM 升级到 19 版本**(建议 19.2.4 以上版本)
25
-
26
- 2. **安装 `react-server-dom-rspack@0.0.1-beta.1` 依赖**
27
-
28
- ```bash
29
- npm install react-server-dom-rspack@0.0.1-beta.1
30
- ```
31
-
32
- :::warning 注意事项
33
-
34
- 1. 目前暂不支持在 SPA 项目中使用 [Server Functions](https://react.dev/reference/rsc/server-functions)
35
- 2. 目前在 Rspack 构建时,产物分片和体积还未达到最优状态,我们将在近期进一步优化
24
+ :::warning UltraModern 可用性
25
+ 当前 UltraModern 公司发行版不提供也不支持 RSC。在 Rspack Flight 运行时完成上游工作之前,框架会保持 [`server.rsc`](/configure/app/server/rsc) 关闭。请勿安装 `react-server-dom-rspack`,也不要携带应用级 pnpm 补丁来提前启用它。
36
26
 
27
+ 本页其余内容仅作为未来采用上游实现时的参考资料保留。
37
28
  :::
38
29
 
39
- 3. 设置 [`server.rsc`](/configure/app/server/rsc) 为 `true`:
30
+ 请保持 [`server.rsc`](/configure/app/server/rsc) 为 `false`:
40
31
 
41
32
  ```ts title="modern.config.ts"
42
33
  import { defineConfig } from '@modern-js/app-tools';
43
34
 
44
35
  export default defineConfig({
45
36
  server: {
46
- rsc: true,
37
+ rsc: false,
47
38
  },
48
39
  });
49
40
  ```
@@ -5,16 +5,31 @@ sidebar_position: 6
5
5
 
6
6
  # Modern.js For AI
7
7
 
8
- Modern.js 为 AI Agent 提供了一套工具套件,帮助开发者利用 AI 高效完成 Modern.js 应用的功能开发、依赖升级与版本迁移工作。
8
+ Modern.js 为 AI Agent 提供了一套工具套件,让项目开箱即为 agent-ready,帮助你更准确、高效地用 AI 完成 Modern.js 应用的开发、升级与迁移。
9
+
10
+ ## 随包文档
11
+
12
+ Modern.js 把与你安装版本一致的英文文档随 `@modern-js/app-tools` 一起分发。安装或升级后,文档即位于 `node_modules/@modern-js/app-tools/docs/`,离线可用、无需额外配置。
13
+
14
+ AI Agent 由此获取与当前框架版本严格匹配的 API、配置与约定,而不是依赖可能过时的训练数据。
15
+
16
+ ## AGENTS.md
17
+
18
+ `AGENTS.md` 是给 AI 编码助手的项目指引,告诉它在动手前先阅读随包文档、并遵循 Modern.js 的约定;同时会生成 `CLAUDE.md`,通过 `@AGENTS.md` 让 Claude Code 复用同一份指引。
19
+
20
+ - **新建项目**:`npx @modern-js/create` 默认生成这两个文件,加 `--no-agents-md` 可跳过。
21
+ - **已有项目**:在项目根运行 `npx @modern-js/create --agents-md-only` 生成或更新,可随时重复运行,你添加的自定义内容会被保留。
22
+
23
+ Modern.js 只维护 `AGENTS.md` 中 `<!-- BEGIN:modernjs-agent-rules -->` 标记内的内容,标记之外你写的内容不会被改动。
9
24
 
10
25
  ## llms.txt
11
26
 
12
- Modern.js 文档遵循 [llms.txt 规范](https://llmstxt.org/),由 [`@rspress/plugin-llms`](https://rspress.rs/plugin/official-plugins/llms) 自动生成,可通过 `/llms.txt` 或 `/llms-full.txt` 供 AI 工具检索:
27
+ llms.txt 是遵循 [llms.txt 规范](https://llmstxt.org/) 的在线文档索引,由 [`@rspress/plugin-llms`](https://rspress.rs/plugin/official-plugins/llms) 自动生成,供 AI 工具在线检索完整文档:
13
28
 
14
29
  - 索引:[`https://modernjs.dev/llms.txt`](https://modernjs.dev/llms.txt)
15
- - 全文:`https://modernjs.dev/llms-full.txt`(体积较大,按需取片段)
30
+ - 全文:[`https://modernjs.dev/llms-full.txt`](https://modernjs.dev/llms-full.txt)(体积较大,按需取片段)
16
31
 
17
- 大部分「这个 API / 配置是什么」类问题,靠 llms.txt 即可解决。让你的 Agent 按需检索它即可,不必把文档复制进项目。
32
+ 当需要查阅随包文档之外的内容时,让 Agent 在线检索它即可,不必把文档复制进项目。典型场景包括:查阅其他框架版本、随包未包含的章节,或在 Modern.js 项目之外获取信息(例如尚未创建项目、或独立查阅资料时)。
18
33
 
19
34
  ## Skills
20
35
 
@@ -128,12 +128,24 @@ pnpm overrides/trust policy 和 pnpm lockfile。剩余失败就是源码迁移
128
128
  `api/lambda`、`shared/effect` 和 `src/effect`。
129
129
 
130
130
  严格 Effect 生成 workspace 会通过 pnpm overrides 固定兼容版本组:
131
- `effect@4.0.0-beta.97`、`@effect/opentelemetry@4.0.0-beta.97` 和
132
- `@effect/vitest@4.0.0-beta.97`。不要添加与这些 overrides 冲突的 app 本地直接
133
- Effect 版本。生成的 pnpm policy 还会为 `effect@4.0.0-beta.97` 和
134
- `@effect/opentelemetry@4.0.0-beta.97` 添加例外,避免框架选定的 Effect beta
135
- 版本组被 24 小时成熟期检查,或从 trusted-publisher metadata 迁移到 provenance
136
- attestation 时被 no-downgrade 检查误拦截。
131
+ `effect@4.0.0-beta.107`、`@effect/opentelemetry@4.0.0-beta.107` 和
132
+ `@effect/vitest@4.0.0-beta.107`。不要添加与这些 overrides 冲突的 app 本地直接
133
+ Effect 版本。严格的 24 小时发布年龄门禁适用于实际安装的包;当前版本组不包含 Effect
134
+ 年龄豁免,仅用于 override 的 `@effect/vitest` 也不是已安装的审批目标。
135
+ `trustPolicyExclude` 是独立策略,仅为 `effect`
136
+ `@effect/opentelemetry` 保留精确例外,以处理 trusted-publisher metadata 向
137
+ provenance attestation 的迁移;它不属于 release-age 审批。
138
+
139
+ ### 当前生成依赖基线
140
+
141
+ | 范围 | 固定版本 |
142
+ | --- | --- |
143
+ | Effect runtime 与测试版本组 | `effect`、`@effect/opentelemetry`、`@effect/vitest`:`4.0.0-beta.107` |
144
+ | Effect compiler | `@effect/tsgo@0.36.2` |
145
+ | TanStack Router | `@tanstack/react-router@1.170.25`、`@tanstack/router-core@1.171.21`、`@tanstack/history@1.162.1` |
146
+ | Module Federation | `bridge-react`、`manifest`、`modern-js-v3`、`rspack`:`2.8.2`;`@module-federation/node@2.7.49` |
147
+ | React Router | `react-router@7.18.2` |
148
+ | Node 与包管理工具 | Node `26.7.0`、`@types/node@^26.2.0`、pnpm `11.21.0` |
137
149
 
138
150
  渐进迁移意味着尚未迁移的旧 Modern.js app 可以保留现有 runtime,直到被转换为
139
151
  UltraModern。一个 surface 一旦生成为或迁移为 UltraModern HTTP API,就只能使用
@@ -24,7 +24,7 @@ Modern.js 所有的官方包使用**统一版本号**进行发布,因此升级
24
24
  - 访问 [npm](https://www.npmjs.com/package/@modern-js/app-tools) 查看 `@modern-js/app-tools` 的最新版本
25
25
  - 查看 [GitHub Releases](https://github.com/web-infra-dev/modern.js/releases)
26
26
 
27
- <ReleaseNote />
27
+ <ReleaseNote />
28
28
 
29
29
  2. **更新 package.json**
30
30
 
@@ -46,7 +46,7 @@ Modern.js 所有的官方包使用**统一版本号**进行发布,因此升级
46
46
 
47
47
  更新完 `package.json` 后,重新安装依赖:
48
48
 
49
- <PackageManagerTabs command="install" />
49
+ <PackageManagerTabs command="install" />
50
50
 
51
51
  :::tip
52
52
  当升级时,需要对 Modern.js 官方提供的所有包做统一升级,而不是升级单个依赖。确保所有 `@modern-js/**` 包的版本号保持一致。
@@ -72,16 +72,11 @@ Modern.js 所有的官方包使用**统一版本号**进行发布,因此升级
72
72
 
73
73
  ### pnpm
74
74
 
75
- 对于使用 pnpm 的项目,请在**项目根目录**的 `package.json` 中添加以下配置,然后重新执行 `pnpm install`:
75
+ 对于使用 pnpm 的项目,请在**项目根目录**的 `pnpm-workspace.yaml` 中添加以下配置,然后重新执行 `pnpm install`:
76
76
 
77
- ```json title="package.json"
78
- {
79
- "pnpm": {
80
- "overrides": {
81
- "package-name": "^1.0.0"
82
- }
83
- }
84
- }
77
+ ```yaml title="pnpm-workspace.yaml"
78
+ overrides:
79
+ package-name: ^1.0.0
85
80
  ```
86
81
 
87
82
  ### Yarn
@@ -109,6 +104,6 @@ Modern.js 所有的官方包使用**统一版本号**进行发布,因此升级
109
104
  ```
110
105
 
111
106
  :::info
112
- 对于 Monorepo 仓库,只能在项目根目录的 `package.json` 中锁定依赖版本,并且会影响 Monorepo 中的所有 package。
107
+ 对于 Monorepo 仓库,请在项目根目录的包管理器配置中锁定依赖版本;该 override 会影响 Monorepo 中的所有 package。
113
108
 
114
109
  :::
@@ -63,7 +63,7 @@ export default createModuleFederationConfig({
63
63
  ```
64
64
 
65
65
  :::info
66
- [`createBridgeComponent`](https://module-federation.io/zh/practice/bridge/react-bridge/export-app.html#createbridgecomponent-api-%E5%8F%82%E8%80%83) 用于导出应用级别模块,Modern.js 相关 API 可以查看 [createRoot](/apis/app/runtime/core/create-root)、[render](/apis/app/runtime/core/render)。
66
+ [`createBridgeComponent`](https://module-federation.io/zh/guide/bridge/overview.html#%E6%A0%B8%E5%BF%83-api) 用于导出应用级别模块,Modern.js 相关 API 可以查看 [createRoot](/apis/app/runtime/core/create-root)、[render](/apis/app/runtime/core/render)。
67
67
  :::
68
68
 
69
69
  ## 消费者使用模块
@@ -99,7 +99,7 @@ export default RemoteApp;
99
99
  ```
100
100
 
101
101
  :::info
102
- [`createRemoteAppComponent`](https://module-federation.io/zh/practice/bridge/react-bridge/load-app.html#%E4%BB%80%E4%B9%88%E6%98%AF-createremoteappcomponent) 用于加载应用级别模块。
102
+ [`createRemoteAppComponent`](https://module-federation.io/zh/guide/bridge/overview.html#%E6%A0%B8%E5%BF%83-api) 用于加载应用级别模块。
103
103
  :::
104
104
 
105
105
  ## 启动应用
@@ -110,8 +110,8 @@ export default RemoteApp;
110
110
 
111
111
  你可以在生产者应用中,创建新的路由文件,并在代码中添加路由导航,可以发现这些功能也能够正常运行。
112
112
 
113
- 上述用例可以参考:[Modern.js & Module Federation 应用级别模块](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/module-federation/app-export)。
113
+ 上述用例可以参考:[Modern.js & Module Federation 应用级别模块](https://github.com/web-infra-dev/modern.js/tree/main/examples/module-federation/app-export)。
114
114
 
115
115
  ## 相关文档
116
116
 
117
- - [Module Federation Bridge](https://module-federation.io/zh/practice/bridge/index.html)
117
+ - [Module Federation Bridge](https://module-federation.io/zh/guide/bridge/overview)
@@ -193,7 +193,7 @@ export default defineConfig({
193
193
  在使用 `modern serve` 命令时,需要在启动生产者项目时携带 `MODERN_MF_AUTO_CORS=true` 环境变量,以自动处理跨域问题,确保消费者可以正常访问生产者的远程模块资源。
194
194
  :::
195
195
 
196
- 上述用例可以参考:[Modern.js & Module Federation 基础用法示例](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/module-federation/base)。
196
+ 上述用例可以参考:[Modern.js & Module Federation 基础用法示例](https://github.com/web-infra-dev/modern.js/tree/main/examples/module-federation/base)。
197
197
 
198
198
  ## 相关文档
199
199
 
package/package.json CHANGED
@@ -19,12 +19,12 @@
19
19
  "modern.js",
20
20
  "ultramodern.js"
21
21
  ],
22
- "version": "3.5.0-ultramodern.98",
22
+ "version": "3.8.1-ultramodern.1",
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@modern-js/sandpack-react": "npm:@bleedingdev/modern-js-sandpack-react@3.5.0-ultramodern.98",
27
+ "@modern-js/sandpack-react": "npm:@bleedingdev/modern-js-sandpack-react@3.8.1-ultramodern.1",
28
28
  "mermaid": "^11.16.0"
29
29
  },
30
30
  "devDependencies": {
@@ -34,17 +34,32 @@
34
34
  "@rspress/shared": "2.0.17",
35
35
  "@shikijs/transformers": "^4.3.1",
36
36
  "@types/fs-extra": "11.0.4",
37
- "@types/node": "^26.1.1",
37
+ "@types/node": "^26.2.0",
38
38
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
39
39
  "classnames": "^2.5.1",
40
40
  "clsx": "^2.1.1",
41
41
  "fs-extra": "^11.3.6",
42
- "react": "^19.2.7",
43
- "react-dom": "^19.2.7",
42
+ "react": "^19.2.8",
43
+ "react-dom": "^19.2.8",
44
44
  "rsbuild-plugin-open-graph": "1.1.3",
45
45
  "ts-node": "^10.9.2",
46
46
  "typescript": "^7.0.2"
47
47
  },
48
+ "nx": {
49
+ "targets": {
50
+ "build": {
51
+ "inputs": [
52
+ "build",
53
+ "^build",
54
+ "{projectRoot}/docs/**/*",
55
+ "{projectRoot}/rspress.config.ts"
56
+ ],
57
+ "outputs": [
58
+ "{projectRoot}/doc_build"
59
+ ]
60
+ }
61
+ }
62
+ },
48
63
  "scripts": {
49
64
  "dev": "rspress dev",
50
65
  "dev:no_lazy": "LAZY=false rspress dev",