@modern-js/main-doc 2.25.1 → 2.25.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/en/apis/app/commands.mdx +2 -2
  3. package/docs/en/apis/app/hooks/config/icon.mdx +2 -2
  4. package/docs/en/apis/app/runtime/web-server/middleware.mdx +1 -1
  5. package/docs/en/components/custom-router-micro-frontend.mdx +40 -0
  6. package/docs/en/components/ua-polyfill.mdx +1 -1
  7. package/docs/en/configure/app/auto-load-plugin.mdx +1 -1
  8. package/docs/en/configure/app/bff/proxy.mdx +2 -2
  9. package/docs/en/configure/app/builder-plugins.mdx +1 -1
  10. package/docs/en/configure/app/runtime/master-app.mdx +1 -1
  11. package/docs/en/configure/app/runtime/state.mdx +1 -1
  12. package/docs/en/guides/advanced-features/bff/index.mdx +1 -0
  13. package/docs/en/guides/advanced-features/code-split.mdx +1 -1
  14. package/docs/en/guides/advanced-features/rspack-start.mdx +1 -1
  15. package/docs/en/guides/advanced-features/ssr.mdx +1 -1
  16. package/docs/en/guides/basic-features/data-fetch.mdx +1 -1
  17. package/docs/en/guides/topic-detail/changesets/add.mdx +1 -1
  18. package/docs/en/guides/topic-detail/changesets/release-pre.mdx +1 -1
  19. package/docs/en/guides/topic-detail/changesets/release.mdx +1 -1
  20. package/docs/en/guides/topic-detail/generator/create/option.md +3 -3
  21. package/docs/en/guides/topic-detail/generator/plugin/api/afterForged.md +1 -1
  22. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +2 -2
  23. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +3 -3
  24. package/docs/en/guides/topic-detail/model/manage-effects.mdx +1 -1
  25. package/docs/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  26. package/docs/en/guides/topic-detail/model/performance.mdx +1 -1
  27. package/docs/en/guides/topic-detail/model/quick-start.mdx +2 -2
  28. package/docs/en/guides/topic-detail/model/use-model.mdx +3 -3
  29. package/docs/zh/apis/monorepo/commands/deploy.mdx +1 -1
  30. package/docs/zh/guides/topic-detail/model/manage-effects.mdx +1 -1
  31. package/docs/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
  32. package/docs/zh/guides/topic-detail/model/performance.mdx +1 -1
  33. package/docs/zh/guides/topic-detail/model/quick-start.mdx +1 -1
  34. package/docs/zh/guides/topic-detail/model/use-model.mdx +3 -3
  35. package/package.json +5 -5
  36. package/docs/zh/apis/monorepo/commands/_category_.json +0 -8
  37. package/docs/zh/apis/monorepo/commands/bump.mdx +0 -39
  38. package/docs/zh/apis/monorepo/commands/change.mdx +0 -57
  39. package/docs/zh/apis/monorepo/commands/clear.mdx +0 -24
  40. package/docs/zh/apis/monorepo/commands/gen-release-note.mdx +0 -32
  41. package/docs/zh/apis/monorepo/commands/index.mdx +0 -7
  42. package/docs/zh/apis/monorepo/commands/lint.mdx +0 -18
  43. package/docs/zh/apis/monorepo/commands/new.mdx +0 -39
  44. package/docs/zh/apis/monorepo/commands/pre.mdx +0 -65
  45. package/docs/zh/apis/monorepo/commands/release.mdx +0 -16
  46. package/docs/zh/apis/monorepo/commands/upgrade.mdx +0 -20
  47. package/docs/zh/apis/monorepo/hooks/_category_.json +0 -8
  48. package/docs/zh/apis/monorepo/hooks/apps.mdx +0 -14
  49. package/docs/zh/apis/monorepo/hooks/code-workspace.mdx +0 -11
  50. package/docs/zh/apis/monorepo/hooks/examples.mdx +0 -16
  51. package/docs/zh/apis/monorepo/hooks/features.mdx +0 -16
  52. package/docs/zh/apis/monorepo/hooks/index.mdx +0 -7
  53. package/docs/zh/apis/monorepo/hooks/packages.mdx +0 -16
  54. package/docs/zh/apis/monorepo/hooks/pnpm-workspace.mdx +0 -11
  55. package/docs/zh/apis/monorepo/hooks/pnpmfile.mdx +0 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @modern-js/main-doc
2
2
 
3
+ ## 2.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a83fcd: docs(main-doc): fix wrong links and add missing files
8
+ docs(main-doc): 修复错误的链接,补充缺失的文件
9
+ - @modern-js/builder-doc@2.25.2
10
+
3
11
  ## 2.25.1
4
12
 
5
13
  ### Patch Changes
@@ -71,7 +71,7 @@ modern dev --entry foo,bar
71
71
 
72
72
  ## modern build
73
73
 
74
- The `modern build` command will build a production-ready product in the `dist/` directory by default. You can specify the output directory by modifying the configuration [`output.distPath`](/configure/app/output/dist-path).
74
+ The `modern build` command will build production-ready artifacts in the `dist/` directory by default. You can specify the output directory by modifying the configuration [`output.distPath`](/configure/app/output/dist-path).
75
75
 
76
76
  ```bash
77
77
  Usage: modern build [options]
@@ -96,7 +96,7 @@ File sizes after production build:
96
96
  645 B dist/static/css/main.0dd3ecc1.css
97
97
  ```
98
98
 
99
- Open the above HTML file in the browser, you can see the tile diagram of the packaged product, and perform package volume analysis and optimization:
99
+ Open the above HTML file in the browser, you can see the tile diagram of the bundled files, and perform package volume analysis and optimization:
100
100
 
101
101
  <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/mwa-build-analyze-8784f762c1ab0cb20935829d5f912c4c.png" />
102
102
 
@@ -7,7 +7,7 @@ sidebar_position: 2
7
7
 
8
8
  ## Favicon
9
9
 
10
- When there is a `favicon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.favicon](/configure/app/html/favicon) configuration item for generating the favicon icon on the page:
10
+ When there is a `favicon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.favicon](/configure/app/html/favicon) configuration option for generating the favicon icon on the page:
11
11
 
12
12
  ```
13
13
  ./config
@@ -32,7 +32,7 @@ When setting up the favicon, Modern.js looks for files in the following order:
32
32
 
33
33
  ## Apple Touch Icon
34
34
 
35
- When there is an `icon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.appIcon](/configure/app/html/app-icon) configuration item for generating the Apple Touch Icon icon under the iOS system.
35
+ When there is an `icon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.appIcon](/configure/app/html/app-icon) configuration option for generating the Apple Touch Icon icon under the iOS system.
36
36
 
37
37
  ```
38
38
  ./config
@@ -123,7 +123,7 @@ export const middleware: SomeType = (ctx, next) => {
123
123
  };
124
124
  ```
125
125
 
126
- By default, the framework extension capability of Web Server is turned off after installing the framework extension plug-in. If you want to use the framework extension, you can turn it on through ['server.enableFrameworkExt'](/configure/app/server/enable-framework-ext.html).
126
+ By default, the framework extension capability of Web Server is turned off after installing the framework extension plugin. If you want to use the framework extension, you can turn it on through ['server.enableFrameworkExt'](/configure/app/server/enable-framework-ext.html).
127
127
 
128
128
 
129
129
  :::info
@@ -0,0 +1,40 @@
1
+ ```js title="src/App.tsx"
2
+ import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
3
+
4
+ import { RouterProvider, Route, createBrowserRouter, createRoutesFromElements, BrowserRouter, Link, Outlet } from '@modern-js/runtime/router';
5
+
6
+ const AppLayout = () => (
7
+ <>
8
+ <div><Link to={'/table'}>Loading conventional routed sub-applications</Link></div>
9
+ <div><Link to={'/dashboard'}>Loading Self-Controlled Routing Sub-Applications</Link></div>
10
+ <div><Link to={'/'}>Uninstall a sub-application</Link></div>
11
+ <Outlet />
12
+ </>
13
+ )
14
+
15
+ export default () => {
16
+ const { apps, MApp, Table, Dashboard } = useModuleApps();
17
+
18
+ // If you are not using the MApp component, you need to use createBrowserRouter to create the route.
19
+ const router = createBrowserRouter(
20
+ createRoutesFromElements(
21
+ <Route path="/" element={<AppLayout />}>
22
+ <Route key={'table'} path={'table/*'} element={<Table />} />
23
+ <Route key={'dashboard'} path={'dashboard/*'} element={<Dashboard />} />
24
+ </Route>
25
+ )
26
+ );
27
+
28
+ return (
29
+ // Approach 1: Use MApp to automatically load sub-applications based on the configured activeWhen parameter (this project is configured in modern.config.ts)
30
+ // <BrowserRouter>
31
+ // <MApp />
32
+ // </BrowserRouter>
33
+
34
+ // Approach 2: Manually write Route components to load sub-applications, which is convenient for scenarios that require authentication and other pre-requisite operations
35
+ <>
36
+ <RouterProvider router={router} />
37
+ </>
38
+ );
39
+ };
40
+ ```
@@ -23,7 +23,7 @@ export default defineConfig({
23
23
  });
24
24
  ```
25
25
 
26
- After configuring `output.polyfill` as `ua` and executing `pnpm run build & & pnpm run serve` to start the server, visiting the page can see that the HTML product contains the following script:
26
+ After configuring `output.polyfill` as `ua` and executing `pnpm run build & & pnpm run serve` to start the server, visiting the page can see that the HTML artifacts contains the following script:
27
27
 
28
28
  ```js
29
29
  <script src="/__polyfill__" crossorigin></script>
@@ -24,7 +24,7 @@ export default defineConfig({
24
24
 
25
25
  ### Auto Registration plugin
26
26
 
27
- In addition to means registration, Modern.js also provides a way to automatically register plugins: set the `autoLoadPlugin` configuration item to `true`.
27
+ In addition to means registration, Modern.js also provides a way to automatically register plugins: set the `autoLoadPlugin` configuration option to `true`.
28
28
 
29
29
  ```ts title="modern.config.ts"
30
30
  import { defineConfig } from '@modern-js/app-tools';
@@ -28,13 +28,13 @@ export default defineConfig({
28
28
 
29
29
  Assuming the address of Modern.js BFF server is `localhost:8080`, all requests starting with `api` will be proxied to `https://cnodejs.org`, for example, the request to `localhost:8080/api/v1/topics` will be proxied to `https://cnodejs.org/api/v1/topics`.
30
30
 
31
- import BFFProxyPathRewrite from "@site-docs/components/bff-proxy-path-rewrite";
31
+ import BFFProxyPathRewrite from "@site-docs-en/components/bff-proxy-path-rewrite";
32
32
 
33
33
  <BFFProxyPathRewrite />
34
34
 
35
35
  Unlike [dev.proxy](/configure/app/dev/proxy), the proxy here only applies to requests entering the BFF/API service; at the same time, this configuration can not only be used in the development environment, but also proxies corresponding requests in the production environment.
36
36
 
37
- import BFFProxyPrinciple from "@site-docs/components/bff-proxy-principle";
37
+ import BFFProxyPrinciple from "@site-docs-en/components/bff-proxy-principle";
38
38
 
39
39
  <BFFProxyPrinciple />
40
40
 
@@ -53,7 +53,7 @@ export default defineConfig({
53
53
  });
54
54
  ```
55
55
 
56
- ### Plugin configuration items
56
+ ### Plugin configuration options
57
57
 
58
58
  If the plugin provides some custom configuration options, you can pass in the configuration through the parameters of the plugin function.
59
59
 
@@ -37,4 +37,4 @@ interface AppInfo {
37
37
 
38
38
  In the `masterApp` configuration, developers can pass through options supported by Garfish
39
39
 
40
- All supported configuration items [see here](https://garfishjs.org/api/run/#%E5%8F%82%E6%95%B0).
40
+ All supported configuration options [see here](https://garfishjs.org/api/run/#%E5%8F%82%E6%95%B0).
@@ -9,7 +9,7 @@ sidebar_label: state
9
9
 
10
10
  Once `state` is enabled, you can use [Model](/guides/topic-detail/model/quick-start) for state management.
11
11
 
12
- The specific configuration items are as follows:
12
+ The specific configuration options are as follows:
13
13
 
14
14
  ## models
15
15
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  title: BFF
3
3
  ---
4
+
4
5
  # BFF
5
6
 
6
7
  In the development of the concept of **front back separation**, the front-end part can do more and more things, and the front-end needs some UI-oriented data interfaces, so the industry introduced the concept of BFF (Backends for Frontends).
@@ -16,7 +16,7 @@ When using Modern.js [Conventional routing](/guides/basic-features/routes#conven
16
16
 
17
17
  ## import
18
18
 
19
- use dynamic `import()`, the JS modules pass to this API will be packaged as a separate JS file, for example:
19
+ use dynamic `import()`, the JS modules pass to this API will be bundled as a separate JS file, for example:
20
20
 
21
21
  ```ts
22
22
  import('./math').then(math => {
@@ -92,4 +92,4 @@ Usually it is available and any errors that arise will fixed promptly.
92
92
  However, if there are any break changes that require modern.js to modify the code, we recommend to wait for the next version of modern.js.
93
93
  :::
94
94
 
95
- More examples of using package management tools, please refer to: [Lock nested dependency](/guides/get-started/upgrade.html#lock-nested-dependency).
95
+ More examples of using package managers, please refer to: [Lock nested dependency](/guides/get-started/upgrade.html#lock-nested-dependency).
@@ -251,7 +251,7 @@ if (process.env.MODERN_TARGET === 'browser') {
251
251
  }
252
252
  ```
253
253
 
254
- After the development environment is packaged, the SSR and CSR products will be compiled into the following content. Therefore, there will be no more Web API errors in the SSR environment.
254
+ After the development environment is bundled, the SSR and CSR artifacts will be compiled into the following content. Therefore, there will be no more Web API errors in the SSR environment.
255
255
 
256
256
  ```ts
257
257
  // SSR production
@@ -336,7 +336,7 @@ export default async (): Promise<ProfileData> => {
336
336
  };
337
337
  ```
338
338
 
339
- 4. When running on the server, the `loader` function will be packaged into a unified bundle, so we do not recommend using `__filename` and `__dirname` in server-side code.
339
+ 4. When running on the server, the `loader` function will be bundled into a unified bundle, so we do not recommend using `__filename` and `__dirname` in server-side code.
340
340
 
341
341
  ### FAQ
342
342
 
@@ -19,7 +19,7 @@ A changeset includes:
19
19
  ## Steps
20
20
 
21
21
  :::info
22
- The following example commands are all using pnpm. If you need to use other package management tools, please replace them as needed.
22
+ The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
23
23
  :::
24
24
 
25
25
  ### NPM Module
@@ -9,7 +9,7 @@ Before doing an actual release, we also need to publish a pre-release version fo
9
9
  ## Steps
10
10
 
11
11
  :::info
12
- The following example commands are all using pnpm. If you need to use other package management tools, please replace them as needed.
12
+ The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
13
13
  :::
14
14
 
15
15
  #### Run the bump command to upgrade the version of the pre-release
@@ -9,7 +9,7 @@ When releasing a version, we need to upgrade the version of the corresponding pa
9
9
  ## Steps
10
10
 
11
11
  :::info
12
- The following example commands are all using pnpm. If you need to use other package management tools, please replace them as needed.
12
+ The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
13
13
 
14
14
  :::
15
15
 
@@ -65,9 +65,9 @@ By default, `@modern-js/create` will automatically identify the user's system la
65
65
 
66
66
  Specify the default project configuration.
67
67
 
68
- By default, `@modern-js/create` will prompt for interactive questions such as language selection and package management tools during the execution process. When it is necessary to specify these configuration contents in advance, they can be passed in through this field.
68
+ By default, `@modern-js/create` will prompt for interactive questions such as language selection and package managers during the execution process. When it is necessary to specify these configuration contents in advance, they can be passed in through this field.
69
69
 
70
- This field is a JSON string. For example, when specifying a package management tool:
70
+ This field is a JSON string. For example, when specifying a package manager:
71
71
 
72
72
  ```bash
73
73
  npx @modern-js/create@latest --config '{"packageManager": "pnpm"}'
@@ -122,7 +122,7 @@ npx @modern-js/create@next --dist-tag next
122
122
 
123
123
  Specify specific package version dependencies when creating a project.
124
124
 
125
- If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will configure `pnpm.overrides` (if the package management tool is pnpm) or `resolutions` to lock the package version number in the `package.json` file in the project root directory.
125
+ If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will configure `pnpm.overrides` (if the package manager is pnpm) or `resolutions` to lock the package version number in the `package.json` file in the project root directory.
126
126
 
127
127
  The parameter value is a JSON string.
128
128
 
@@ -46,4 +46,4 @@ Parameters:
46
46
 
47
47
  ### install
48
48
 
49
- Installs dependencies in the root directory of the project. The `install` function will use the corresponding package management tool according to the value of `packageManager` to install dependencies.
49
+ Installs dependencies in the root directory of the project. The `install` function will use the corresponding package manager according to the value of `packageManager` to install dependencies.
@@ -39,7 +39,7 @@ After the project is created, we can enable the `micro frontend` through `pnpm r
39
39
 
40
40
  Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
41
41
 
42
- import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
42
+ import EnableMicroFrontend from "@site-docs-en/components/enable-micro-frontend";
43
43
 
44
44
  <EnableMicroFrontend />
45
45
 
@@ -127,7 +127,7 @@ Since it is a self-controlled route, we delete the `routes/` folder and add the
127
127
 
128
128
  #### Load sub-app
129
129
 
130
- import CustomRouterMicroFrontend from "@site-docs/components/custom-router-micro-frontend";
130
+ import CustomRouterMicroFrontend from "@site-docs-en/components/custom-router-micro-frontend";
131
131
 
132
132
  <CustomRouterMicroFrontend />
133
133
 
@@ -8,7 +8,7 @@ In the previous [Experience micro frontend](/guides/topic-detail/micro-frontend/
8
8
 
9
9
  After creating an application project through the `@modern-js/create` command, you can execute `pnpm run new` in the project (the `modern new` command is actually executed). After selecting the 「micro frontend」 mode, the micro frontend will be installed. Dependencies, just register the plugin manually.
10
10
 
11
- import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
11
+ import EnableMicroFrontend from "@site-docs-en/components/enable-micro-frontend";
12
12
 
13
13
  <EnableMicroFrontend />
14
14
 
@@ -23,10 +23,10 @@ You can register the sub-application information directly through the configurat
23
23
  :::tip
24
24
  It can be configured at runtime via the API [defineConfig](/apis/app/runtime/app/define-config).
25
25
 
26
- When the parameter is a function, it cannot be serialized to the product code, so please configure it through defineConfig when it comes to configuration such as functions
26
+ When the parameter is a function, it cannot be serialized to the output code, so please configure it through defineConfig when it comes to configuration such as functions
27
27
  :::
28
28
 
29
- import MicroRuntimeConfig from "@site-docs/components/micro-runtime-config";
29
+ import MicroRuntimeConfig from "@site-docs-en/components/micro-runtime-config";
30
30
 
31
31
  <MicroRuntimeConfig />
32
32
 
@@ -248,5 +248,5 @@ const handleClick = async () => {
248
248
  ```
249
249
 
250
250
  :::info
251
- [Example](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/effects)
251
+ [Example](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/effects)
252
252
  :::
@@ -100,7 +100,7 @@ The final effect is as follows:
100
100
  ![communicate-models](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/models-communicate.gif)
101
101
 
102
102
  :::info Additional Information
103
- - Full example code for this section can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/models-communication).
103
+ - Full example code for this section can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/models-communication).
104
104
  - For more information about the relevant API, please refer to: [model](/apis/app/runtime/model/model_#function-types).
105
105
 
106
106
  :::
@@ -165,6 +165,6 @@ const barModel = model("bar").define({
165
165
  We created a caching function `createSelector`, which only recalculates the value of `combineA` when the state of `barModel` changes or the state `a` of `fooModel` changes.
166
166
 
167
167
  :::info Additional Information
168
- You can find the complete example code of this section [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/performance-optimization).
168
+ You can find the complete example code of this section [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/performance-optimization).
169
169
  :::
170
170
 
@@ -4,7 +4,7 @@ title: Quick Start
4
4
  ---
5
5
  # Quick Start
6
6
 
7
- import ReduckMigration from "@site-docs/components/reduck-migration"
7
+ import ReduckMigration from "@site-docs-en/components/reduck-migration"
8
8
 
9
9
  <ReduckMigration />
10
10
 
@@ -110,5 +110,5 @@ The final demonstration effect is as follows:
110
110
 
111
111
  ![countModel](https://lf3-static.bytednsdoc.com/obj/eden-cn/eueh7vhojuh/modern/simple-count-model.gif)
112
112
 
113
- That completes a simple counter application. You can view the complete example code for this section [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model).
113
+ That completes a simple counter application. You can view the complete example code for this section [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/counter-model).
114
114
 
@@ -163,7 +163,7 @@ function ThreeComponent() {
163
163
 
164
164
  Using React's refs can also achieve similar effects. In fact, `useStaticModel` also uses refs internally. However, using `useStaticModel` directly helps decouple the state management logic from the component and converge it into the Model layer.
165
165
 
166
- The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/static-model).
166
+ The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/static-model).
167
167
 
168
168
  ### Using as Local State
169
169
 
@@ -194,7 +194,7 @@ Click the `add` button of `Counter` and `LocalCounter` respectively, and the sta
194
194
 
195
195
  ![local-model](https://lf3-static.bytednsdoc.com/obj/eden-cn/eueh7vhojuh/modern/local-model.gif)
196
196
 
197
- The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/local-model).
197
+ The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/local-model).
198
198
 
199
199
  ## Using outside of components
200
200
 
@@ -237,7 +237,7 @@ setInterval(() => {
237
237
  }, 1000);
238
238
  ```
239
239
 
240
- The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model-outof-react).
240
+ The complete sample code can be found [here](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/counter-model-outof-react).
241
241
 
242
242
  :::info
243
243
  If the Store object is manually created through [`createStore`](/apis/app/runtime/model/create-store), there is no need to obtain it through `useStore` in the component, and it can be used directly.
@@ -9,7 +9,7 @@ Usage: modern deploy [options]
9
9
  deploy project
10
10
 
11
11
  Options:
12
- -p, --path [path] Specify the path of the product output (default: "output")
12
+ -p, --path [path] Specify the path of the output files (default: "output")
13
13
  -h, --help display help for command
14
14
  ```
15
15
 
@@ -255,6 +255,6 @@ const handleClick = async () => {
255
255
  ```
256
256
 
257
257
  :::info 补充信息
258
- [示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/effects)
258
+ [示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/effects)
259
259
 
260
260
  :::
@@ -100,7 +100,7 @@ Modern.js 默认开启 [自动生成 actions](./auto-actions.mdx),所以 `step
100
100
  ![communicate-models](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/models-communicate.gif)
101
101
 
102
102
  :::info 补充信息
103
- - 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/models-communication)。
103
+ - 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/models-communication)。
104
104
  - 相关 API 的更多介绍,请参考:[model](/apis/app/runtime/model/model_#函数类型)。
105
105
 
106
106
  :::
@@ -166,6 +166,6 @@ const barModel = model("bar").define({
166
166
  我们创建缓存函数 `createSelector`,仅当 `barModel` 的状态发生改变或 `fooModel` 的 `a` 状态发生改变时,才会重新计算 `combineA` 的值。
167
167
 
168
168
  :::info 补充信息
169
- 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/performance-optimization)
169
+ 本节完整的[示例代码](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/performance-optimization)
170
170
 
171
171
  :::
@@ -110,4 +110,4 @@ function Counter() {
110
110
 
111
111
  ![countModel](https://lf3-static.bytednsdoc.com/obj/eden-cn/eueh7vhojuh/modern/simple-count-model.gif)
112
112
 
113
- 这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model)查看。
113
+ 这样,我们就完了一个简单的计数器应用。本节完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/counter-model)查看。
@@ -164,7 +164,7 @@ function ThreeComponent() {
164
164
 
165
165
  使用 React 的 refs 也可以实现类似效果,其实 `useStaticModel` 内部也使用到了 refs。不过直接 `useStaticModel` 有助于将状态的管理逻辑从组件中解耦,统一收敛到 Model 层。
166
166
 
167
- 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/static-model)查看。
167
+ 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/static-model)查看。
168
168
 
169
169
  ### 作为局部状态使用
170
170
 
@@ -196,7 +196,7 @@ function LocalCounter() {
196
196
 
197
197
  ![local-model](https://lf3-static.bytednsdoc.com/obj/eden-cn/eueh7vhojuh/modern/local-model.gif)
198
198
 
199
- 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/local-model)查看。
199
+ 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/local-model)查看。
200
200
 
201
201
  ## 在组件外使用
202
202
 
@@ -240,7 +240,7 @@ setInterval(() => {
240
240
  }, 1000);
241
241
  ```
242
242
 
243
- 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model-outof-react)查看。
243
+ 完整的示例代码可以在[这里](https://github.com/web-infra-dev/modern-js-examples/tree/main/examples/runtime-api/counter-model-outof-react)查看。
244
244
 
245
245
  :::info
246
246
  如果是通过 [`createStore`](/apis/app/runtime/model/create-store) 手动创建的 Store 对象,无需通过 `useStore` 在组件内获取,即可直接使用。
package/package.json CHANGED
@@ -15,14 +15,14 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.25.1",
18
+ "version": "2.25.2",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "peerDependencies": {
25
- "@modern-js/builder-doc": "^2.25.1"
25
+ "@modern-js/builder-doc": "^2.25.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "classnames": "^2",
@@ -34,9 +34,9 @@
34
34
  "fs-extra": "^10",
35
35
  "@types/node": "^16",
36
36
  "@types/fs-extra": "^9",
37
- "@modern-js/builder-doc": "2.25.1",
38
- "@modern-js/doc-tools": "2.25.1",
39
- "@modern-js/doc-plugin-auto-sidebar": "2.25.1"
37
+ "@modern-js/builder-doc": "2.25.2",
38
+ "@modern-js/doc-plugin-auto-sidebar": "2.25.2",
39
+ "@modern-js/doc-tools": "2.25.2"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "modern dev",
@@ -1,8 +0,0 @@
1
- {
2
- "label": "命令",
3
- "position": 4,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/monorepo/commands/index"
7
- }
8
- }
@@ -1,39 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- ---
4
-
5
- ```bash
6
- Usage: modern bump [options]
7
-
8
- 使用变更集自动更新发布版本和变更日志
9
-
10
- Options:
11
- --canary 创建一个预发布版本进行测试 (default: false)
12
- --preid <tag> 在对预发布版本进行版本控制时指定标识符 (default: "next")
13
- --snapshot 创建一个特殊版本进行测试 (default: false)
14
- -h, --help display help for command
15
- ```
16
-
17
- :::info
18
- `bump` 命令执行之前需要提前执行 [`change`](/apis/monorepo/commands/change) 命令添加 changeset。
19
-
20
- :::
21
-
22
- 按 changeset 记录修改 `package.json` 中的版本号, 同时生成 `CHANGELOG.md`:
23
-
24
- ```bash
25
- npx modern bump
26
- 🦋 All files have been updated. Review them and commit at your leisure
27
- ```
28
-
29
- `CHANGELOG.md` 示例内容如下:
30
-
31
- ```md
32
- # package-a
33
-
34
- ## 0.1.1
35
-
36
- ### Patch Changes
37
-
38
- - test publish
39
- ```
@@ -1,57 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- ---
4
- # change
5
-
6
- ```bash
7
- Usage: modern change [options]
8
-
9
- 创建变更集
10
-
11
- Options:
12
- --empty 创建空变更集 (default: false)
13
- --open 使用编辑器中打开创建的变更集 (default: false)
14
- -h, --help display help for command
15
- ```
16
-
17
- :::info
18
- [`change`](/apis/monorepo/commands/change)、[`pre`](/apis/monorepo/commands/pre)、[`bump`](/apis/monorepo/commands/bump)、[`release`](/apis/monorepo/commands/release) 命令集成了工具 [`changesets`](https://github.com/atlassian/changesets) 管理版本变更和 Changelog。
19
-
20
- :::
21
-
22
- `modern change` 命令添加 changeset:
23
-
24
- ```bash
25
- $ npx modern change
26
- 🦋 Which packages would you like to include? · package-a, package-b
27
- 🦋 Which packages should have a major bump? · No items were selected
28
- 🦋 Which packages should have a minor bump? · No items were selected
29
- 🦋 The following packages will be patch bumped:
30
- 🦋 package-a@0.1.0
31
- 🦋 package-b@0.1.0
32
- 🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
33
- 🦋 Summary · test publish
34
- 🦋 === Releasing the following packages ===
35
- 🦋 [Patch]
36
- 🦋 package-a, package-b
37
- 🦋 ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
38
- 🦋 ║ ========= NOTE ======== ║
39
- 🦋 ║All dependents of these packages that will be incompatible with the new version will be patch bumped when this changeset is applied.║
40
- 🦋 ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
41
- 🦋 Is this your desired changeset? (Y/n) · true
42
- 🦋 Changeset added! - you can now commit it
43
- 🦋
44
- 🦋 If you want to modify or expand on the changeset summary, you can find it here
45
- 🦋 info /xxxx/monorepo/.changeset/long-lizards-talk.md
46
- ```
47
-
48
- 上面我们给 `package-a` 和 `package-b` 都选择了 `patch` 变更,具体的变更信息在 monorepo 根目录下的 `.changeset/long-lizards-talk.md` 中:
49
-
50
- ```md
51
- ---
52
- 'package-a': patch
53
- 'package-b': patch
54
- ---
55
-
56
- test publish
57
- ```
@@ -1,24 +0,0 @@
1
- ---
2
- sidebar_position: 8
3
- ---
4
- # clear
5
-
6
- ```bash
7
- Usage: modern clear [options]
8
-
9
- clear project dirs
10
-
11
- Options:
12
- --remove-dirs [dirs...] remove dirs, default is node_modules
13
- -h, --help display help for command
14
- ```
15
-
16
- 默认对 Monorepo 以及 Monorepo 子项目的 `node_modules` 进行清理。
17
-
18
- 可以通过参数 `--remove-dirs` 来指定要删除的目录,例如执行:
19
-
20
- ```bash
21
- $ npx modern clear --remove-dirs dist
22
- ```
23
-
24
- 则会清理所有 Monorepo 子项目的 `dist` 目录。
@@ -1,32 +0,0 @@
1
- ---
2
- sidebar_position: 9
3
- ---
4
- # gen-release-note
5
-
6
- ```bash
7
- Usage: modern gen-release-note [options]
8
-
9
- 根据当前仓库 changeset 文件生成 Release Note
10
-
11
- Options:
12
- --repo <repo> 仓库名称,用于生成 Pull Request 链接, 例如: web-infra-dev/modern.js
13
- --custom <cumtom> 自定义 Release Note 生成函数
14
- -h, --help display help for command
15
- ```
16
-
17
- 根据当前仓库的 changeset 信息自动生成 Release Note。
18
-
19
- :::warning 注意
20
- 需要在 bump 命令之前执行。
21
-
22
- :::
23
-
24
- ```markdown
25
- ## Features:
26
-
27
- [[#1160](https://github.com/web-infra-dev/modern.js/pull/1160)] export ExecaError type
28
-
29
- ## Bug Fix:
30
-
31
- [[#1264](https://github.com/web-infra-dev/modern.js/pull/1264)] fix: conventional router app use App.init not work
32
- ```
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # 命令
6
-
7
- 本节涵盖了使用 Monorepo 工程的所有命令。
@@ -1,18 +0,0 @@
1
- ---
2
- sidebar_position: 6
3
- ---
4
- # lint
5
-
6
- ```bash
7
- Usage: modern lint [options] [...files]
8
-
9
- lint and fix source files
10
-
11
- Options:
12
- --no-fix disable auto fix source file
13
- -h, --help display help for command
14
- ```
15
-
16
- 运行 `ESLint` 检查 monorepo 中代码语法情况, 通长情况下,我们只需要在 `git commit` 阶段通过 `lint-staged` 检查本次提交修改的部分代码。
17
-
18
- - `--no-fix` 参数设置后可以关闭自动修复 lint 错误代码的能力。
@@ -1,39 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
- # new
5
-
6
- ```bash
7
- Usage: modern new [options]
8
-
9
- Monorepo 创建子项目
10
-
11
- Options:
12
- -d, --debug 开启 Debug 模式,打印调试日志信息 (default: false)
13
- -c, --config <config> 生成器运行默认配置(JSON 字符串)
14
- --dist-tag <tag> 生成器使用特殊的 npm Tag 版本
15
- --registry 生成器运行过程中定制 npm Registry
16
- -h, --help display help for command
17
- ```
18
-
19
- `modern new` 命令在 monorepo 中可以用来添加应用工程和可复用的模块:
20
-
21
- ```bash
22
- $ modern new
23
- ? 请选择你想创建的工程类型 (Use arrow keys)
24
- ❯ Web 应用
25
- Web 应用(测试)
26
- Npm 模块
27
- Npm 模块(内部)
28
- ```
29
-
30
- 应用工程默认会添加到 `apps` 目录, 测试应用会添加到 `examples` 目录,公共模块默认会添加到 `packages` 目录, 内部模块默认会添加到 `features` 目录。
31
-
32
- 内部模块在 monorepo 的应用里面使用时,可以无需构建直接使用源码。
33
-
34
- :::caution 注意
35
- `--config` 参数对应参数值需要使用 JSON 字符串。
36
-
37
- pnpm 暂不支持使用 JSON 字符串作为参数值,可使用 `npm new` 开启相关功能。【[相关 Issue](https://github.com/pnpm/pnpm/issues/3876)】
38
-
39
- :::
@@ -1,65 +0,0 @@
1
- ---
2
- sidebar_position: 3
3
- ---
4
- # pre
5
-
6
- ```bash
7
- Usage: modern pre [options] <enter|exit> [tag]
8
-
9
- 进入和退出预发布模式
10
-
11
- Options:
12
- -h, --help display help for command
13
- ```
14
-
15
- 可以使用 `modern pre` 命令在正式发布前[预发布](https://github.com/atlassian/changesets/blob/main/docs/prereleases.md)一个版本。
16
-
17
- 首先 `modern pre enter <tag>` 进入预发布模式:
18
-
19
- ```bash
20
- $ npx modern pre enter next
21
- 🦋 success Entered pre mode with tag next
22
- 🦋 info Run `changeset version` to version packages with prerelease versions
23
- ```
24
-
25
- 之后通过 `modern change` 命令添加 changeset:
26
-
27
- ```bash
28
- $ npx modern change
29
- 🦋 Which packages would you like to include? · package-a, package-b
30
- 🦋 Which packages should have a major bump? · No items were selected
31
- 🦋 Which packages should have a minor bump? · No items were selected
32
- 🦋 The following packages will be patch bumped:
33
- 🦋 package-a@0.1.1
34
- 🦋 package-b@0.1.1
35
- 🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
36
- 🦋 Summary · test pre publish
37
- 🦋 === Releasing the following packages ===
38
- 🦋 [Patch]
39
- 🦋 package-a, package-b
40
- 🦋 ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
41
- 🦋 ║ ========= NOTE ======== ║
42
- 🦋 ║All dependents of these packages that will be incompatible with the new version will be patch bumped when this changeset is applied.║
43
- 🦋 ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
44
- 🦋 Is this your desired changeset? (Y/n) · true
45
- 🦋 Changeset added! - you can now commit it
46
- 🦋
47
- 🦋 If you want to modify or expand on the changeset summary, you can find it here
48
- 🦋 info /xxxxxx/monorepo/.changeset/beige-paws-rule.md
49
- ```
50
-
51
- 接着可以使用 `modern bump` 命令更新具体的版本号:
52
-
53
- ```bash
54
- $ npx modern bump
55
- 🦋 warn ===============================IMPORTANT!===============================
56
- 🦋 warn You are in prerelease mode
57
- 🦋 warn If you meant to do a normal release you should revert these changes and run `changeset pre exit`
58
- 🦋 warn You can then run `changeset version` again to do a normal release
59
- 🦋 warn ----------------------------------------------------------------------
60
- 🦋 All files have been updated. Review them and commit at your leisure
61
- ```
62
-
63
- 可以看到 `package-a` 和 `package-b` 的 `package.json` 中版本号均已更新到 `0.1.2-next.0`。
64
-
65
- 提交完变更之后,我们可以通过 `modern pre exit` 命令退出预发布模式。
@@ -1,16 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
- # release
5
-
6
- ```bash
7
- Usage: modern release [options]
8
-
9
- publish changes to npm
10
-
11
- Options:
12
- --tag <tag> publish use special tag (default: "")
13
- -h, --help display help for command
14
- ```
15
-
16
- 发布当前仓库的 Packages 至 NPM。
@@ -1,20 +0,0 @@
1
- ---
2
- sidebar_position: 11
3
- ---
4
- # upgrade
5
-
6
- ```
7
- Usage: modern upgrade [options]
8
-
9
- 升级 Modern.js 到最新版本
10
-
11
- Options:
12
- --registry <registry> 定制 npm registry (default: "")
13
- -d,--debug 开启 Debug 模式,打印调试日志信息 (default: false)
14
- --cwd <cwd> 项目路径 (default: "")
15
- -h, --help display help for command
16
- ```
17
-
18
- `modern upgrade` 命令,用于升级项目 Modern.js 相关依赖至最新版本。
19
-
20
- 在项目根目录下执行命令 `npx modern upgrade`,会默认将当前执行命令项目的 `package.json` 中的 Modern.js 相关依赖更新至最新版本。
@@ -1,8 +0,0 @@
1
- {
2
- "label": "文件约定",
3
- "position": 3,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/monorepo/hooks/index"
7
- }
8
- }
@@ -1,14 +0,0 @@
1
- ---
2
- title: apps/*
3
- sidebar_position: 1
4
- ---
5
- # apps/*
6
-
7
- Monorepo 工程方案应用类型项目目录。
8
-
9
- Modern.js Monorepo 工程方案约定将应用类型子项目放置在 `apps` 目录下进行统一管理,`apps` 目录下每一个文件夹都是一个完整的应用项目。
10
-
11
- :::info
12
- 可直接在项目下执行 new 命令创建应用类型子项目。
13
-
14
- :::
@@ -1,11 +0,0 @@
1
- ---
2
- title: monorepo.code-workspace
3
- sidebar_position: 7
4
- ---
5
- # monorepo.code-workspace
6
-
7
- Monorepo 工程方案 VS Code 配置文件。
8
-
9
- Monorepo 工程方案支持 VS Code Workspace 配置,可以通过该配置文件打开的一个或多个文件夹的集合。
10
-
11
- VS Code workspace 协议详情可查看: [VS Code Workspace](https://code.visualstudio.com/docs/editor/workspaces)
@@ -1,16 +0,0 @@
1
- ---
2
- title: examples/*
3
- sidebar_position: 2
4
- ---
5
- # examples/*
6
-
7
- Monorepo 工程方案测试应用类型项目目录。
8
-
9
- Modern.js Monorepo 工程方案约定将测试的应用类型子项目放置在 `examples` 目录下进行统一管理,`examples` 目录下每一个文件夹都是一个完整的应用项目。
10
-
11
- 测试类型的应用项目不包含部署相关的 scripts 命令,用于开发过程中进行测试项目、测试案例的编写。
12
-
13
- :::info
14
- 可直接在项目下执行 new 命令创建测试应用类型子项目。
15
-
16
- :::
@@ -1,16 +0,0 @@
1
- ---
2
- title: features/
3
- sidebar_position: 3
4
- ---
5
- # features/
6
-
7
- Monorepo 工程方案内部模块类型项目目录。
8
-
9
- Modern.js Monorepo 工程方案约定将内部模块类型子项目放置在 `features` 目录下进行统一管理,`features` 目录下每一个文件夹都是一个完整的模块项目。
10
-
11
- 内部模块项目用于一些不需要编译的公共的组件和工具的编写,这类型的项目不包含编译、发布命令,在应用类型项目中引用时,应用类型项目会默认对其进行编译。
12
-
13
- :::info
14
- 可直接在项目下执行 new 命令内部模块类型子项目。
15
-
16
- :::
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # 命令
6
-
7
- 本节涵盖了使用 Monorepo 工程所有的文件约定
@@ -1,16 +0,0 @@
1
- ---
2
- title: packages/
3
- sidebar_position: 4
4
- ---
5
- # packages/
6
-
7
- Monorepo 工程方案公共模块类型项目目录。
8
-
9
- Modern.js Monorepo 工程方案约定将公共模块类型子项目放置在 `packages` 目录下进行统一管理,`packages` 目录下每一个文件夹都是一个完整的模块项目。
10
-
11
- 公共模块项目用户一些公共的组件和工具的编写,这些公共包可自行进行编译和发布,也可在应用类型项目中引用。
12
-
13
- :::info
14
- 可直接在项目下执行 new 命令创建模块类型子项目。
15
-
16
- :::
@@ -1,11 +0,0 @@
1
- ---
2
- title: pnpm-workspace.yaml
3
- sidebar_position: 5
4
- ---
5
- # pnpm-workspace.yaml
6
-
7
- Monorepo 工程方案 pnpm workspace 配置文件。
8
-
9
- Monorepo 工程方案支持使用 pnpm 作为包管理工具对项目进行管理,支持 pnpm 的 workspace 协议。
10
-
11
- pnpm workspace 配置详情可查看: [pnpm workspace](https://pnpm.io/workspaces)
@@ -1,11 +0,0 @@
1
- ---
2
- title: .pnpmfile.cjs
3
- sidebar_position: 6
4
- ---
5
- # .pnpmfile.cjs
6
-
7
- Monorepo 工程方案 pnpm 钩子文件。
8
-
9
- Monorepo 工程方案支持使用 pnpm 作为包管理工具对项目进行管理,支持使用 pnpm 的钩子文件对安装过程进行自定义。
10
-
11
- pnpm .pnpmfile.cjs 使用详情可查看: [pnpmfile](https://pnpm.io/pnpmfile)