@modern-js/main-doc 3.7.0 → 3.8.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.
@@ -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.
@@ -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
+ ```
@@ -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`:
@@ -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
 
@@ -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.
@@ -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) 自定义该目录。
@@ -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
+ ```
@@ -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`:
@@ -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
 
@@ -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/**` 包的版本号保持一致。
package/package.json CHANGED
@@ -16,14 +16,14 @@
16
16
  "modern",
17
17
  "modern.js"
18
18
  ],
19
- "version": "3.7.0",
19
+ "version": "3.8.1",
20
20
  "publishConfig": {
21
21
  "registry": "https://registry.npmjs.org/",
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
25
  "mermaid": "^11.15.0",
26
- "@modern-js/sandpack-react": "3.7.0"
26
+ "@modern-js/sandpack-react": "3.8.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "rsbuild-plugin-open-graph": "1.1.3",
@@ -42,6 +42,21 @@
42
42
  "ts-node": "^10.9.2",
43
43
  "typescript": "^5"
44
44
  },
45
+ "nx": {
46
+ "targets": {
47
+ "build": {
48
+ "inputs": [
49
+ "build",
50
+ "^build",
51
+ "{projectRoot}/docs/**/*",
52
+ "{projectRoot}/rspress.config.ts"
53
+ ],
54
+ "outputs": [
55
+ "{projectRoot}/doc_build"
56
+ ]
57
+ }
58
+ }
59
+ },
45
60
  "scripts": {
46
61
  "dev": "rspress dev",
47
62
  "dev:no_lazy": "LAZY=false rspress dev",