@modern-js/main-doc 2.11.0 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/docs/en/apis/app/commands.mdx +1 -1
  3. package/docs/en/apis/app/hooks/api/framework/lambda.mdx +2 -2
  4. package/docs/en/apis/app/hooks/api/functions/api.mdx +3 -3
  5. package/docs/en/apis/app/hooks/api/functions/app.mdx +1 -1
  6. package/docs/en/apis/app/hooks/api/test.mdx +2 -1
  7. package/docs/en/apis/app/hooks/config/icon.mdx +46 -6
  8. package/docs/en/apis/app/hooks/config/mock.mdx +1 -1
  9. package/docs/en/apis/app/hooks/config/upload.mdx +1 -1
  10. package/docs/en/apis/app/hooks/server/test.mdx +1 -1
  11. package/docs/en/apis/app/hooks/src/app.mdx +1 -1
  12. package/docs/en/apis/app/hooks/src/pages.mdx +1 -1
  13. package/docs/en/apis/app/runtime/app/define-config.mdx +1 -1
  14. package/docs/en/apis/app/runtime/core/bootstrap.mdx +2 -2
  15. package/docs/en/apis/app/runtime/core/use-loader.mdx +6 -2
  16. package/docs/en/apis/app/runtime/model/auto-actions.mdx +6 -6
  17. package/docs/en/apis/app/runtime/model/connect.mdx +2 -1
  18. package/docs/en/apis/app/runtime/model/create-app.mdx +1 -1
  19. package/docs/en/apis/app/runtime/model/handle-effect.mdx +3 -3
  20. package/docs/en/apis/app/runtime/model/model_.mdx +2 -2
  21. package/docs/en/apis/app/runtime/model/use-model.mdx +2 -2
  22. package/docs/en/apis/app/runtime/model/use-static-model.mdx +2 -2
  23. package/docs/en/apis/app/runtime/model/use-store.mdx +1 -1
  24. package/docs/en/apis/app/runtime/router/router.mdx +1 -0
  25. package/docs/en/apis/app/runtime/ssr/pre-render.mdx +2 -2
  26. package/docs/en/apis/app/runtime/testing/render.mdx +1 -1
  27. package/docs/en/components/enable-bff.mdx +2 -2
  28. package/docs/en/configure/app/html/script-loading.mdx +13 -0
  29. package/docs/en/configure/app/output/ssg.mdx +1 -1
  30. package/docs/en/configure/app/plugins.mdx +3 -3
  31. package/docs/en/configure/app/source/disable-entry-dirs.mdx +1 -1
  32. package/docs/en/configure/app/tools/bundler-chain.mdx +13 -0
  33. package/docs/en/configure/app/tools/swc.mdx +4 -3
  34. package/docs/en/configure/app/usage.mdx +65 -23
  35. package/docs/en/guides/advanced-features/bff/function.mdx +3 -3
  36. package/docs/en/guides/advanced-features/code-split.mdx +2 -2
  37. package/docs/en/guides/advanced-features/eslint.mdx +1 -1
  38. package/docs/en/guides/advanced-features/ssg.mdx +2 -2
  39. package/docs/en/guides/advanced-features/ssr.mdx +45 -8
  40. package/docs/en/guides/basic-features/alias.mdx +1 -1
  41. package/docs/en/guides/basic-features/data-fetch.mdx +1 -1
  42. package/docs/en/guides/basic-features/env-vars.mdx +5 -5
  43. package/docs/en/guides/basic-features/html.mdx +0 -4
  44. package/docs/en/guides/basic-features/routes.mdx +48 -28
  45. package/docs/en/guides/concept/entries.mdx +3 -3
  46. package/docs/en/guides/get-started/introduction.mdx +21 -1
  47. package/docs/en/guides/get-started/quick-start.mdx +6 -23
  48. package/docs/en/guides/get-started/upgrade.mdx +7 -7
  49. package/docs/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  50. package/docs/en/guides/topic-detail/generator/codesmith/api/json.mdx +3 -3
  51. package/docs/en/guides/topic-detail/generator/config/app.mdx +1 -1
  52. package/docs/en/guides/topic-detail/generator/config/monorepo.mdx +1 -1
  53. package/docs/en/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +1 -1
  54. package/docs/en/guides/topic-detail/model/manage-effects.mdx +2 -1
  55. package/docs/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  56. package/docs/en/guides/topic-detail/model/use-model.mdx +2 -1
  57. package/docs/en/guides/troubleshooting/builder.mdx +31 -0
  58. package/docs/en/tutorials/foundations/introduction.mdx +0 -2
  59. package/docs/zh/apis/app/hooks/config/icon.mdx +44 -6
  60. package/docs/zh/apis/app/hooks/src/pages.mdx +1 -1
  61. package/docs/zh/apis/app/runtime/core/use-loader.mdx +4 -0
  62. package/docs/zh/apis/app/runtime/model/handle-effect.mdx +2 -1
  63. package/docs/zh/apis/app/runtime/model/model_.mdx +4 -2
  64. package/docs/zh/blog/updates/2022-0708-updates.md +1 -2
  65. package/docs/zh/components/enable-bff.mdx +2 -2
  66. package/docs/zh/configure/app/html/script-loading.mdx +13 -0
  67. package/docs/zh/configure/app/runtime/router.mdx +1 -1
  68. package/docs/zh/configure/app/source/disable-entry-dirs.mdx +2 -2
  69. package/docs/zh/configure/app/tools/bundler-chain.mdx +13 -0
  70. package/docs/zh/configure/app/tools/swc.mdx +4 -3
  71. package/docs/zh/configure/app/usage.mdx +66 -24
  72. package/docs/zh/guides/advanced-features/ssr.mdx +74 -36
  73. package/docs/zh/guides/basic-features/data-fetch.mdx +1 -1
  74. package/docs/zh/guides/basic-features/html.mdx +0 -4
  75. package/docs/zh/guides/basic-features/routes.mdx +64 -24
  76. package/docs/zh/guides/concept/entries.mdx +4 -4
  77. package/docs/zh/guides/get-started/introduction.mdx +21 -1
  78. package/docs/zh/guides/get-started/upgrade.mdx +3 -3
  79. package/docs/zh/guides/topic-detail/changesets/release.mdx +2 -2
  80. package/docs/zh/guides/topic-detail/model/use-model.mdx +2 -1
  81. package/docs/zh/guides/troubleshooting/builder.mdx +31 -0
  82. package/modern.config.ts +3 -2
  83. package/package.json +5 -5
  84. package/src/components/SolutionCards/index.module.scss +62 -0
  85. package/src/components/SolutionCards/index.tsx +26 -0
  86. package/docs/en/configure/app/source/plugin-import.mdx +0 -13
  87. package/docs/zh/configure/app/source/plugin-import.mdx +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @modern-js/main-doc
2
2
 
3
+ ## 2.13.0
4
+
5
+ ### Patch Changes
6
+
7
+ - e91ec97: feat(app-tools): export mergeConfig function
8
+
9
+ feat(app-tools): 导出 mergeConfig 函数
10
+
11
+ - 42700c1: chore: improve ssr docs, add more use case for node/web code split
12
+ chore: 优化 ssr 文档,为 node/web 代码分割添加更多使用场景
13
+ - Updated dependencies [1feacdc]
14
+ - Updated dependencies [348306d]
15
+ - Updated dependencies [42700c1]
16
+ - @modern-js/builder-doc@2.13.0
17
+
18
+ ## 2.12.0
19
+
20
+ ### Patch Changes
21
+
22
+ - 9e5044d: doc: 修正文档中使用@edenx/runtime 的部分
23
+ doc: Correct the sections in the document that use @edenx/runtime.
24
+ - 9328fb9: feat: prebundle theme
25
+
26
+ feat: 预打包主题
27
+
28
+ - @modern-js/builder-doc@2.12.0
29
+
3
30
  ## 2.11.0
4
31
 
5
32
  ### Patch Changes
@@ -84,7 +84,7 @@ Options:
84
84
 
85
85
  ### Analyze Bundle
86
86
 
87
- execute `npx modern build --analyze` commandcan produce an HTML file that analyzes the volume of the bundle while packaging the production code:
87
+ execute `npx modern build --analyze` command, can produce an HTML file that analyzes the volume of the bundle while packaging the production code:
88
88
 
89
89
  ```
90
90
  Bundle Analyzer saved report to /example/dist/report.html
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
  ---
5
5
  # lambda/*.[tj]s
6
6
 
7
- Declaring API routing in BFF framework mode. Except [some files](/apis/app/hooks/api/framework/lambda#allow-list)files in `api/` are registered as routes.
7
+ Declaring API routing in BFF framework mode. Except [some files](/apis/app/hooks/api/framework/lambda#allow-list), files in `api/` are registered as routes.
8
8
 
9
9
  :::info
10
10
  use `api/` need execute new command to enable the 「BFF」 feature.
@@ -40,7 +40,7 @@ Dynamic named routing parameters can be supported by creating folders or files w
40
40
  - `api/lambda/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
41
41
  - `api/lambda/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
42
42
 
43
- the `$BASENAME` can be configured in `modern.config.js`,the default value is `/api`.
43
+ the `$BASENAME` can be configured in `modern.config.js`, the default value is `/api`.
44
44
 
45
45
  ### Allow List
46
46
 
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
  ---
5
5
  # **/*.[tj]s
6
6
 
7
- Declaring API routing in BFF function mode. Except [some files](/apis/app/hooks/api/functions/api#allow-list)files in `api/` are registered as routes.
7
+ Declaring API routing in BFF function mode. Except [some files](/apis/app/hooks/api/functions/api#allow-list), files in `api/` are registered as routes.
8
8
 
9
9
  :::info
10
10
  use `api/` need execute new command to enable the 「BFF」 feature.
@@ -40,7 +40,7 @@ Dynamic named routing parameters can be supported by creating folders or files w
40
40
  - `api/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
41
41
  - `api/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
42
42
 
43
- the `$BASENAME` can be configured in `modern.config.js`,the default value is `/api`.
43
+ the `$BASENAME` can be configured in `modern.config.js`, the default value is `/api`.
44
44
 
45
45
  ### Allow List
46
46
 
@@ -56,7 +56,7 @@ By default, all files in the `api/` will be parsed as BFF function. but we also
56
56
 
57
57
  In addition to the above routing rules, the function definition and export in the code also have conventions.
58
58
 
59
- function need named exportsand the name of the exported function is the HTTP Method:
59
+ function need named exports, and the name of the exported function is the HTTP Method:
60
60
 
61
61
  ```ts
62
62
  export const get = async () => {
@@ -4,7 +4,7 @@ sidebar_position: 3
4
4
  ---
5
5
  # _app.[tj]s
6
6
 
7
- in BFF function modethis file can add middleware before [BFF 函数](/apis/app/hooks/api/functions/api).
7
+ in BFF function mode, this file can add middleware before [BFF 函数](/apis/app/hooks/api/functions/api).
8
8
 
9
9
  :::note
10
10
  For detail, see [hook](/apis/app/runtime/bff/hook)
@@ -2,9 +2,10 @@
2
2
  title: test.[tj]s
3
3
  sidebar_position: 2
4
4
  ---
5
+
5
6
  # test.[tj]s
6
7
 
7
- App's BFF test filesupport for writing test cases in the `api/` directory which file with suffix `.test.[tj]s`.
8
+ App's BFF test file, support for writing test cases in the `api/` directory which file with suffix `.test.[tj]s`.
8
9
 
9
10
  :::info
10
11
  To use unit test and integration test, you need to execute the `new` command in advance to enable the `unit test/integration test`.
@@ -1,16 +1,56 @@
1
1
  ---
2
- title: icon.png
2
+ title: icon
3
3
  sidebar_position: 2
4
4
  ---
5
- # icon.png
6
5
 
7
- When `config/icon.png` exist, it can inject app icon information into the html page at build time:
6
+ # Icon
8
7
 
8
+ ## Set favicon
9
+
10
+ When there is a `favicon.*` file in the `config` directory of the project root directory, Modern.js will automatically set the file to the [html.favicon](/configure/app/html/favicon) config to generate the favicon icon for the page:
11
+
12
+ ```
13
+ ./config
14
+ └── favicon.ico
9
15
  ```
10
- .config
16
+
17
+ After the build is complete, you can see that the following tags are automatically generated in the HTML:
18
+
19
+ ```html
20
+ <link rel="icon" href="/favicon.ico" />
21
+ ```
22
+
23
+ ### Order
24
+
25
+ When setting up the favicon, Modern.js looks for files in the following order:
26
+
27
+ - favicon.png
28
+ - favicon.jpg
29
+ - favicon.jpeg
30
+ - favicon.svg
31
+ - favicon.ico
32
+
33
+ ## Set app icon
34
+
35
+ When there is an `icon.*` file in the `config` directory of the project root directory, Modern.js will automatically set the file to the [html.appIcon](/configure/app/html/app-icon) config, it is used to generate the apple-touch-icon icon for the iOS system.
36
+
37
+ ```
38
+ ./config
11
39
  └── icon.png
12
40
  ```
13
41
 
14
- the app icon `link` meta will be injected into the html, as follows:
42
+ After the build is complete, you can see that the following tags are automatically generated in the HTML:
43
+
44
+ ```html
45
+ <link rel="apple-touch-icon" sizes="180*180" href="/static/image/icon.png" />
46
+ ```
47
+
48
+ ### Order
49
+
50
+ When setting the app icon, Modern.js looks for files in the following order:
15
51
 
16
- ![app-icon](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/api/app-icon.png)
52
+ - icon.png
53
+ - icon.jpg
54
+ - icon.jpeg
55
+ - icon.svg
56
+ - icon.ico
@@ -4,4 +4,4 @@ sidebar_position: 5
4
4
  ---
5
5
  # mock/
6
6
 
7
- when `config/mock/index.js` existModernjs auto start the Mock service in the development.
7
+ when `config/mock/index.js` exist, Modernjs auto start the Mock service in the development.
@@ -42,7 +42,7 @@ Whether in [custom HTML](/guides/basic-features/html), or in any HTML file under
42
42
  <script src="/upload/index.js"></script>
43
43
  ```
44
44
 
45
- if [`output.assetPrefix`](/configure/app/output/asset-prefix) is configuredadd this prefix directly using template syntax:
45
+ if [`output.assetPrefix`](/configure/app/output/asset-prefix) is configured, add this prefix directly using template syntax:
46
46
 
47
47
  ```html
48
48
  <script src="<%=assetPrefix %>/upload/index.js"></script>
@@ -4,7 +4,7 @@ sidebar_position: 2
4
4
  ---
5
5
  # test.[tj]s
6
6
 
7
- App's Web Server test filesupport for writing test cases in the `server/` directory which file with suffix `.test.[tj]s`.
7
+ App's Web Server test file, support for writing test cases in the `server/` directory which file with suffix `.test.[tj]s`.
8
8
 
9
9
  :::info
10
10
  To use unit test and integration test, you need to execute the `new` command in advance to enable the `unit test/integration test`.
@@ -49,6 +49,6 @@ export default AppWrapper;
49
49
  ```
50
50
 
51
51
  :::note
52
- In multi-entry Appeach entry can have a `App.[jt]sx`, for detail, see [Entry](/guides/concept/entries).
52
+ In multi-entry App, each entry can have a `App.[jt]sx`, for detail, see [Entry](/guides/concept/entries).
53
53
 
54
54
  :::
@@ -84,7 +84,7 @@ When the entire App needs a global `layout`, it can be achieved through `pages/_
84
84
  import React from 'react';
85
85
  import UserLayout from 'xxxx';
86
86
 
87
- export default const App = ({Component, ...pageProps}:{ Component: React.ComponentType}) => {
87
+ export const App = ({Component, ...pageProps}:{ Component: React.ComponentType}) => {
88
88
  return (
89
89
  <UserLayout>
90
90
  <Component {...pageProps} />
@@ -13,7 +13,7 @@ import { defineConfig } from '@modern-js/runtime';
13
13
 
14
14
  Runtime configurations can usually be configured under the `runtime` of the `modern.config.js`, such as the [router](/configure/app/runtime/router) configuration.
15
15
 
16
- The configuration in `modern.config.js` is determined at build timeIf some configuration parameters are obtained at runtime, or if the configuration parameters are from a module (such as a component), then need use `defineConfig` API configuration on runtime.
16
+ The configuration in `modern.config.js` is determined at build time, If some configuration parameters are obtained at runtime, or if the configuration parameters are from a module (such as a component), then need use `defineConfig` API configuration on runtime.
17
17
 
18
18
  :::info
19
19
  `@modern-js/app-tools` has the same name API, Used to provide **TS type for configuration**, please distinguish them.
@@ -33,7 +33,7 @@ type BootStrap<T = unknown> = (
33
33
  ### Input
34
34
 
35
35
  - `AppComponent`: reactElement instance created by [`createApp`](./create-app).
36
- - `rootId`: DOM root element id to mountlike `"root"`.
36
+ - `rootId`: DOM root element id to mount, like `"root"`.
37
37
  - `root`: ReactDOM.create the return value, which is used in the scenario where the root needs to destroy the component outside the bootstrap function.
38
38
  - `ReactDOM`: ReactDOM object for distinguishing between React 18 and React 17 APIs.
39
39
 
@@ -56,7 +56,7 @@ bootstrap(WrappedApp, 'root', undefined, ReactDOM);
56
56
  ```
57
57
 
58
58
  :::info
59
- since `@modern-js/runtime/plugins` is a aliaswhen used in a ts project, its type needs to be declaredJust add the following type declarations to `src/modern-app-env.d.ts`:
59
+ since `@modern-js/runtime/plugins` is a alias, when used in a ts project, its type needs to be declared, Just add the following type declarations to `src/modern-app-env.d.ts`:
60
60
 
61
61
  ```ts
62
62
  declare module '@modern-js/runtime/plugins';
@@ -3,7 +3,11 @@ title: useLoader
3
3
  ---
4
4
  # useLoader
5
5
 
6
- Isomorphic APIusually used to make asynchronous requests. When SSR, the server level uses `useLoader` to prefetch the data, and the browser side also reuses this part of the data.
6
+ Isomorphic API, usually used to make asynchronous requests. When SSR, the server level uses `useLoader` to prefetch the data, and the browser side also reuses this part of the data.
7
+
8
+ :::tip
9
+ When using Rspack as the bundler, the useLoader API is not currently supported.
10
+ :::
7
11
 
8
12
  ## Usage
9
13
 
@@ -47,7 +51,7 @@ function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
47
51
  - `onError`: error callback.
48
52
  - `initialData`: the initial data before the first execution,.
49
53
  - `skip`: when the value is `true`, the function does not execute.
50
- - `params`: when the result of the `params` serialization changesthe function is re-executed. `params` is also passed in as the second argument of the function.
54
+ - `params`: when the result of the `params` serialization changes, the function is re-executed. `params` is also passed in as the second argument of the function.
51
55
  - `static`: when the value is `true`, `useLoader` is used for [SSG](/guides/advanced-features/ssg).
52
56
 
53
57
  ### Return Value
@@ -8,7 +8,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
8
8
 
9
9
  <ReduckTip />
10
10
 
11
- Reduck can automatically generate Actions according to the type of Statefor easy to modify State.
11
+ Reduck can automatically generate Actions according to the type of State, for easy to modify State.
12
12
 
13
13
  :::tip
14
14
  can use [`runtime.state.autoActions`](/configure/app/runtime/state#autoactions) close auto actions feature.
@@ -19,7 +19,7 @@ can use [`runtime.state.autoActions`](/configure/app/runtime/state#autoactions)
19
19
 
20
20
  ### Basic Data Type
21
21
 
22
- State type in `string`、`number`、`boolean`、`null`,generate `setState` Action.
22
+ State type in `string`、`number`、`boolean`、`null`, generate `setState` Action.
23
23
 
24
24
  ```tsx title="example"
25
25
  const fooModel = model('foo').define({
@@ -48,7 +48,7 @@ function App() {
48
48
 
49
49
  ### Array
50
50
 
51
- State type is Arraygenerate the following Actions:
51
+ State type is Array, generate the following Actions:
52
52
 
53
53
  - `push`: adds one or more elements to the end of the array.
54
54
  - `pop`: removes the last element from the array.
@@ -57,9 +57,9 @@ State type is Array,generate the following Actions:
57
57
  - usage: `arr.unshift(element1, ..., elementN)`
58
58
  - `elementN`: the element or elements to add to the beginning of the array.
59
59
  - `filter`: filter element.
60
- {/* 语义与原生方法不同,待修改 API */}
60
+ {/* 语义与原生方法不同, 待修改 API */}
61
61
  - `concat`: concat array.
62
- {/* 语义与原生方法不同,待修改 API */}
62
+ {/* 语义与原生方法不同, 待修改 API */}
63
63
  - `splice`: modify the array by deleting or replacing existing elements or adding new elements in place, and return the modified array(Note that it is different from the native `splice` return value).
64
64
  - usage: `splice(start[, deleteCount[, item1[, item2[, ...]]]])`
65
65
  - `start`: specifies the start position of the modification(counting from 0).
@@ -93,7 +93,7 @@ function App() {
93
93
 
94
94
  ### PlainObject
95
95
 
96
- State type is PlainObjectbase on the names contained in Stategenerate `set${key}`(Camel-Case) Actions.
96
+ State type is PlainObject, base on the names contained in State, generate `set${key}`(Camel-Case) Actions.
97
97
 
98
98
  ```tsx title="example"
99
99
  const fooModel = model('foo').define({
@@ -2,9 +2,10 @@
2
2
  sidebar_position: 5
3
3
  title: connect
4
4
  ---
5
+
5
6
  # connect
6
7
 
7
- import ReduckTip from "@site-docs-en/components/reduck-tip"
8
+ import ReduckTip from '@site-docs-en/components/reduck-tip';
8
9
 
9
10
  <ReduckTip />
10
11
 
@@ -30,7 +30,7 @@ function createApp(config: AppConfig): object;
30
30
 
31
31
  - `config`
32
32
  - `StoreConfig`: the same as [`createStore`](./create-store.mdx) params.
33
- - `devTools`: the default value is `true`. when it is an object typeconfiguring [Options](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md) of Redux DevTools.
33
+ - `devTools`: the default value is `true`. when it is an object type, configuring [Options](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md) of Redux DevTools.
34
34
  - `autoActions`: the default value is `true`.if [auto generate Actions](./auto-actions.mdx).
35
35
 
36
36
  ### Return Value
@@ -65,7 +65,7 @@ interface State {
65
65
  }
66
66
  ```
67
67
 
68
- if `result` is `false`,then returned State has no `result`:
68
+ if `result` is `false`, then returned State has no `result`:
69
69
 
70
70
  ```ts
71
71
  interface State {
@@ -80,13 +80,13 @@ interface State {
80
80
 
81
81
  - `combineMode`: the default value is `"merge"`. Get fulfilled state results. There are two ways to deal with it (The data types that can be automatically processed here are also limited to simple object or array types):
82
82
 
83
- - `"merge"`: the previous data is merged with the current data. the data is an array type, operation is similar to `[].concat(lastData, currentData)`. the data is an objectoperation is similar to `{...lastData, ...curData}`.
83
+ - `"merge"`: the previous data is merged with the current data. the data is an array type, operation is similar to `[].concat(lastData, currentData)`. the data is an object, operation is similar to `{...lastData, ...curData}`.
84
84
  - `"replace"`: the current data directly replaces the previous data.
85
85
 
86
86
  - `omitResultNamespace`: the default value is `false`. When the result is an object type, you want to mount the result directly on the State of the Model, rather than on "result", you can set it to true. For example:
87
87
 
88
88
  ```ts
89
- // the result: {user: 'xx', email: 'xx'}
89
+ // the result: {user: 'xx', email: 'xx'},
90
90
  // config handleEffect({ omitResultNamespace: true })
91
91
  // get State like follows:
92
92
  {
@@ -33,7 +33,7 @@ Used to define the detailed structure of the Model, supporting passing in an obj
33
33
 
34
34
  `function define(modelDesc: ModelDesc): Model;`
35
35
 
36
- - modelDesc: `ModelDesc`,definition of Model structureincludes `state`、`computed`、`actions`、`effects` etc. props.
36
+ - modelDesc: `ModelDesc`, definition of Model structure, includes `state`、`computed`、`actions`、`effects` etc. props.
37
37
 
38
38
  ```tsx title="example"
39
39
  const fooModel = model('foo').define({
@@ -59,7 +59,7 @@ const fooModel = model('foo').define({
59
59
  `function define((context: Context, utils: Utils) => ModelDesc): Model;`
60
60
 
61
61
  - `context`: Reduck Context, can get underlying `store` object. `store` support all Redux Store [API](https://redux.js.org/api/store), also mounts the `use` method for consuming the Model, and the `unmount` method for unmounting the Model.
62
- - utils: commonly used tool like `use`、`onMount`. `use` is the same as `store.use`,`onMount` is the hook function after the Model is mounted.
62
+ - utils: commonly used tool like `use`、`onMount`. `use` is the same as `store.use`, `onMount` is the hook function after the Model is mounted.
63
63
 
64
64
  {/* TODO: @anchao 调整类型 */}
65
65
  ```ts
@@ -38,8 +38,8 @@ function useModel(
38
38
 
39
39
  Returns an array with each value:
40
40
 
41
- - state: return value of `stateSelector`. if there is no `stateSelector`,will combine all incoming Model States(including derived states) and return them. If there is an attribute of the same name in the State of different Models, the following State will override the previous State. when `state` changesthe component call `useModel` will re-render.
42
- - actions: return value of `actionSelector`. if there is no `actionSelector`,will combine all incoming Model Action(including Effect) and return them. If there is an attribute of the same name in the Action of different Models, the following Action will override the previous Action.
41
+ - state: return value of `stateSelector`. if there is no `stateSelector`, will combine all incoming Model States(including derived states) and return them. If there is an attribute of the same name in the State of different Models, the following State will override the previous State. when `state` changes, the component call `useModel` will re-render.
42
+ - actions: return value of `actionSelector`. if there is no `actionSelector`, will combine all incoming Model Action(including Effect) and return them. If there is an attribute of the same name in the Action of different Models, the following Action will override the previous Action.
43
43
  - subscribe: A function that subscribes to State changes. This function is called when the State of any Model passed in changes.
44
44
 
45
45
  ## Example
@@ -8,7 +8,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
8
8
 
9
9
  <ReduckTip />
10
10
 
11
- If want to consume a Model in the form of React Hook in the componentand can get the current latest state at any timebut you don't want the Model state to be updated, which will cause the component to be re-rendered, we can use `useStaticModel`.
11
+ If want to consume a Model in the form of React Hook in the component, and can get the current latest state at any time, but you don't want the Model state to be updated, which will cause the component to be re-rendered, we can use `useStaticModel`.
12
12
 
13
13
  `useStaticModel` API is same as `useModel`.For detail, see [`useModel`](./use-model.mdx).
14
14
 
@@ -16,7 +16,7 @@ To ensure that the latest state is always available, be careful not to deconstru
16
16
 
17
17
  ```tsx
18
18
  function App() {
19
- // ❌ Do not deconstruct statebut can deconstruct actions.
19
+ // ❌ Do not deconstruct state, but can deconstruct actions.
20
20
  const [{ username }, { logout }] = useStaticModel(userModel);
21
21
 
22
22
  // ✅ True Usage.
@@ -18,7 +18,7 @@ function useStore(): ReduckStore;
18
18
 
19
19
  ### Return Type
20
20
 
21
- - ReduckStore: Reduck Storetype refer to the return type of [createStore](./create-store.mdx).
21
+ - ReduckStore: Reduck Store, type refer to the return type of [createStore](./create-store.mdx).
22
22
 
23
23
  :::info More
24
24
  [Use Model](/guides/topic-detail/model/use-model).
@@ -2,6 +2,7 @@
2
2
  title: router
3
3
  sidebar_position: 1
4
4
  ---
5
+
5
6
  # router
6
7
 
7
8
  :::info
@@ -35,8 +35,8 @@ function PreRender(props: Props): React.Component
35
35
 
36
36
  ### Input
37
37
 
38
- - `interval`: set the time the cache keep freshseconds. During this time, the cache will be used directly and not invoke asynchronous rendering.
39
- - `staleLimit`: sets the time when the cache is completely expiredseconds.During this time, The cache can be returned and asynchronous rendering will be invoke, otherwise must wait for the re-rendered result.
38
+ - `interval`: set the time the cache keep fresh, seconds. During this time, the cache will be used directly and not invoke asynchronous rendering.
39
+ - `staleLimit`: sets the time when the cache is completely expired, seconds.During this time, The cache can be returned and asynchronous rendering will be invoke, otherwise must wait for the re-rendered result.
40
40
  - `level`: sets the calculation rule level for the cache identity, usually used with `includes` and `matches`. The default value is `0`.
41
41
 
42
42
  ```bash
@@ -39,7 +39,7 @@ function render(ui: React.ReactElement<any>, options: Options): RenderResult;
39
39
 
40
40
  - `ui`: the React component that needs to be rendered.
41
41
  - `options`: render options.
42
- - `container`: the dom which component mounted. by default create a `div` elementand auto append to `document.body`. the default value is `document.body.append(document.createElement('div'))`.
42
+ - `container`: the dom which component mounted. by default create a `div` element, and auto append to `document.body`. the default value is `document.body.append(document.createElement('div'))`.
43
43
  - `baseElement`: Used to specify the `basename` used in `queries`. If `container` is specified, the default value is the value of `container`, otherwise it is `document.body`.
44
44
  - `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://reactjs.org/docs/react-dom.html#hydrate) rendering component is used. The default value is `false`.
45
45
  - `wrapper`: a react component that can be used to customize rendering logic.
@@ -6,7 +6,7 @@ import { Tabs, Tab as TabItem } from "@theme";
6
6
  <Tabs>
7
7
  <TabItem value="express" label="Express.js" default>
8
8
 
9
- ```ts title="edenx.config.ts"
9
+ ```ts title="modern.config.ts"
10
10
  import expressPlugin from '@modern-js/plugin-express';
11
11
  import bffPlugin from '@modern-js/plugin-bff';
12
12
 
@@ -18,7 +18,7 @@ export default defineConfig({
18
18
  </TabItem>
19
19
  <TabItem value="koa" label="Koa.js">
20
20
 
21
- ```ts title="edenx.config.ts"
21
+ ```ts title="modern.config.ts"
22
22
  import koaPlugin from '@modern-js/plugin-koa';
23
23
  import bffPlugin from '@modern-js/plugin-bff';
24
24
 
@@ -0,0 +1,13 @@
1
+ ---
2
+ sidebar_label: scriptLoading
3
+ ---
4
+
5
+ # html.scriptLoading
6
+
7
+ :::tip
8
+ This config is provided by Modern.js Builder, more detail can see [html.scriptLoading](https://modernjs.dev/builder/en/api/config-html.html#htmlscriptloading).
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/docs/en/config/html/scriptLoading.md';
12
+
13
+ <Main />
@@ -143,7 +143,7 @@ The `headers` set in the route override the `headers` set in the entry.
143
143
 
144
144
  By default, **Conventional Routing** all turn on SSG. Modern.js provides another field to prevent the default SSG behavior.
145
145
 
146
- For example, the following directory structure ,`/`、`/user` and `/user/profle` all have SSG enabled:
146
+ For example, the following directory structure , `/`、`/user` and `/user/profle` all have SSG enabled:
147
147
 
148
148
  ```bash
149
149
  .
@@ -23,9 +23,9 @@ This config **is used to configure the Modern.js framework plugin**. If you need
23
23
 
24
24
  There are three different type of framework plugins built into the Modern.js:
25
25
 
26
- - `CLI Plugin`,for local development, compilation and build phases, can extend various capabilities on the command line and compilation phases.
27
- - `Server Plugin`,for server-level.
28
- - `Runtime Plugin`,for runtime.
26
+ - `CLI Plugin`, for local development, compilation and build phases, can extend various capabilities on the command line and compilation phases.
27
+ - `Server Plugin`, for server-level.
28
+ - `Runtime Plugin`, for runtime.
29
29
 
30
30
  The ability to customize CLI plugins is currently open Modern.js, and the Server plugin and Runtime plugin will be available in the future.
31
31
 
@@ -14,7 +14,7 @@ For example, when the configuration and directory structure is as follows:
14
14
  ```ts title="modern.config.ts"
15
15
  export default defineConfig({
16
16
  source: {
17
- disableEntryDirs: './src/one',
17
+ disableEntryDirs: ['./src/one'],
18
18
  },
19
19
  });
20
20
  ```
@@ -0,0 +1,13 @@
1
+ ---
2
+ sidebar_label: bundlerChain
3
+ ---
4
+
5
+ # tools.bundlerChain
6
+
7
+ :::tip
8
+ This config is provided by Modern.js Builder, more detail can see [tools.bundlerChain](https://modernjs.dev/builder/en/api/config-tools.html#toolsbundlerchain).
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/docs/en/config/tools/bundlerChain.mdx';
12
+
13
+ <Main />
@@ -19,13 +19,14 @@ When using Rspack as the bundler, SWC will be used for transpiling and compressi
19
19
 
20
20
  ## Install
21
21
 
22
- The `@modern-js/plugin-swc` plugin needs to be installed before use.
22
+ First, you need to execute `pnpm run new` to enable the SWC compile:
23
23
 
24
24
  ```bash
25
- pnpm add @modern-js/plugin-swc -D
25
+ ? Action: Enable features
26
+ ? Enable features: Enable SWC Compile
26
27
  ```
27
28
 
28
- After the installationplease register the SWC plugin in the `modern.config.ts` file, then the SWC compilation and compression will be enabled.
29
+ After the installation, please register the SWC plugin in the `modern.config.ts` file, then the SWC compilation and compression will be enabled.
29
30
 
30
31
  ```ts title="modern.config.ts"
31
32
  import appTools, { defineConfig } from '@modern-js/app-tools';