@modern-js/main-doc 2.32.1 → 2.33.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/docs/en/apis/app/runtime/app/define-config.mdx +2 -2
- package/docs/en/apis/app/runtime/model/auto-actions.mdx +2 -2
- package/docs/en/apis/app/runtime/model/model_.mdx +0 -1
- package/docs/en/apis/app/runtime/model/use-static-model.mdx +1 -1
- package/docs/en/community/contributing-guide.mdx +2 -3
- package/docs/en/configure/app/builder-plugins.mdx +1 -1
- package/docs/en/configure/app/source/enable-async-entry.mdx +3 -1
- package/docs/en/configure/app/tools/tailwindcss.mdx +43 -1
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -2
- package/docs/en/guides/advanced-features/bff/function.mdx +1 -1
- package/docs/en/guides/basic-features/css.mdx +28 -18
- package/docs/en/guides/basic-features/mock.mdx +1 -1
- package/docs/en/guides/concept/builder.mdx +2 -2
- package/docs/en/guides/get-started/glossary.mdx +13 -1
- package/docs/en/guides/get-started/introduction.mdx +10 -6
- package/docs/en/guides/topic-detail/framework-plugin/hook.mdx +2 -2
- package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/category.md +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/context.md +1 -1
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +2 -5
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +2 -2
- package/docs/en/guides/topic-detail/model/auto-actions.mdx +1 -1
- package/docs/en/guides/topic-detail/model/performance.mdx +2 -1
- package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +1 -1
- package/docs/en/guides/topic-detail/model/use-model.mdx +1 -1
- package/docs/en/tutorials/first-app/c05-loader.mdx +0 -2
- package/docs/zh/community/blog/v2-release-note.mdx +7 -8
- package/docs/zh/community/contributing-guide.mdx +2 -3
- package/docs/zh/configure/app/builder-plugins.mdx +1 -1
- package/docs/zh/configure/app/source/enable-async-entry.mdx +4 -2
- package/docs/zh/configure/app/tools/tailwindcss.mdx +42 -2
- package/docs/zh/guides/basic-features/css.mdx +27 -18
- package/docs/zh/guides/concept/builder.mdx +3 -3
- package/docs/zh/guides/get-started/glossary.mdx +13 -1
- package/docs/zh/guides/get-started/introduction.mdx +11 -7
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +1 -1
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +3 -6
- package/docs/zh/tutorials/first-app/c06-model.mdx +1 -4
- package/package.json +9 -8
- package/{modern.config.ts → rspress.config.ts} +78 -76
- package/src/components/ContentCard/index.tsx +2 -3
- package/src/components/ListCard/index.tsx +1 -1
- package/src/components/RandomMemberList/index.tsx +1 -1
- package/src/components/ShowcaseList/index.module.scss +5 -5
- package/src/components/SolutionCards/index.module.scss +2 -2
- package/src/i18n/enUS.ts +2 -2
- package/src/i18n/index.ts +1 -1
- package/src/i18n/zhCN.ts +2 -2
- package/src/index.ts +3 -2
- package/src/pages/index.module.scss +1 -1
- package/src/pages/index.tsx +7 -6
- package/docs/en/configure/app/source/design-system.mdx +0 -1175
- package/docs/zh/configure/app/source/design-system.mdx +0 -1174
package/CHANGELOG.md
CHANGED
@@ -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
|
-
{/*
|
60
|
+
{/* Semantics are different from native methods, API to be modified */}
|
61
61
|
- `concat`: concat array.
|
62
|
-
{/*
|
62
|
+
{/* Semantics are different from native methods, API to be modified */}
|
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).
|
@@ -61,7 +61,6 @@ const fooModel = model('foo').define({
|
|
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
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
|
-
{/* TODO: @anchao 调整类型 */}
|
65
64
|
```ts
|
66
65
|
interface Utils {
|
67
66
|
use: UseModel;
|
@@ -189,14 +189,13 @@ root
|
|
189
189
|
└─ packages
|
190
190
|
└─ document
|
191
191
|
├─ builder-doc # Documentation for Modern.js Builder
|
192
|
-
├─ doc-tools-doc # Documentation for Modern.js Doc
|
193
192
|
├─ main-doc # Documentation for Modern.js Framework
|
194
193
|
└─ module-doc # Documentation for Modern.js Module
|
195
194
|
```
|
196
195
|
|
197
|
-
This website is built with
|
196
|
+
This website is built with Rspress, the document content can be written using markdown or mdx syntax. You can refer to the [Rspress Website](https://rspress.dev/) for detailed usage.
|
198
197
|
|
199
|
-
The source code of
|
198
|
+
The source code of Rspress can be found in [this repo](https://github.com/web-infra-dev/rspress).
|
200
199
|
|
201
200
|
---
|
202
201
|
|
@@ -9,7 +9,7 @@ sidebar_position: 21
|
|
9
9
|
|
10
10
|
Used to configure the Modern.js Builder plugin.
|
11
11
|
|
12
|
-
Modern.js Builder is the build
|
12
|
+
Modern.js Builder is the build tool of Modern.js, please read [Builder](/guides/concept/builder) for background. If you want to know how to write Builder plugins, you can refer to [Modern.js Builder - Introduce to Plugin](https://modernjs.dev/builder/en/plugins/introduction.html).
|
13
13
|
|
14
14
|
## Precautions
|
15
15
|
|
@@ -13,7 +13,9 @@ When this option is enabled, Modern.js will wrap the automatically generated ent
|
|
13
13
|
|
14
14
|
## Background
|
15
15
|
|
16
|
-
|
16
|
+
import ModuleFederation from '@modern-js/builder-doc/docs/zh/shared/module-federation.md';
|
17
|
+
|
18
|
+
<ModuleFederation />
|
17
19
|
|
18
20
|
## Example
|
19
21
|
|
@@ -17,6 +17,14 @@ const tailwind = {
|
|
17
17
|
};
|
18
18
|
```
|
19
19
|
|
20
|
+
Used to modify the configuration of [Tailwind CSS](https://tailwindcss.com/docs/configuration).
|
21
|
+
|
22
|
+
### Enabling Tailwind CSS
|
23
|
+
|
24
|
+
Before using `tools.tailwindcss`, you need to enable the Tailwind CSS plugin for Modern.js.
|
25
|
+
|
26
|
+
Please refer to the section [Using Tailwind CSS](/guides/basic-features/css.html#using-tailwind-css) for instructions on how to enable it.
|
27
|
+
|
20
28
|
### Function Type
|
21
29
|
|
22
30
|
When `tools.tailwindcss`'s type is Function, the default tailwindcss config will be passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result.
|
@@ -51,6 +59,40 @@ export default {
|
|
51
59
|
|
52
60
|
### Notes
|
53
61
|
|
54
|
-
Please note
|
62
|
+
Please note:
|
63
|
+
|
64
|
+
- If you are using both the `tailwind.config.{ts,js}` file and `tools.tailwindcss` option, the configuration defined in `tools.tailwindcss` will take precedence and override the content defined in `tailwind.config.{ts,js}`.
|
65
|
+
- If you are using the `source.designSystem` configuration option simultaneously, the `theme` configuration of Tailwind CSS will be overridden by the value of `source.designSystem`.
|
55
66
|
|
56
67
|
The usage of other configurations follows the same approach as the official usage of Tailwind CSS. Please refer to [tailwindcss - Configuration](https://tailwindcss.com/docs/configuration) for more details.
|
68
|
+
|
69
|
+
### About source.designSystem
|
70
|
+
|
71
|
+
`source.designSystem` is a deprecated configuration option in Modern.js.
|
72
|
+
|
73
|
+
Starting from Modern.js vMAJOR_VERSION.33.0, you can use the `theme` configuration option of Tailwind CSS as a replacement for `source.designSystem`. It is no longer necessary to split the `theme` configuration and set it on `designSystem`.
|
74
|
+
|
75
|
+
- Previous usage:
|
76
|
+
|
77
|
+
```ts title="modern.config.ts"
|
78
|
+
const { theme, ...rest } = tailwindConfig;
|
79
|
+
|
80
|
+
export default {
|
81
|
+
tools: {
|
82
|
+
tailwindcss: rest,
|
83
|
+
},
|
84
|
+
source: {
|
85
|
+
designSystem: theme,
|
86
|
+
},
|
87
|
+
};
|
88
|
+
```
|
89
|
+
|
90
|
+
- Current usage:
|
91
|
+
|
92
|
+
```ts title="modern.config.ts"
|
93
|
+
export default {
|
94
|
+
tools: {
|
95
|
+
tailwindcss: tailwindConfig,
|
96
|
+
},
|
97
|
+
};
|
98
|
+
```
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
sidebar_position: 3
|
3
|
-
title: Frameworks
|
4
3
|
---
|
4
|
+
|
5
5
|
# Frameworks
|
6
6
|
|
7
|
-
Modern.js's BFF supports different runtime frameworks, currently Modern.js's BFF supports two runtime frameworks[Express.js](https://expressjs.com/)
|
7
|
+
Modern.js's BFF supports different runtime frameworks, currently Modern.js's BFF supports two runtime frameworks: [Express.js](https://expressjs.com/) and [Koa.js](https://koajs.com/).
|
8
8
|
|
9
9
|
## Function Mode
|
10
10
|
|
@@ -103,37 +103,47 @@ Depending on your needs, you can selectively import the CSS files provided by Ta
|
|
103
103
|
|
104
104
|
:::
|
105
105
|
|
106
|
-
### Tailwind CSS
|
107
|
-
|
108
|
-
Tailwind CSS provides an official extension called [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) for autocompletion of Tailwind CSS class names, CSS functions, and directives in VS Code.
|
106
|
+
### Configuring Tailwind CSS
|
109
107
|
|
110
|
-
|
108
|
+
In Modern.js, you have two ways to configure Tailwind CSS:
|
111
109
|
|
112
|
-
1.
|
113
|
-
2. Create a `tailwind.config.ts` file in the root directory of your project and write the desired Tailwind CSS configuration.
|
110
|
+
1. Using the `tailwind.config.{ts,js}` file, which follows the official usage of Tailwind CSS. Please refer to ["Tailwind CSS - Configuration"](https://tailwindcss.com/docs/configuration) for more details.
|
114
111
|
|
115
112
|
```ts title="tailwind.config.ts"
|
113
|
+
import type { Config } from 'tailwindcss';
|
114
|
+
|
116
115
|
export default {
|
117
|
-
content: [
|
118
|
-
|
119
|
-
'./config/html/**/*.{html,ejs,hbs}',
|
120
|
-
'./storybook/**/*',
|
121
|
-
],
|
122
|
-
};
|
116
|
+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
117
|
+
} as Config;
|
123
118
|
```
|
124
119
|
|
125
|
-
|
120
|
+
:::tip
|
121
|
+
Please upgrade Modern.js to version >= MAJOR_VERSION.33.0 to support automatic reading of `tailwind.config.{ts,js}` files.
|
122
|
+
:::
|
126
123
|
|
127
|
-
|
128
|
-
import tailwindConfig from './tailwind.config';
|
124
|
+
2. Using the [tools.tailwindcss](/configure/app/tools/tailwindcss.html) configuration option. This is the old way of configuring Tailwind CSS, and we recommend using the `tailwind.config.{ts,js}` file for configuration.
|
129
125
|
|
130
|
-
|
126
|
+
```ts title="modern.config.ts"
|
127
|
+
export default {
|
131
128
|
tools: {
|
132
|
-
tailwindcss:
|
129
|
+
tailwindcss: {
|
130
|
+
content: ['./src/**/*.{js,jsx,ts,tsx}'],
|
131
|
+
},
|
133
132
|
},
|
134
|
-
}
|
133
|
+
};
|
135
134
|
```
|
136
135
|
|
136
|
+
If you are using both the `tailwind.config.{ts,js}` file and `tools.tailwindcss` option, the configuration defined in `tools.tailwindcss` will take precedence and override the content defined in `tailwind.config.{ts,js}`.
|
137
|
+
|
138
|
+
### Tailwind CSS Autocomplete
|
139
|
+
|
140
|
+
Tailwind CSS provides an official extension called [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) for autocompletion of Tailwind CSS class names, CSS functions, and directives in VS Code.
|
141
|
+
|
142
|
+
You can follow the steps below to enable the autocomplete feature:
|
143
|
+
|
144
|
+
1. Install the [Tailwind CSS IntelliSense](https://github.com/tailwindlabs/tailwindcss-intellisense) extension in VS Code.
|
145
|
+
2. If the root directory of your project does not have a `tailwind.config.{ts,js}` file, you need to create one and write the Tailwind CSS configuration for your current project. Otherwise, the IDE plugin will not work correctly.
|
146
|
+
|
137
147
|
### Tailwind CSS Version
|
138
148
|
|
139
149
|
Modern.js supports both Tailwind CSS v2 and v3 versions, and the framework will recognize the version of the `tailwindcss` dependency in the project `package.json` file and enable the corresponding configuration. By default, we will install Tailwind CSS v3 version for you.
|
@@ -52,7 +52,7 @@ const Mock = require('mockjs');
|
|
52
52
|
module.exports = {
|
53
53
|
'/api/getInfo': Mock.mock({
|
54
54
|
'data|1-10': [{ name: '@cname' }],
|
55
|
-
}) /* => {data: [{name: "
|
55
|
+
}) /* => {data: [{name: "Jack"}, {name: "Jim"}, {name: "Mary"}} */,
|
56
56
|
};
|
57
57
|
```
|
58
58
|
|
@@ -6,14 +6,14 @@ sidebar_position: 2
|
|
6
6
|
|
7
7
|
**Modern.js uses [Modern.js Builder](https://modernjs.dev/builder/en) to build your Web App.**
|
8
8
|
|
9
|
-
Modern.js Builder is one of the core components of the Modern.js system. It is a build
|
9
|
+
Modern.js Builder is one of the core components of the Modern.js system. It is a build tool for web development scenarios that can be used independently of Modern.js. Modern.js Builder supports multiple bundlers such as webpack and Rspack, and by default uses the most mature webpack for bundling.
|
10
10
|
|
11
11
|
## Build Architecture
|
12
12
|
|
13
13
|
From a building perspective, Modern.js is divided into three layers, from top to bottom:
|
14
14
|
|
15
15
|
- Upper-level development framework: Modern.js.
|
16
|
-
- Common build
|
16
|
+
- Common build tool: Modern.js Builder.
|
17
17
|
- Low-level bundler: webpack and Rspack.
|
18
18
|
|
19
19
|
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-0824.png" style={{ width: '100%', maxWidth: '540px' }} />
|
@@ -30,10 +30,22 @@ In CSR, the server sends an empty HTML shell and some JavaScript scripts to the
|
|
30
30
|
|
31
31
|
## Garfish
|
32
32
|
|
33
|
-
[Garfish](https://
|
33
|
+
[Garfish](https://garfishjs.org/) is a micro-frontend solution mainly used to solve problems such as cross-team collaboration and diversified technology systems in web applications.
|
34
34
|
|
35
35
|
Starting from the architecture level, it combines multiple independently delivered frontend applications into a whole. These frontend applications can be developed, tested, and deployed independently, but in the user's perspective, they are still cohesive single products.
|
36
36
|
|
37
|
+
## Micro-frontend
|
38
|
+
|
39
|
+
import MicroFrontend from '@modern-js/builder-doc/docs/en/shared/micro-frontend.md';
|
40
|
+
|
41
|
+
<MicroFrontend />
|
42
|
+
|
43
|
+
## Module Federation
|
44
|
+
|
45
|
+
import ModuleFederation from '@modern-js/builder-doc/docs/en/shared/module-federation.md';
|
46
|
+
|
47
|
+
<ModuleFederation />
|
48
|
+
|
37
49
|
## Rspack
|
38
50
|
|
39
51
|
import Rspack from '@modern-js/builder-doc/docs/en/shared/rspack.md';
|
@@ -7,7 +7,7 @@ sidebar_position: 1
|
|
7
7
|
|
8
8
|
**Modern.js is an open source web engineering system from ByteDance**, which provides multiple solutions to help developers solve problems in different development scenarios.
|
9
9
|
|
10
|
-
Currently, Modern.js includes three solutions, targeting web application development, npm package development, and
|
10
|
+
Currently, Modern.js includes three solutions, targeting web application development, npm package development, and web application building:
|
11
11
|
|
12
12
|
import { SolutionCards } from '@site/src/components/SolutionCards';
|
13
13
|
|
@@ -24,9 +24,9 @@ import { SolutionCards } from '@site/src/components/SolutionCards';
|
|
24
24
|
link: 'http://modernjs.dev/module-tools/en/',
|
25
25
|
},
|
26
26
|
{
|
27
|
-
title: 'Modern.js
|
28
|
-
description: 'For
|
29
|
-
link: 'http://modernjs.dev/
|
27
|
+
title: 'Modern.js Builder',
|
28
|
+
description: 'For web application building',
|
29
|
+
link: 'http://modernjs.dev/builder/en/',
|
30
30
|
},
|
31
31
|
]}
|
32
32
|
/>
|
@@ -38,13 +38,17 @@ As part of the Modern.js engineering system, each of the above solutions can be
|
|
38
38
|
**The current documentation site corresponds to the Modern.js framework**, which is used to developing web applications.
|
39
39
|
|
40
40
|
- If you need to develop an npm package, please refer to the [Modern.js Module](https://modernjs.dev/module-tools) documentation.
|
41
|
-
- If you need to
|
42
|
-
- If you need to implement a web development framework based on the Modern.js build engine, please refer to the [Modern.js Builder](https://modernjs.dev/builder) documentation.
|
41
|
+
- If you need to implement a web development framework based on the Modern.js build tool, please refer to the [Modern.js Builder](https://modernjs.dev/builder) documentation.
|
43
42
|
|
44
43
|
:::tip
|
45
44
|
Since the Modern.js framework is the most widely used, in this documentation site, we will omit "framework" and directly refer to it as Modern.js.
|
46
45
|
:::
|
47
46
|
|
47
|
+
Modern.js can also be combined with the following solutions:
|
48
|
+
|
49
|
+
- If you need to develop a documentation site, [Rspress](https://rspress.dev/) is recommended.
|
50
|
+
- If you need to introduce micro-frontend architecture, [Garfish](https://garfishjs.org/) is recommended.
|
51
|
+
|
48
52
|
## Modern.js Framework
|
49
53
|
|
50
54
|
**The Modern.js framework is a progressive web framework based on React**. At ByteDance, we use Modern.js to build upper-level frameworks that have supported the development of thousands of web applications.
|
@@ -66,7 +66,7 @@ pipeline.use((count, next) => {
|
|
66
66
|
return count * 2;
|
67
67
|
});
|
68
68
|
|
69
|
-
// 3.
|
69
|
+
// 3. Run
|
70
70
|
pipeline.run(1); // 2
|
71
71
|
pipeline.run(5); // 6
|
72
72
|
```
|
@@ -155,7 +155,7 @@ workflow.use(count => {
|
|
155
155
|
return count * 2;
|
156
156
|
});
|
157
157
|
|
158
|
-
// 3.
|
158
|
+
// 3. Run
|
159
159
|
workflow.run(1); // [2, 2]
|
160
160
|
workflow.run(5); // [6, 10]
|
161
161
|
```
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
4
4
|
|
5
5
|
# Usage
|
6
6
|
|
7
|
-
Modern.js provides `@modern-js/create` tool for creating project templates provided by Modern.js, including [Web App](https://modernjs.dev/), [Npm Module](https://modernjs.dev/module-tools), [
|
7
|
+
Modern.js provides `@modern-js/create` tool for creating project templates provided by Modern.js, including [Web App](https://modernjs.dev/), [Npm Module](https://modernjs.dev/module-tools), [Monorepo](/guides/topic-detail/monorepo/intro.html).
|
8
8
|
|
9
9
|
The following will introduce how to use `@modern-js/create`.
|
10
10
|
|
@@ -58,7 +58,7 @@ npx @modern-js/create@latest plugin --plugin @modern-js/generator-plugin-plugin
|
|
58
58
|
? Please select the base type of the plugin: Web App
|
59
59
|
```
|
60
60
|
|
61
|
-
###
|
61
|
+
### Custom
|
62
62
|
|
63
63
|
```bash
|
64
64
|
npx @modern-js/create@latest plugin --plugin @modern-js/generator-plugin-plugin
|
@@ -4,12 +4,9 @@ title: Introduction
|
|
4
4
|
---
|
5
5
|
# Introduction
|
6
6
|
|
7
|
-
|
7
|
+
import MicroFrontend from '@modern-js/builder-doc/docs/en/shared/micro-frontend.md';
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
- As the iterative application of the project becomes larger and more difficult to maintain.
|
12
|
-
- Collaborative development of projects across teams or departments leads to inefficiencies.
|
9
|
+
<MicroFrontend />
|
13
10
|
|
14
11
|
## Keyword
|
15
12
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
sidebar_position: 2
|
3
|
-
title:
|
3
|
+
title: Development
|
4
4
|
---
|
5
5
|
|
6
6
|
# Experience Micro Frontend
|
@@ -16,7 +16,7 @@ Currently supports two routing modes
|
|
16
16
|
- Self-controlled routing
|
17
17
|
- Conventional routing
|
18
18
|
|
19
|
-
First, clarify the routing mode of the main application [create a
|
19
|
+
First, clarify the routing mode of the main application [create a file-based routing main App](#file-based-routing-main-app) or [create a self-controlled main App](#self-controlled-main-app)
|
20
20
|
|
21
21
|
In this experience we will create two sub-applications Table and Dashboard for the main application (Table is reduced routing, Dashboard is self-controlled routing)
|
22
22
|
|
@@ -84,7 +84,8 @@ const fooModel = model('foo').define({
|
|
84
84
|
});
|
85
85
|
|
86
86
|
function ComponentA() {
|
87
|
-
//
|
87
|
+
// By passing in the selector function
|
88
|
+
// only the a state is returned to the component
|
88
89
|
const [stateA] = useModel(fooModel, state => state.a);
|
89
90
|
|
90
91
|
return <div>{stateA}</div>;
|
@@ -30,7 +30,7 @@ export const foo = model<State>('foo').define({
|
|
30
30
|
});
|
31
31
|
```
|
32
32
|
|
33
|
-
When you declare type information for the State of a Model, the `computed` and `actions` of the Model can get the correct type information. In fact, even if we don't define State type information in the example code above, the type information of State can be automatically inferred based on the initial value information of `state`. However, we still recommend that you declare the type information of State when defining a Model because the type information of State inferred based on the initial value information of `state` may be incomplete (missing fields or field type information), and the type information of State cannot be automatically inferred based on the initial value information of `state` when using [Function Type](/apis/app/runtime/model/model_
|
33
|
+
When you declare type information for the State of a Model, the `computed` and `actions` of the Model can get the correct type information. In fact, even if we don't define State type information in the example code above, the type information of State can be automatically inferred based on the initial value information of `state`. However, we still recommend that you declare the type information of State when defining a Model because the type information of State inferred based on the initial value information of `state` may be incomplete (missing fields or field type information), and the type information of State cannot be automatically inferred based on the initial value information of `state` when using [Function Type](/apis/app/runtime/model/model_#function-type) to define the Model.
|
34
34
|
|
35
35
|
## Dependent types of Derived State
|
36
36
|
|
@@ -78,8 +78,6 @@ function Index() {
|
|
78
78
|
export default Index;
|
79
79
|
```
|
80
80
|
|
81
|
-
{/* Todo 重新截图,SSR 内容 */}
|
82
|
-
|
83
81
|
Re-execute `pnpm run dev`, view `view-source: http://localhost:8080/`, or view the "Preview" of the HTML request in the Network panel of devtools, you can see that the HTML rendered by SSR already contains the complete UI:
|
84
82
|
|
85
83
|

|
@@ -205,17 +205,17 @@ Modern.js Module 的核心能力包括:
|
|
205
205
|
|
206
206
|
> 如果你对 Modern.js Module 感兴趣,请移步[「Modern.js Module 文档」](https://modernjs.dev/module-tools)来了解更多。
|
207
207
|
|
208
|
-
##
|
208
|
+
## Rspress
|
209
209
|
|
210
|
-
|
210
|
+
Rspress 是一个面向文档站场景的框架,它的目标是给开发者提供一个简单、高效、可扩展的文档站解决方案。
|
211
211
|
|
212
|
-

|
213
213
|
|
214
214
|
<div style={{ textAlign: 'center', fontStyle: 'italic' }}>
|
215
|
-
|
215
|
+
Rspress 官网介绍页
|
216
216
|
</div>
|
217
217
|
|
218
|
-
目前,
|
218
|
+
目前,Rspress 包含如下能力:
|
219
219
|
|
220
220
|
- **基于 Rspack 构建**:项目构建和 HMR 速度飞快,提供愉悦的开发和生产部署体验。
|
221
221
|
- **支持 MDX 语法**:在普通 Markdown 语法的基础上可以嵌入 React 组件和 JSX 语法。
|
@@ -224,9 +224,9 @@ Modern.js Doc 是一个面向文档站场景的框架,它的目标是给开发
|
|
224
224
|
- **自定义主题**:内置一套默认主题,你可以基于这套主题进行扩展,也可以从零定制一套自定义主题。
|
225
225
|
- **插件机制**:提供丰富的插件钩子能力,让你能够充分自定义扩展框架功能。
|
226
226
|
|
227
|
-
我们做
|
227
|
+
我们做 Rspress 的初心,是为了解决我们团队内的文档站搭建需求。随着 Rspress 的功能逐渐完整,我们也将它开放给社区使用,使它能发挥更大的价值。
|
228
228
|
|
229
|
-
目前,
|
229
|
+
目前,Rspress 仍处于 beta 测试状态,相关源代码已经开放在 [Rspress 仓库](https://github.com/web-infra-dev/rspress) 中,并提供了基础的 [使用文档](https://rspress.dev/)。在未来,我们将继续投入,使之成为一个完成度更高的文档解决方案。
|
230
230
|
|
231
231
|
## 致谢
|
232
232
|
|
@@ -236,7 +236,6 @@ Modern.js 中的部分代码实现参考了社区中的开源项目,我们对
|
|
236
236
|
- `@modern-js/plugin`: hook API 的实现参考了 [farrow-pipeline](https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline)。
|
237
237
|
- `@modern-js/builder`: moduleScope 和 fileSize 插件参考了 [create-react-app](https://github.com/facebook/create-react-app),TsConfigPathsPlugin 参考了 [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin),generateMetaTags 函数参考了 [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin)。
|
238
238
|
- `@modern-js/plugin-testing`: jest runner 参考了 [jest-cli](https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21)。
|
239
|
-
- `@modern-js/doc-tools`: 部分样式参考了 [vitepress](https://github.com/vuejs/vitepress)。
|
240
239
|
- `@modern-js/plugin-data-loader`: 部分实现参考了 [remix](https://github.com/remix-run/remix)。
|
241
240
|
|
242
241
|
## 最后
|
@@ -188,14 +188,13 @@ root
|
|
188
188
|
└─ packages
|
189
189
|
└─ document
|
190
190
|
├─ builder-doc # Modern.js Builder 文档
|
191
|
-
├─ doc-tools-doc # Modern.js Doc 文档
|
192
191
|
├─ main-doc # Modern.js Framework 文档
|
193
192
|
└─ module-doc # Modern.js Module 文档
|
194
193
|
```
|
195
194
|
|
196
|
-
文档站使用
|
195
|
+
文档站使用 Rspress 构建,文档内容可以使用 markdown 或 mdx 语法编写。详细使用方法可以参考 [Rspress 文档](https://rspress.dev/)。
|
197
196
|
|
198
|
-
|
197
|
+
Rspress 的源代码可以在 [这个仓库](https://github.com/web-infra-dev/rspress) 中找到。
|
199
198
|
|
200
199
|
---
|
201
200
|
|
@@ -9,7 +9,7 @@ sidebar_position: 21
|
|
9
9
|
|
10
10
|
用于配置 Modern.js Builder 构建插件。
|
11
11
|
|
12
|
-
Modern.js Builder 是 Modern.js
|
12
|
+
Modern.js Builder 是 Modern.js 底层的构建工具,请阅读 [构建能力](/guides/concept/builder) 了解相关背景。
|
13
13
|
|
14
14
|
如果你想了解 Builder 插件的编写方式,可以参考 [Modern.js Builder - 插件系统](https://modernjs.dev/builder/plugins/introduction.html)。
|
15
15
|
|
@@ -9,11 +9,13 @@ sidebar_label: enableAsyncEntry
|
|
9
9
|
|
10
10
|
该选项用于 webpack 模块联邦(Module Federation)场景。
|
11
11
|
|
12
|
-
开启此选项后,Modern.js 会通过
|
12
|
+
开启此选项后,Modern.js 会通过 dynamic import 来包裹自动生成的入口文件(Asynchronous Boundaries),使页面代码可以消费模块联邦生成的远程模块。
|
13
13
|
|
14
14
|
## 背景知识
|
15
15
|
|
16
|
-
|
16
|
+
import ModuleFederation from '@modern-js/builder-doc/docs/zh/shared/module-federation.md';
|
17
|
+
|
18
|
+
<ModuleFederation />
|
17
19
|
|
18
20
|
## 示例
|
19
21
|
|
@@ -17,7 +17,13 @@ const tailwind = {
|
|
17
17
|
};
|
18
18
|
```
|
19
19
|
|
20
|
-
|
20
|
+
用于修改 [Tailwind CSS](https://tailwindcss.com/docs/configuration) 的配置项。
|
21
|
+
|
22
|
+
### 启用 Tailwind CSS
|
23
|
+
|
24
|
+
在使用 `tools.tailwindcss` 之前,你需要启用 Modern.js 的 Tailwind CSS 插件。
|
25
|
+
|
26
|
+
请阅读[「使用 Tailwind CSS」](/guides/basic-features/css.html#使用-tailwind-css) 章节来了解开启方式。
|
21
27
|
|
22
28
|
### Function 类型
|
23
29
|
|
@@ -53,6 +59,40 @@ export default {
|
|
53
59
|
|
54
60
|
### 注意事项
|
55
61
|
|
56
|
-
|
62
|
+
注意:
|
63
|
+
|
64
|
+
- 如果你同时使用了 `tailwind.config.{ts,js}` 文件和 `tools.tailwindcss` 选项,那么 `tools.tailwindcss` 定义的配置会优先生效,并覆盖 `tailwind.config.{ts,js}` 中定义的内容。
|
65
|
+
- 如果你同时使用了 `source.designSystem` 配置项,那么 Tailwind CSS 的 `theme` 配置将会被 `source.designSystem` 的值所覆盖。
|
57
66
|
|
58
67
|
其他配置的使用方式与 Tailwind CSS 官方用法一致,请参考 [tailwindcss - Configuration](https://tailwindcss.com/docs/configuration)。
|
68
|
+
|
69
|
+
### 关于 source.designSystem
|
70
|
+
|
71
|
+
`source.designSystem` 是 Modern.js 中废弃的配置项。
|
72
|
+
|
73
|
+
从 Modern.js vMAJOR_VERSION.33.0 版本开始,你可以使用 Tailwind CSS 的 `theme` 配置项来代替 `source.designSystem`,不再需要将 `theme` 配置拆分并设置到 `designSystem` 上。
|
74
|
+
|
75
|
+
- 旧版本用法:
|
76
|
+
|
77
|
+
```ts title="modern.config.ts"
|
78
|
+
const { theme, ...rest } = tailwindConfig;
|
79
|
+
|
80
|
+
export default {
|
81
|
+
tools: {
|
82
|
+
tailwindcss: rest,
|
83
|
+
},
|
84
|
+
source: {
|
85
|
+
designSystem: theme,
|
86
|
+
},
|
87
|
+
};
|
88
|
+
```
|
89
|
+
|
90
|
+
- 当前版本用法:
|
91
|
+
|
92
|
+
```ts title="modern.config.ts"
|
93
|
+
export default {
|
94
|
+
tools: {
|
95
|
+
tailwindcss: tailwindConfig,
|
96
|
+
},
|
97
|
+
};
|
98
|
+
```
|