@modern-js/main-doc 2.22.0 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +24 -0
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/deploy.mdx +1 -0
- package/docs/en/components/entry-mode.mdx +0 -0
- package/docs/en/components/init-app.mdx +3 -7
- package/docs/en/components/release-note.mdx +1 -0
- package/docs/en/configure/app/output/css-modules.mdx +13 -0
- package/docs/en/configure/app/tools/swc.mdx +2 -16
- package/docs/en/guides/advanced-features/rspack-start.mdx +1 -2
- package/docs/en/guides/concept/builder.mdx +15 -15
- package/docs/en/guides/concept/entries.mdx +47 -46
- package/docs/en/guides/get-started/glossary.mdx +12 -12
- package/docs/en/guides/get-started/introduction.mdx +17 -20
- package/docs/en/guides/get-started/quick-start.mdx +21 -37
- package/docs/en/guides/get-started/upgrade.mdx +15 -13
- package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
- package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
- package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
- package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
- package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
- package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
- package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
- package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
- package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
- package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
- package/docs/en/guides/troubleshooting/builder.mdx +8 -0
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/community/contributing-guide.mdx +1 -1
- package/docs/zh/components/entry-mode.mdx +0 -0
- package/docs/zh/components/init-app.mdx +5 -9
- package/docs/zh/configure/app/output/css-modules.mdx +13 -0
- package/docs/zh/configure/app/tools/swc.mdx +2 -16
- package/docs/zh/guides/advanced-features/rspack-start.mdx +1 -2
- package/docs/zh/guides/concept/builder.mdx +1 -1
- package/docs/zh/guides/concept/entries.mdx +18 -14
- package/docs/zh/guides/get-started/quick-start.mdx +7 -10
- package/docs/zh/guides/get-started/upgrade.mdx +1 -1
- package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
- package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
- package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
- package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
- package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
- package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
- package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
- package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
- package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
- package/docs/zh/guides/troubleshooting/builder.mdx +8 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# @modern-js/main-doc
|
2
2
|
|
3
|
+
## 2.22.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 411d047: docs: fix reset command
|
8
|
+
|
9
|
+
docs: 修复 reset command 翻译问题
|
10
|
+
|
11
|
+
- bce7a12: docs(main): update concept doc
|
12
|
+
|
13
|
+
docs(main): 更新核心概念文档
|
14
|
+
|
15
|
+
- 2ede584: docs(main): update start doc
|
16
|
+
|
17
|
+
docs(main): 更新开始文档
|
18
|
+
|
19
|
+
- 7267a1a: docs(main): update changeset doc
|
20
|
+
|
21
|
+
docs(main): 更新包版本管理文档
|
22
|
+
|
23
|
+
- Updated dependencies [bd4b150]
|
24
|
+
- Updated dependencies [2ede584]
|
25
|
+
- @modern-js/builder-doc@2.22.1
|
26
|
+
|
3
27
|
## 2.22.0
|
4
28
|
|
5
29
|
### Minor Changes
|
@@ -0,0 +1 @@
|
|
1
|
+
After local verification, you can organize the artifacts in `dist/` into the structure required by the server for deployment.
|
File without changes
|
@@ -1,12 +1,13 @@
|
|
1
|
-
|
1
|
+
`@modern-js/create` provides an interactive Q & A interface to initialize the project based on the results, with initialization performed according to the default settings:
|
2
2
|
|
3
3
|
```bash
|
4
4
|
? Please select the type of project you want to create: Web App
|
5
5
|
? Please select the programming language: TS
|
6
6
|
? Please select the package manager: pnpm
|
7
|
+
? Please select the bundler: webpack
|
7
8
|
```
|
8
9
|
|
9
|
-
After create the project, Modern.js automatically
|
10
|
+
After create the project, Modern.js will automatically install dependencies and create a git repository.
|
10
11
|
|
11
12
|
```bash
|
12
13
|
[INFO] dependencies are automatically installed
|
@@ -20,11 +21,6 @@ pnpm run lint # Run ESLint and automatically fix problems
|
|
20
21
|
pnpm run new # Enable optional features or add a new entry
|
21
22
|
```
|
22
23
|
|
23
|
-
:::note
|
24
|
-
In addition to working during project initialization, the Modern.js generator can also generate modules of the project in subsequent development, which is not thrown away as soon as it is used.
|
25
|
-
|
26
|
-
:::
|
27
|
-
|
28
24
|
Now, the project structure is as follows:
|
29
25
|
|
30
26
|
```
|
@@ -0,0 +1 @@
|
|
1
|
+
According to the [Release Note](https://github.com/web-infra-dev/modern.js/releases) on the official website, developers can also manually upgrade the project to the desired version.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: cssModules
|
3
|
+
---
|
4
|
+
|
5
|
+
# output.cssModules
|
6
|
+
|
7
|
+
:::tip
|
8
|
+
This config is provided by Modern.js Builder, more detail can see [output.cssModules](https://modernjs.dev/builder/en/api/config-output.html#outputcssmodules).
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/docs/en/config/output/cssModules.md';
|
12
|
+
|
13
|
+
<Main />
|
@@ -19,23 +19,9 @@ When using Rspack as the bundler, SWC will be used for transpiling and compressi
|
|
19
19
|
|
20
20
|
## Install
|
21
21
|
|
22
|
-
|
22
|
+
import EnableSWC from '@modern-js/builder-doc/docs/en/shared/enable-swc.md';
|
23
23
|
|
24
|
-
|
25
|
-
? Please select the operation you want: Enable features
|
26
|
-
? Please select the feature name: Enable SWC Compile
|
27
|
-
```
|
28
|
-
|
29
|
-
After the installation, please register the SWC plugin in the `modern.config.ts` file, then the SWC compilation and compression will be enabled.
|
30
|
-
|
31
|
-
```ts title="modern.config.ts"
|
32
|
-
import appTools, { defineConfig } from '@modern-js/app-tools';
|
33
|
-
import swcPlugin from '@modern-js/plugin-swc';
|
34
|
-
|
35
|
-
export default defineConfig({
|
36
|
-
plugins: [appTools(), swcPlugin()],
|
37
|
-
});
|
38
|
-
```
|
24
|
+
<EnableSWC />
|
39
25
|
|
40
26
|
## Config
|
41
27
|
|
@@ -81,8 +81,7 @@ For example, if you are using pnpm, you can update the Rspack version with `over
|
|
81
81
|
"@rspack/core": "nightly",
|
82
82
|
"@rspack/dev-client": "nightly",
|
83
83
|
"@rspack/dev-middleware": "nightly",
|
84
|
-
"@rspack/plugin-html": "nightly"
|
85
|
-
"@rspack/postcss-loader": "nightly"
|
84
|
+
"@rspack/plugin-html": "nightly"
|
86
85
|
}
|
87
86
|
}
|
88
87
|
}
|
@@ -4,31 +4,31 @@ sidebar_position: 2
|
|
4
4
|
|
5
5
|
# Builder
|
6
6
|
|
7
|
-
**Modern.js uses [Modern.js Builder](https://modernjs.dev/builder) to build your Web App.**
|
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 Modern.js. It is
|
9
|
+
Modern.js Builder is one of the core components of the Modern.js system. It is a build engine 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
|
-
From
|
13
|
+
From a building perspective, Modern.js is divided into three layers, from top to bottom:
|
14
14
|
|
15
|
-
- Upper-
|
16
|
-
-
|
17
|
-
- Low-level
|
15
|
+
- Upper-level development framework: Modern.js.
|
16
|
+
- Common build engine: Modern.js Builder.
|
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-1117.png" style={{ width: '100%', maxWidth: '540px' }} />
|
20
20
|
|
21
21
|
## Builder Documentation
|
22
22
|
|
23
|
-
Since Modern.js Builder is a module that can be used independently, we
|
23
|
+
Since Modern.js Builder is a module that can be used independently, we have provided separate documentation for it, which can be found at [modernjs.dev/builder](https://modernjs.dev/builder/en).
|
24
24
|
|
25
|
-
In this
|
25
|
+
In this documentation, you can learn about the detailed introduction of Modern.js Builder, and you can also find complete usage guides for various building capabilities. If you have any building needs or problems, it is recommended that you read the Modern.js Builder documentation first to solve them.
|
26
26
|
|
27
|
-
## Builder
|
27
|
+
## Builder Configuration
|
28
28
|
|
29
|
-
|
29
|
+
Modern.js's configuration inherits from Modern.js Builder, so you can use all the build configurations provided by Modern.js Builder in Modern.js.
|
30
30
|
|
31
|
-
|
31
|
+
Taking the `html.title` config option of Modern.js Builder as an example, you can directly use this option in the `modern.config.ts` file, and it will be automatically passed to Modern.js Builder.
|
32
32
|
|
33
33
|
```ts title="modern.config.js"
|
34
34
|
export default defineConfig({
|
@@ -38,10 +38,10 @@ export default defineConfig({
|
|
38
38
|
});
|
39
39
|
```
|
40
40
|
|
41
|
-
For
|
41
|
+
For detailed information about build configuration, please refer to [「Modern.js Builder - Builder Config」](https://modernjs.dev/builder/en/guide/basic/builder-config.html).
|
42
42
|
|
43
|
-
##
|
43
|
+
## Builder Capabilities
|
44
44
|
|
45
|
-
Modern.js Builder provides
|
45
|
+
Modern.js Builder provides rich build capabilities, including JavaScript compilation, CSS compilation, static resource processing, code hot update, code compression, TS type checking, and dozens of other capabilities.
|
46
46
|
|
47
|
-
We recommend you
|
47
|
+
We recommend that you read [「Modern.js Builder - All Features」](https://modernjs.dev/builder/en/guide/features.html) to learn about all the features provided by Modern.js Builder.
|
@@ -2,21 +2,21 @@
|
|
2
2
|
sidebar_position: 1
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# Entry
|
6
6
|
|
7
|
-
|
7
|
+
In this chapter, you will learn about the entry convention in Modern.js and how to customize it.
|
8
8
|
|
9
|
-
## What is
|
9
|
+
## What is Entry?
|
10
10
|
|
11
|
-
**Entry
|
11
|
+
**Entry refers to the starting module of a page.**
|
12
12
|
|
13
|
-
In
|
13
|
+
In a Modern.js project, each entry corresponds to an independent page and a server-side route. By default, Modern.js automatically determines the entry of a page based on directory conventions, but also supports customizing the entry through configuration options.
|
14
14
|
|
15
|
-
Many configuration
|
15
|
+
Many configuration options provided by Modern.js are divided by entry, such as page title, HTML template, page meta information, whether to enable SSR/SSG, server-side routing rules, etc.
|
16
16
|
|
17
17
|
## Single Entry and Multiple Entries
|
18
18
|
|
19
|
-
The project initialized by Modern.js is single
|
19
|
+
The project initialized by Modern.js is a single entry (SPA) project, with the following structure:
|
20
20
|
|
21
21
|
```
|
22
22
|
.
|
@@ -30,7 +30,7 @@ The project initialized by Modern.js is single-entry (SPA), and the project stru
|
|
30
30
|
└── tsconfig.json
|
31
31
|
```
|
32
32
|
|
33
|
-
Modern.js can easily switch from single entry to multiple
|
33
|
+
In a Modern.js project, you can easily switch from single entry to multiple entries by running `pnpm run new` in the project directory and creating an entry:
|
34
34
|
|
35
35
|
```bash
|
36
36
|
? Please select the operation you want: Create Element
|
@@ -38,7 +38,7 @@ Modern.js can easily switch from single entry to multiple entry. You can execute
|
|
38
38
|
? Please fill in the entry name: new-entry
|
39
39
|
```
|
40
40
|
|
41
|
-
After
|
41
|
+
After running the command, Modern.js will automatically generate a new entry directory. At this point, you can see that the `src/` directory has the following structure:
|
42
42
|
|
43
43
|
```bash
|
44
44
|
.
|
@@ -54,51 +54,55 @@ After execution, Modern.js will automatically generate a new entry directory, an
|
|
54
54
|
└── page.tsx
|
55
55
|
```
|
56
56
|
|
57
|
-
The original code
|
57
|
+
The original entry code has been moved to a directory with the same name as the `name` field in `package.json`, and a `new-entry` entry directory has been created.
|
58
58
|
|
59
|
-
After
|
59
|
+
After running `pnpm run dev`, you can see a new route named `/new-entry` has been added, and the migrated code route has not changed.
|
60
60
|
|
61
61
|
:::tip
|
62
|
-
Modern.js will use the entry with the same name as the `name` field in
|
62
|
+
Modern.js will use the entry with the same name as the `name` field in `package.json` as the main entry. The route of the main entry is `/`, and the route of other entries is `/{entryName}`.
|
63
63
|
|
64
|
-
For example, when `name` in package.json is `myapp`, `src/myapp` will be
|
64
|
+
For example, when the `name` field in `package.json` is `myapp`, `src/myapp` will be the main entry of the project.
|
65
65
|
|
66
66
|
:::
|
67
67
|
|
68
|
-
## Entry
|
68
|
+
## Entry Types
|
69
69
|
|
70
|
-
Different entry types have different
|
70
|
+
Different entry types have different compilation and runtime behaviors.
|
71
71
|
|
72
|
-
|
72
|
+
import EntryMode from '@site-docs-en/components/entry-mode.mdx';
|
73
|
+
|
74
|
+
<EntryMode />
|
75
|
+
|
76
|
+
By default, Modern.js scans the files under `src/` before starting the project, identifies the entry, and generates the corresponding server-side route.
|
73
77
|
|
74
78
|
:::tip
|
75
|
-
You can
|
79
|
+
You can modify the directory for entry identification by using the [source.entriesDir](/configure/app/source/entries-dir) config.
|
76
80
|
|
77
81
|
:::
|
78
82
|
|
79
|
-
Not all
|
83
|
+
Not all top-level directories under `src/` become project entries. The directory where the entry is located must meet one of the following four conditions:
|
80
84
|
|
81
|
-
1.
|
82
|
-
2. Has `App.[jt]sx?` file
|
83
|
-
3. Has `index.[jt]sx?` file
|
84
|
-
4. Has a `pages/` directory (Modern.js 1.0
|
85
|
+
1. Has a `routes/` directory.
|
86
|
+
2. Has an `App.[jt]sx?` file.
|
87
|
+
3. Has an `index.[jt]sx?` file.
|
88
|
+
4. Has a `pages/` directory (compatible with Modern.js 1.0).
|
85
89
|
|
86
|
-
When the `src/` directory meets the entry
|
90
|
+
When the `src/` directory meets the entry requirements, Modern.js considers the current project as a single entry application.
|
87
91
|
|
88
92
|
:::tip
|
89
|
-
In single
|
93
|
+
In a single entry application, the default entry name is `main`.
|
90
94
|
|
91
95
|
:::
|
92
96
|
|
93
|
-
When the project is not a single
|
97
|
+
When the project is not a single entry application, Modern.js will further look at the top-level directories under `src/`.
|
94
98
|
|
95
99
|
### Framework Mode Entry
|
96
100
|
|
97
|
-
Framework mode refers to the need to use
|
101
|
+
Framework mode refers to the need to use Modern.js framework capabilities, such as Router, SSR, integrated calls, etc. Under this type of entry convention, the entry defined by the developer is not a real webpack compilation entry. Modern.js will generate a wrapped entry during startup, and you can find the real entry in `node_modules/.modern/{entryName}/index.js`.
|
98
102
|
|
99
103
|
#### Conventional Routing
|
100
104
|
|
101
|
-
If there is a `routes/` directory in the entry, Modern.js will scan the files under `routes/`
|
105
|
+
If there is a `routes/` directory in the entry, Modern.js will scan the files under `routes/` during startup, and automatically generate client-side routes (react-router) based on file conventions. For example:
|
102
106
|
|
103
107
|
```bash
|
104
108
|
.
|
@@ -108,11 +112,13 @@ If there is a `routes/` directory in the entry, Modern.js will scan the files un
|
|
108
112
|
│ └── page.tsx
|
109
113
|
```
|
110
114
|
|
111
|
-
|
115
|
+
In the above directory, the component exported in `layout.tsx` will be the outermost component, and the component exported in `page.tsx` will be the component of the `/` route.
|
116
|
+
|
117
|
+
For more information, please refer to [Conventional Routing](/guides/basic-features/routes.html#conventional-routing).
|
112
118
|
|
113
119
|
#### Self-controlled Routing
|
114
120
|
|
115
|
-
If there is an `App.[jt]sx?` file in the entry,
|
121
|
+
If there is an `App.[jt]sx?` file in the entry, developers can set the client-side route in this file through code, or not set the client-side route.
|
116
122
|
|
117
123
|
```tsx
|
118
124
|
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
@@ -129,11 +135,11 @@ export default () => {
|
|
129
135
|
};
|
130
136
|
```
|
131
137
|
|
132
|
-
For
|
138
|
+
For more information, please refer to [Self-controlled Routing](/guides/basic-features/routes.html#self-controlled-routing).
|
133
139
|
|
134
140
|
#### Custom Bootstrap
|
135
141
|
|
136
|
-
If there is an `index.[jt]sx` file in the entry, and
|
142
|
+
If there is an `index.[jt]sx` file in the entry, and the file exports a function by default, Modern.js will pass the default `bootstrap` function as a parameter and use the exported function to replace the default `bootstrap`. This way, developers can customize how components are mounted to DOM nodes or add custom behavior before mounting. For example:
|
137
143
|
|
138
144
|
```tsx
|
139
145
|
export default (App: React.ComponentType, bootstrap: () => void) => {
|
@@ -144,12 +150,7 @@ export default (App: React.ComponentType, bootstrap: () => void) => {
|
|
144
150
|
};
|
145
151
|
```
|
146
152
|
|
147
|
-
|
148
|
-
Since the bootstrap function needs to be compatible with React17 and React18, you need to manually pass in ReactDOM parameters when calling the bootstrap function.
|
149
|
-
|
150
|
-
:::
|
151
|
-
|
152
|
-
The content of the file generated by Modern.js is as follows:
|
153
|
+
At this point, the generated file content of Modern.js is as follows:
|
153
154
|
|
154
155
|
```js
|
155
156
|
import React from 'react';
|
@@ -180,9 +181,9 @@ export default AppWrapper;
|
|
180
181
|
|
181
182
|
### Build Mode Entry
|
182
183
|
|
183
|
-
Build mode refers to
|
184
|
+
Build mode refers to not using any Modern.js runtime capabilities and completely defining the project's webpack entry by the developer.
|
184
185
|
|
185
|
-
If `index.[jt]sx`
|
186
|
+
If there is an `index.[jt]sx` file in the entry and it does not export a default function, then this file is the real webpack entry file. Similar to [Create React App](https://github.com/facebook/create-react-app), you need to mount the component to the DOM node by yourself, add hot update code, etc. For example:
|
186
187
|
|
187
188
|
```js title=src/index.jsx
|
188
189
|
import React from 'react';
|
@@ -192,13 +193,13 @@ import App from './App';
|
|
192
193
|
ReactDOM.render(<App />, document.getElementById('root'));
|
193
194
|
```
|
194
195
|
|
195
|
-
Modern.js **not
|
196
|
+
Modern.js **does not recommend** using this method for new projects, as it loses some of the framework's capabilities, such as the `runtime` configuration in the `modern.config.js` file will no longer take effect. However, this method can be very useful when migrating projects from other frameworks to Modern.js, such as CRA, or manually building webpack.
|
196
197
|
|
197
|
-
##
|
198
|
+
## Specifying Entry Using Configuration
|
198
199
|
|
199
|
-
Most existing projects are not built according to the directory
|
200
|
+
Most existing projects are not built according to the directory structure of Modern.js. If you want to change to the directory structure of Modern.js, there will be certain migration costs.
|
200
201
|
|
201
|
-
In this case,
|
202
|
+
In this case, in addition to using file conventions to generate entries, you can manually configure the entry in `modern.config.[jt]s`.
|
202
203
|
|
203
204
|
```ts title="modern.config.ts"
|
204
205
|
export default defineConfig({
|
@@ -213,11 +214,11 @@ export default defineConfig({
|
|
213
214
|
});
|
214
215
|
```
|
215
216
|
|
216
|
-
### Disable Default
|
217
|
+
### Disable Default Entry Scanning
|
217
218
|
|
218
|
-
When using
|
219
|
+
When using custom entries, part of the project structure may coincidentally hit the directory conventions of Modern.js, but in fact, this part of the directory is not the real entry.
|
219
220
|
|
220
|
-
Modern.js provides `disableDefaultEntries`
|
221
|
+
Modern.js provides the `disableDefaultEntries` configuration to disable the default entry scanning rules. When you need to customize the entry, you generally need to use `disableDefaultEntries` in combination with `entries`. This way, some existing projects can be quickly migrated without modifying the directory structure.
|
221
222
|
|
222
223
|
```ts title="modern.config.ts"
|
223
224
|
export default defineConfig({
|
@@ -6,9 +6,9 @@ sidebar_position: 4
|
|
6
6
|
|
7
7
|
## BFF
|
8
8
|
|
9
|
-
BFF
|
9
|
+
BFF is short for "Backend For Frontend". It is an architecture pattern that involves creating a backend service for frontend applications.
|
10
10
|
|
11
|
-
The BFF service acts as an intermediary between the frontend application and the
|
11
|
+
The BFF service acts as an intermediary between the frontend application and the server API, and can provide customized APIs for the frontend to use. This allows frontend developers to have more control over the data and functionality they need, without relying on the backend service to provide the corresponding capabilities.
|
12
12
|
|
13
13
|
## Bundler
|
14
14
|
|
@@ -24,15 +24,15 @@ import Builder from '@modern-js/builder-doc/docs/en/shared/builder.md';
|
|
24
24
|
|
25
25
|
## CSR
|
26
26
|
|
27
|
-
CSR stands for "Client-Side Rendering". It means that
|
27
|
+
CSR stands for "Client-Side Rendering". It means that the page is rendered in the browser using JavaScript, and logic such as data fetching, templates, and routing is completed on the client side rather than the server.
|
28
28
|
|
29
|
-
In CSR, the server sends an empty HTML shell
|
29
|
+
In CSR, the server sends an empty HTML shell and some JavaScript scripts to the browser, and the browser fetching data from the server's API and renders dynamic content to the page.
|
30
30
|
|
31
31
|
## Garfish
|
32
32
|
|
33
|
-
[Garfish](https://garfish.bytedance.net/) is a
|
33
|
+
[Garfish](https://garfish.bytedance.net/) 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
|
-
Starting from the
|
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
37
|
## Rspack
|
38
38
|
|
@@ -42,19 +42,19 @@ import Rspack from '@modern-js/builder-doc/docs/en/shared/rspack.md';
|
|
42
42
|
|
43
43
|
## SSR
|
44
44
|
|
45
|
-
SSR stands for "Server-Side Rendering". It
|
45
|
+
SSR stands for "Server-Side Rendering". It means that the HTML of the web page is generated by the server and sent to the client, rather than sending only an empty HTML shell and relying on JavaScript to generate the page content.
|
46
46
|
|
47
|
-
In traditional client-side rendering, the server sends an empty HTML shell
|
47
|
+
In traditional client-side rendering, the server sends an empty HTML shell and some JavaScript scripts to the client, and then fetching data from the server's API and fills the page with dynamic content. This leads to slow initial page loading times and is not conducive to user experience and SEO.
|
48
48
|
|
49
|
-
With SSR, the server generates
|
49
|
+
With SSR, the server generates HTML that already contains dynamic content and sends it to the client. This makes the initial page loading faster and more SEO-friendly, as search engines can crawl the rendered page.
|
50
50
|
|
51
51
|
## SSG
|
52
52
|
|
53
|
-
SSG stands for "Static Site Generation". It
|
53
|
+
SSG stands for "Static Site Generation". It means that web pages are pre-rendered as static HTML and served directly to the client, without the need for the server to generate HTML in real-time.
|
54
54
|
|
55
|
-
In traditional SSR, the server generates
|
55
|
+
In traditional SSR, the server generates HTML in real-time every time a user requests a page. With SSG, HTML can be generated in advance during the build process and hosted on a CDN or other static resource service.
|
56
56
|
|
57
|
-
SSG can provide faster
|
57
|
+
Compared to traditional SSR, SSG can provide faster loading speeds and less server-side overhead, as there is no need to maintain a server to generate HTML in real-time. However, SSG is not suitable for websites that require dynamic content, as the HTML is generated during the build process and does not support real-time updates.
|
58
58
|
|
59
59
|
## SWC
|
60
60
|
|
@@ -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,
|
10
|
+
Currently, Modern.js includes three solutions, targeting web application development, npm package development, and document site development:
|
11
11
|
|
12
12
|
import { SolutionCards } from '@site/src/components/SolutionCards';
|
13
13
|
|
@@ -31,40 +31,37 @@ import { SolutionCards } from '@site/src/components/SolutionCards';
|
|
31
31
|
]}
|
32
32
|
/>
|
33
33
|
|
34
|
-
As
|
34
|
+
As part of the Modern.js engineering system, each of the above solutions can be used separately and has its own independent documentation site. Developers can choose one or more solutions as needed.
|
35
35
|
|
36
36
|
## About Documentation
|
37
37
|
|
38
|
-
**
|
38
|
+
**The current documentation site corresponds to the Modern.js framework**, which is used to developing web applications.
|
39
39
|
|
40
|
-
- If you
|
41
|
-
- If you
|
42
|
-
- If you
|
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 develop a documentation site, please refer to the [Modern.js Doc](https://modernjs.dev/doc-tools/) documentation.
|
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.
|
43
43
|
|
44
44
|
:::tip
|
45
|
-
|
45
|
+
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
46
|
:::
|
47
47
|
|
48
48
|
## Modern.js Framework
|
49
49
|
|
50
50
|
**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.
|
51
51
|
|
52
|
-
Modern.js can provide developers with
|
52
|
+
Modern.js can provide developers with an ultimate **Development Experience** and enable applications to have better **User Experience**.
|
53
53
|
|
54
|
-
In the process of developing React applications, developers
|
54
|
+
In the process of developing React applications, developers usually need to design implementation plans for certain features or use other libraries and frameworks to solve these problems. Modern.js supports all configurations and tools needed by React applications, and has built-in **additional features and optimizations**. Developers can use React to build the UI of the application, and then gradually adopt the features of Modern.js to solve common application requirements, such as routing, data acquisition, and state management.
|
55
55
|
|
56
|
-
|
56
|
+
It mainly includes the following features:
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
- 🌏 **Ecology**: Self-developed state management, micro frontend, module packaging, Monorepo solution and other peripheral requirements.
|
65
|
-
- 🕸 **Routing Modes**: Contains controlled routing, routing based on file conventions (nested routing), configurable routing, etc.
|
66
|
-
- 🚀 **Independently Build Core**: Support a variety of packaging tools, deep optimization bundle.
|
58
|
+
- 🚀 **Rust Bundler**: Provides support for dual bundlers, easily switch to the Rspack for faster build speed.
|
59
|
+
- 🪜 **Progressive**: Create projects with the most streamlined templates, gradually enable plugin features through the generator, and customize solutions.
|
60
|
+
- 🏠 **Integration**: Development and production environment web server are unique, CSR and SSR are isomorphic development, and API service calls are functions as interfaces.
|
61
|
+
- 📦 **Out Of The Box**: Default TS support, built-in build, ESLint, debugging tools, fully functional and testable.
|
62
|
+
- 🌏 **Ecology**: Self-developed state management, micro-frontend, module packaging, Monorepo solutions, and other peripheral needs.
|
63
|
+
- 🕸 **Routing Modes**: Includes self-controlled routing, file-convention-based routing (nested routing), etc.
|
67
64
|
|
68
65
|
## Next
|
69
66
|
|
70
|
-
If you want to
|
67
|
+
If you want to learn how to use the Modern.js framework, you can try to [create your first application](/tutorials/first-app/c01-start), or read the [Quick Start](/guides/get-started/quick-start) guide.
|