@modern-js/main-doc 2.35.1 → 2.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/docs/en/apis/app/hooks/src/routes.mdx +1 -1
  2. package/docs/en/components/debug-app.mdx +1 -1
  3. package/docs/en/components/turtorials-example-list.mdx +2 -0
  4. package/docs/en/configure/app/source/entries.mdx +7 -6
  5. package/docs/en/guides/advanced-features/bff/sdk.mdx +119 -0
  6. package/docs/en/guides/advanced-features/rspack-start.mdx +1 -1
  7. package/docs/en/guides/advanced-features/ssr.mdx +17 -17
  8. package/docs/en/guides/basic-features/data/_category_.json +4 -0
  9. package/docs/en/guides/basic-features/{data-fetch.mdx → data/data-fetch.mdx} +35 -27
  10. package/docs/en/guides/basic-features/data/data-write.mdx +241 -0
  11. package/docs/en/guides/basic-features/routes.mdx +7 -7
  12. package/docs/en/guides/concept/entries.mdx +31 -30
  13. package/docs/en/guides/get-started/quick-start.mdx +1 -1
  14. package/docs/en/guides/topic-detail/framework-plugin/extend.mdx +0 -1
  15. package/docs/en/guides/topic-detail/framework-plugin/hook-list.mdx +0 -1
  16. package/docs/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  17. package/docs/en/guides/topic-detail/framework-plugin/implement.mdx +1 -2
  18. package/docs/en/guides/topic-detail/framework-plugin/introduction.mdx +1 -1
  19. package/docs/en/guides/topic-detail/framework-plugin/lifecycle.mdx +1 -1
  20. package/docs/en/guides/topic-detail/framework-plugin/plugin-api.mdx +31 -11
  21. package/docs/en/guides/topic-detail/framework-plugin/relationship.mdx +2 -2
  22. package/docs/en/guides/topic-detail/generator/new/config.md +0 -5
  23. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +2 -2
  24. package/docs/en/tutorials/first-app/c05-loader.mdx +2 -2
  25. package/docs/en/tutorials/first-app/c06-model.mdx +4 -4
  26. package/docs/en/tutorials/first-app/c07-container.mdx +3 -3
  27. package/docs/en/tutorials/foundations/introduction.mdx +3 -2
  28. package/docs/zh/apis/app/hooks/src/routes.mdx +1 -1
  29. package/docs/zh/components/debug-app.mdx +1 -1
  30. package/docs/zh/components/micro-runtime-config.mdx +2 -2
  31. package/docs/zh/components/turtorials-example-list.mdx +2 -0
  32. package/docs/zh/configure/app/source/entries.mdx +7 -6
  33. package/docs/zh/guides/advanced-features/bff/sdk.mdx +119 -0
  34. package/docs/zh/guides/advanced-features/rspack-start.mdx +1 -1
  35. package/docs/zh/guides/advanced-features/ssr.mdx +16 -16
  36. package/docs/zh/guides/basic-features/data/_category_.json +4 -0
  37. package/docs/zh/guides/basic-features/{data-fetch.mdx → data/data-fetch.md} +31 -27
  38. package/docs/zh/guides/basic-features/data/data-write.mdx +236 -0
  39. package/docs/zh/guides/basic-features/routes.mdx +7 -7
  40. package/docs/zh/guides/concept/entries.mdx +34 -32
  41. package/docs/zh/guides/get-started/quick-start.mdx +1 -1
  42. package/docs/zh/guides/topic-detail/framework-plugin/extend.mdx +0 -1
  43. package/docs/zh/guides/topic-detail/framework-plugin/hook-list.mdx +0 -1
  44. package/docs/zh/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  45. package/docs/zh/guides/topic-detail/framework-plugin/implement.mdx +0 -1
  46. package/docs/zh/guides/topic-detail/framework-plugin/introduction.mdx +1 -1
  47. package/docs/zh/guides/topic-detail/framework-plugin/lifecycle.mdx +1 -1
  48. package/docs/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +31 -11
  49. package/docs/zh/guides/topic-detail/framework-plugin/relationship.mdx +1 -1
  50. package/docs/zh/guides/topic-detail/generator/new/config.md +0 -5
  51. package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +2 -2
  52. package/docs/zh/guides/topic-detail/monorepo/create-sub-project.mdx +0 -14
  53. package/docs/zh/guides/topic-detail/monorepo/sub-project-interface.mdx +7 -43
  54. package/docs/zh/tutorials/first-app/c05-loader.mdx +2 -2
  55. package/docs/zh/tutorials/first-app/c06-model.mdx +3 -3
  56. package/docs/zh/tutorials/first-app/c07-container.mdx +3 -3
  57. package/docs/zh/tutorials/foundations/introduction.mdx +3 -2
  58. package/package.json +7 -7
@@ -11,7 +11,6 @@ sidebar_position: 3
11
11
  按照 [「创建子项目」](/guides/topic-detail/monorepo/create-sub-project) 章节的介绍(如果还没有看过,可以先了解一下),我们首先创建以下三个子项目:
12
12
 
13
13
  - 一个「应用」子项目
14
- - 一个「模块(内部)」子项目
15
14
  - 一个「模块」子项目
16
15
 
17
16
  执行 `pnpm run new`,并按照如下进行选择:
@@ -25,15 +24,6 @@ sidebar_position: 3
25
24
  ? 请选择开发语言:TS
26
25
  ```
27
26
 
28
- **「模块(内部)」子项目:**
29
-
30
- ```
31
- ? 请选择你想创建的工程类型:Npm 模块(内部)
32
- ? 请填写子项目名称:internal-lib
33
- ? 请填写子项目目录名称:internal-lib
34
- ? 请选择开发语言:TS
35
- ```
36
-
37
27
  **「模块」子项目:**
38
28
 
39
29
  ```
@@ -47,7 +37,6 @@ sidebar_position: 3
47
37
 
48
38
  - `./apps/app`
49
39
  - `./packages/components`
50
- - `./features/internal-lib`
51
40
 
52
41
  然后修改一下默认的代码和新增文件:
53
42
 
@@ -73,19 +62,10 @@ export default function ({ text }: { text: string }) {
73
62
  }
74
63
  ```
75
64
 
76
- **修改 `./features/internal-lib/src/index.ts`**
77
-
78
- ```tsx
79
- export default function (text: string) {
80
- return text.toUpperCase();
81
- }
82
- ```
83
-
84
65
  **修改 `./apps/app/src/App.tsx`**
85
66
 
86
67
  ```tsx
87
68
  import { Switch, Route } from '@modern-js/runtime/router';
88
- import formatString from 'internal-lib';
89
69
  import Comp from 'components';
90
70
 
91
71
  import './App.css';
@@ -94,7 +74,7 @@ const App = () => (
94
74
  <Switch>
95
75
  <Route exact={true} path="/">
96
76
  <div className="container-box">
97
- <Comp text={formatString('hello world')} />
77
+ <Comp text="hello world" />
98
78
  {/* 省略... */}
99
79
  </div>
100
80
  </Route>
@@ -107,7 +87,7 @@ const App = () => (
107
87
  export default App;
108
88
  ```
109
89
 
110
- 到此为止我们创建了一个可以被发布到外部的组件项目、一个转换字符串的内部模块项目以及一个使用组件和内部模块的应用项目,如果直接运行应用项目还暂时无法正常使用。接下来将要介绍如何让它们能够互相联调使用,成功的使应用子项目 `apps/app` 正常运行。
90
+ 到此为止我们创建了一个可以被发布到外部的组件项目以及一个使用组件的应用项目,如果直接运行应用项目还暂时无法正常使用。接下来将要介绍如何让它们能够互相联调使用,成功的使应用子项目 `apps/app` 正常运行。
111
91
 
112
92
  :::info
113
93
  启动 `apps/app` 项目之前需要先构建(`pnpm run build`) `packages/component`。
@@ -118,25 +98,12 @@ export default App;
118
98
 
119
99
  ## 在使用 pnpm 的 Monorepo 中进行项目联调
120
100
 
121
- 在 pnpm 的 Monorepo 项目中,我们通过在 `apps/app` 子项目下分别执行:
101
+ 在 pnpm 的 Monorepo 项目中,我们通过在 `apps/app` 子项目下执行以下命令,将 `packages/components` 子项目加入到应用的依赖列表当中。
122
102
 
123
103
  ```
124
104
  pnpm add components
125
105
  ```
126
106
 
127
- 以及
128
-
129
- ```
130
- pnpm add internal-lib -D
131
- ```
132
-
133
- :::info
134
- 注意这里将 internal-lib 作为 `apps/app` 项目的开发依赖,因为在构建环境会被打包到构建产物中。
135
-
136
- :::
137
-
138
- 将 `packages/components` 与 `features/internal-lib` 子项目加入到应用的依赖列表当中。
139
-
140
107
  执行成功后,在 `apps/app/package.json` 会发生如下变化:
141
108
 
142
109
  ```json
@@ -144,9 +111,6 @@ pnpm add internal-lib -D
144
111
  "dependencies": {
145
112
  ++ "components": "workspace:^0.1.0"
146
113
  },
147
- "devDependencies": {
148
- ++ "internal-lib": "workspace:^0.1.0"
149
- },
150
114
  }
151
115
  ```
152
116
 
@@ -157,18 +121,18 @@ pnpm add internal-lib -D
157
121
 
158
122
  当依赖安装成功之后,我们还需要将 `packages/components` 进行构建,因为需要使用其构建产物。
159
123
 
160
- 到此为止,`app/apps` 应用子项目可以正常的运行了。在修改 `features/internal-lib` 的源码,或者修改 `packages/components` 的源码并构建之后都会触发应用子项目的热更新。
124
+ 到此为止,`app/apps` 应用子项目可以正常的运行了。在修改 `packages/components` 的源码并构建之后,会触发应用子项目的热更新。
161
125
 
162
126
  ## 在使用 Yarn 的 Monorepo 中进行项目联调
163
127
 
164
- 在 Yarn 的 Monorepo 项目中,默认情况下可以直接在 `apps/app` 应用项目中直接使用组件项目和内部模块项目。
128
+ 在 Yarn 的 Monorepo 项目中,默认情况下可以直接在 `apps/app` 应用项目中直接使用组件项目。
165
129
 
166
130
  :::info 补充信息
167
- 之所以可以直接在应用中使用使用组件项目和内部模块项目,是因为 Yarn 将这些子项目模块提升到了顶层的 `node_modules`内。
131
+ 之所以可以直接在应用中使用组件项目,是因为 Yarn 将这些子项目模块提升到了顶层的 `node_modules`内。
168
132
 
169
133
  :::
170
134
 
171
- 但是由于组件 `components` 是非内部模块,因此建议在 `apps/app/package.json` 中进行依赖声明:
135
+ 但是考虑到依赖关系的严谨性,建议在 `apps/app/package.json` 中进行显式依赖声明:
172
136
 
173
137
  ```json
174
138
  {
@@ -18,7 +18,7 @@ pnpm add faker@5
18
18
  pnpm add @types/faker@5 -D
19
19
  ```
20
20
 
21
- 创建 `src/routes/page.loader.ts`:
21
+ 创建 `src/routes/page.data.ts`:
22
22
 
23
23
  ```tsx
24
24
  import { name, internet } from 'faker';
@@ -32,7 +32,7 @@ type LoaderData = {
32
32
  }[];
33
33
  };
34
34
 
35
- export default async (): Promise<LoaderData> => {
35
+ export const loader = async (): Promise<LoaderData> => {
36
36
  const data = new Array(20).fill(0).map(() => {
37
37
  const firstName = name.firstName();
38
38
  return {
@@ -192,9 +192,9 @@ const Item = ({
192
192
  export default Item;
193
193
  ```
194
194
 
195
- 接下来,我们修改 `src/routes/page.tsx` 和 `src/routes/page.loader.ts`,为 `<Item>` 组件传递更多参数:
195
+ 接下来,我们修改 `src/routes/page.tsx` 和 `src/routes/page.data.ts`,为 `<Item>` 组件传递更多参数:
196
196
 
197
- ```ts title="src/routes/page.loader.ts"
197
+ ```ts title="src/routes/page.data.ts"
198
198
  export type LoaderData = {
199
199
  code: number;
200
200
  data: {
@@ -204,7 +204,7 @@ export type LoaderData = {
204
204
  }[];
205
205
  };
206
206
 
207
- export default async (): Promise<LoaderData> => {
207
+ export const loader async (): Promise<LoaderData> => {
208
208
  const data = new Array(20).fill(0).map(() => {
209
209
  const firstName = name.firstName();
210
210
  return {
@@ -15,7 +15,7 @@ import { Tabs, Tab as TabItem } from "@theme";
15
15
 
16
16
  Modern.js 支持在 `layout.tsx` 通过 Data Loader 获取数据,我们先数据获取这部分代码移动到 `src/routes/layout.tsx` 中:
17
17
 
18
- ```ts title="src/routes/layout.loader.ts"
18
+ ```ts title="src/routes/layout.data.ts"
19
19
  export type LoaderData = {
20
20
  code: number;
21
21
  data: {
@@ -25,7 +25,7 @@ export type LoaderData = {
25
25
  }[];
26
26
  };
27
27
 
28
- export default async (): Promise<LoaderData> => {
28
+ export const loader = async (): Promise<LoaderData> => {
29
29
  const data = new Array(20).fill(0).map(() => {
30
30
  const firstName = name.firstName();
31
31
  return {
@@ -58,7 +58,7 @@ import 'tailwindcss/base.css';
58
58
  import 'tailwindcss/components.css';
59
59
  import 'tailwindcss/utilities.css';
60
60
  import '../styles/utils.css';
61
- import type { LoaderData } from './layout.loader';
61
+ import type { LoaderData } from './layout.data';
62
62
 
63
63
  export default function Layout() {
64
64
  const { data } = useLoaderData() as LoaderData;
@@ -31,8 +31,9 @@ sidebar_position: 1
31
31
 
32
32
  我们提供了一些在开发过程中常用的案例供你参考,可以在这里找到 Modern.js 提供的一些功能组合的使用方式,我们将持续完善这里的案例。
33
33
 
34
- - [路由鉴权](/tutorials/examples/csr-auth.html)
35
- - ...
34
+ import ExampleList from '@site-docs/components/turtorials-example-list';
35
+
36
+ <ExampleList />
36
37
 
37
38
  下面就让我们从 [创建项目](tutorials/first-app/c01-start) 开始吧!
38
39
 
package/package.json CHANGED
@@ -15,17 +15,17 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.35.1",
18
+ "version": "2.36.0",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "dependencies": {
25
- "@modern-js/sandpack-react": "2.35.1"
25
+ "@modern-js/sandpack-react": "2.36.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "@modern-js/builder-doc": "^2.35.1"
28
+ "@modern-js/builder-doc": "^2.36.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "classnames": "^2",
@@ -35,12 +35,12 @@
35
35
  "ts-node": "^10.9.1",
36
36
  "typescript": "^5",
37
37
  "fs-extra": "^10",
38
- "rspress": "0.0.13",
39
- "@rspress/shared": "0.0.13",
38
+ "rspress": "1.0.0-beta.3",
39
+ "@rspress/shared": "1.0.0-beta.3",
40
40
  "@types/node": "^16",
41
41
  "@types/fs-extra": "^9",
42
- "@modern-js/builder-doc": "2.35.1",
43
- "@modern-js/doc-plugin-auto-sidebar": "2.35.1"
42
+ "@modern-js/builder-doc": "2.36.0",
43
+ "@modern-js/doc-plugin-auto-sidebar": "2.36.0"
44
44
  },
45
45
  "scripts": {
46
46
  "dev": "rspress dev",