@modern-js/main-doc 0.0.0-next-1686120584093 → 0.0.0-next-1686150530663

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,24 +1,28 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-1686120584093
3
+ ## 0.0.0-next-1686150530663
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 411d047d98: docs: fix reset command
7
+ - 411d047d9: docs: fix reset command
8
8
 
9
9
  docs: 修复 reset command 翻译问题
10
10
 
11
- - 2ede584c37: docs(main): update start doc
11
+ - bce7a1274: docs(main): update concept doc
12
+
13
+ docs(main): 更新核心概念文档
14
+
15
+ - 2ede584c3: docs(main): update start doc
12
16
 
13
17
  docs(main): 更新开始文档
14
18
 
15
- - 7267a1ae6c: docs(main): update changeset doc
19
+ - 7267a1ae6: docs(main): update changeset doc
16
20
 
17
21
  docs(main): 更新包版本管理文档
18
22
 
19
- - Updated dependencies [bd4b150404]
20
- - Updated dependencies [2ede584c37]
21
- - @modern-js/builder-doc@0.0.0-next-1686120584093
23
+ - Updated dependencies [bd4b15040]
24
+ - Updated dependencies [2ede584c3]
25
+ - @modern-js/builder-doc@0.0.0-next-1686150530663
22
26
 
23
27
  ## 2.22.0
24
28
 
File without changes
@@ -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 />
@@ -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 A build engine for web development. and can be used independently of Modern.js. Modern.js Builder supports multiple bundlers such as webpack and Rspack, and it uses webpack by default.
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 the perspective of building, Modern.js is divided into three layers, from top to bottom:
13
+ From a building perspective, Modern.js is divided into three layers, from top to bottom:
14
14
 
15
- - Upper-layer framework: Modern.js.
16
- - Universal build engine: Modern.js Builder.
17
- - Low-level bundlers: webpack and rspack.
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 provide a separate document for it, the site address is: [modernjs.dev/builder](https://modernjs.dev/builder).
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 document, you can learn about the detailed introduction of Modern.js Builder, and you can also find a complete usage guide for each building features. When you encounter building issues, it is recommended that you first read the Modern.js Builder documentation to solve them.
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 Config
27
+ ## Builder Configuration
28
28
 
29
- The config of Modern.js is inherited from Modern.js Builder, so you can use all build configs provided by Modern.js Builder in Modern.js.
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
- Take the `html.title` config of Modern.js Builder as an example, you can directly use this config in the `modern.config.ts` file, and it will be automatically passed to Modern.js Builder.
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 details of building configs, please refer to [「Modern.js Builder - Builder Config」](https://modernjs.dev/builder/en/guide/basic/builder-config.html).
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
- ## Building Features
43
+ ## Builder Capabilities
44
44
 
45
- Modern.js Builder provides a wealth of building features, including dozens of features such as JavaScript compilation, CSS compilation, static resource processing, hot module replacement, code compression, and TS type checking.
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 to read [「Modern.js Builder - All Features」](https://modernjs.dev/builder/en/guide/features.html) to learn all the building features provided by Modern.js Builder.
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
- # Entries
5
+ # Entry
6
6
 
7
- Through this chapter, you can learn about the entry convention in Modern.js and how to customize the entry.
7
+ In this chapter, you will learn about the entry convention in Modern.js and how to customize it.
8
8
 
9
- ## What is an Entry
9
+ ## What is Entry?
10
10
 
11
- **Entry is the starting module of a page.**
11
+ **Entry refers to the starting module of a page.**
12
12
 
13
- In the Modern.js project, each entry corresponds to an independent page, and also corresponds to a server route. By default, Modern.js will automatically determine the entry of the page based on the directory convention, and also supports customizing the entry through configuration items.
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 items 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.
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-entry (SPA), and the project structure is as follows:
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 entry. You can execute `pnpm run new` under the project to create entry through generator:
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 execution, Modern.js will automatically generate a new entry directory, and you can see that the `src/` directory has the following structure:
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 was moved to the directory with the same name as the `name` in the `package.json`, and a new directory was created.
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 executing `pnpm run dev`, you can see that a `/new-entry` route has been added, and the migrated code route has not changed.
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 the package.json file as the main entry, the route of the main entry is `/`, and the route of other entries is `/{entryName}`.
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 used as the main entry of the project.
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 Type
68
+ ## Entry Types
69
69
 
70
- Different entry types have different compile and run-time behaviors. When creating a project in Modern.js, developers can manually choose to create a project in **framework mode** or **build mode**. After the creation is complete, you can see that the project template files for different modes are different.
70
+ Different entry types have different compilation and runtime behaviors.
71
71
 
72
- By default, Modern.js will scan the files under `src/` before starting the project, identify the entry, and generate the corresponding server-side route.
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 change the entry directory to another directory through [source.entriesDir](/configure/app/source/entries-dir).
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 first-level directories under `src/` will become project entries, and the directory where the entry is located must meet one of the following four conditions:
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. Have a `routes/` directory
82
- 2. Has `App.[jt]sx?` file
83
- 3. Has `index.[jt]sx?` file
84
- 4. Has a `pages/` directory (Modern.js 1.0 compatible)
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 characteristics, Modern.js will consider the current project as a single-entry application.
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-entry applications, the default entry is named `main`.
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-entry application, Modern.js will further check the first-level directory under `src/`.
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 the capabilities of the Modern.js framework, such as Router, SSR, integrated calls, etc. Under this kind of entry agreement, the entry defined by the developer is not the real Webpack compilation entry. Modern.js will generate an encapsulated entry when it starts, and the real entry can be found in `node_modules/.modern/{entryName}/index.js`.
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/` at startup, and automatically generate client-side routes (react-router) based on file conventions. For example:
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
- For details, please refer to [routing](/guides/basic-features/routes#conventional-routing).
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, the developer can freely set the client route in this file, or not set the client route.
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 details, please refer to [routing](/guides/basic-features/routes#self-controlled-routing).
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 when the file defaults to exporting functions, Modern.js will pass the default bootstrap function as an imported parameter, and replace the default bootstrap with the exported function, so that developers can customize Mounting components to DOM nodes, or adding custom behavior before mounting. E.g:
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
- :::warning
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 the ability not to use any Modern.js runtime, and the developer defines the entry of the project Webpack completely by himself.
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` exists in the entry and there is no default export function, then this file is the real Webpack entry file. This is similar to [Create React App](https://github.com/facebook/create-react-app), you need to mount components to DOM nodes, add hot update code, etc. For example:
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 recommended** new project to use this method, this method loses some capabilities of the framework, such as the `runtime` configuration in the **`modern.config.js` file will no longer take effect**. But this method will be very useful when the project is migrated from other frameworks to Modern.js, such as CRA, or webpack that is manually built by yourself.
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
- ## Specify Entry Using Configuration
198
+ ## Specifying Entry Using Configuration
198
199
 
199
- Most existing projects are not built according to the directory convention of Modern.js. If you want to change to the directory structure agreed by Modern.js, there will be a certain migration cost.
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, instead of generating the entry using file conventions, you can manually configure the entry in `modern.config.[jt]s`.
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 Entries
217
+ ### Disable Default Entry Scanning
217
218
 
218
- When using a custom entry, part of the project structure may happen to hit the directory convention of Modern.js, but in fact this part of the directory is not the real entry.
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` config to disable default entry scanning rules. When you need to customize the entry, you generally need to use `disableDefaultEntries` with `entries`. In this way, some existing projects can be quickly migrated without modifying the directory structure.
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({
@@ -29,3 +29,11 @@ Please refer to [Modern.js Builder - Exceptions FAQ](https://modernjs.dev/builde
29
29
  - 'compilation' argument error when webpack compiling?
30
30
  - Compile error `You may need additional loader`?
31
31
  - Find `exports is not defined` runtime error?
32
+
33
+ ## HMR FAQ
34
+
35
+ Please refer to [Modern.js Builder - HMR FAQ](https://modernjs.dev/builder/guide/faq/hmr.html), such as:
36
+
37
+ - HMR not working when external React?
38
+ - HMR not working when setting filename hash in development mode?
39
+ - HMR not working when updating React components?
File without changes
@@ -0,0 +1,13 @@
1
+ ---
2
+ sidebar_label: cssModules
3
+ ---
4
+
5
+ # output.cssModules
6
+
7
+ :::tip
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [output.cssModules](https://modernjs.dev/builder/api/config-output.html#outputcssmodules)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/docs/zh/config/output/cssModules.md';
12
+
13
+ <Main />
@@ -14,7 +14,7 @@ Modern.js Builder 是 Modern.js 体系的核心组件之一,它是一个面向
14
14
 
15
15
  - 上层研发框架:Modern.js。
16
16
  - 通用构建引擎:Modern.js Builder。
17
- - 底层打包工具:webpack 和 rspack
17
+ - 底层打包工具:webpack 和 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
 
@@ -30,7 +30,7 @@ Modern.js 初始化的项目是单入口的(SPA),项目结构如下:
30
30
  └── tsconfig.json
31
31
  ```
32
32
 
33
- 在 Modern.js 项目中,你可以很方便的将单入口切换成多入口,直接在项目下执行 `pnpm run new`,通过生成器创建入口即可:
33
+ 在 Modern.js 项目中,你可以很方便的将单入口切换成多入口,直接在项目下执行 `pnpm run new`,根据提示创建入口即可:
34
34
 
35
35
  ```bash
36
36
  ? 请选择你想要的操作 创建工程元素
@@ -54,34 +54,38 @@ Modern.js 初始化的项目是单入口的(SPA),项目结构如下:
54
54
  └── page.tsx
55
55
  ```
56
56
 
57
- 原本的代码被移动到了和 `package.json` 中 `name` 同名的目录下,并创建了新的目录。
57
+ 原本的入口代码被移动到了和 `package.json` 中 `name` 同名的目录下,并创建了 `new-entry` 入口目录。
58
58
 
59
59
  执行 `pnpm run dev` 后,可以看到新增了一条名为 `/new-entry` 的路由,并且被迁移的代码路由并未发生变化。
60
60
 
61
61
  :::tip
62
- Modern.js 会将与 package.json 文件中 `name` 字段同名的入口作为主入口,主入口的路由为 `/`,其他入口的路由为 `/{entryName}`。
62
+ Modern.js 会将与 `package.json` 文件中 `name` 字段同名的入口作为主入口,主入口的路由为 `/`,其他入口的路由为 `/{entryName}`。
63
63
 
64
- 比如,package.json 中的 `name` 为 `myapp` 时,`src/myapp` 会作为项目的主入口。
64
+ 比如,`package.json` 中的 `name` 为 `myapp` 时,`src/myapp` 会作为项目的主入口。
65
65
 
66
66
  :::
67
67
 
68
68
  ## 入口类型
69
69
 
70
- 不同的入口类型具有不同的编译和运行时行为。在 Modern.js 创建项目时,开发者可以手动选择创建**框架模式**或是**构建模式**的项目。完成创建后,可以看到不同模式的项目样板文件是不同的。
70
+ 不同的入口类型具有不同的编译和运行时行为。
71
+
72
+ import EntryMode from '@site-docs/components/entry-mode.mdx';
73
+
74
+ <EntryMode />
71
75
 
72
76
  默认情况下,Modern.js 启动项目前会对 `src/` 下的文件进行扫描,识别入口,并生成对应的服务端路由。
73
77
 
74
78
  :::tip
75
- 可以通过 [source.entriesDir](/configure/app/source/entries-dir) 更改入口目录为其他目录。
79
+ 可以通过 [source.entriesDir](/configure/app/source/entries-dir) 修改页面的入口识别目录。
76
80
 
77
81
  :::
78
82
 
79
83
  并非 `src/` 下所有的一级目录都会成为项目入口, 入口所在目录必须满足以下四个条件之一:
80
84
 
81
- 1. 具有 `routes/` 目录
82
- 2. 具有 `App.[jt]sx?` 文件
83
- 3. 具有 `index.[jt]sx?` 文件
84
- 4. 具有 `pages/` 目录(兼容 Modern.js 1.0
85
+ 1. 具有 `routes/` 目录。
86
+ 2. 具有 `App.[jt]sx?` 文件。
87
+ 3. 具有 `index.[jt]sx?` 文件。
88
+ 4. 具有 `pages/` 目录(兼容 Modern.js 1.0)。
85
89
 
86
90
  当 `src/` 目录满足入口特征时,Modern.js 会认为当前项目为单入口应用。
87
91
 
@@ -94,7 +98,7 @@ Modern.js 会将与 package.json 文件中 `name` 字段同名的入口作为主
94
98
 
95
99
  ### 框架模式入口
96
100
 
97
- 框架模式指需要使用 Modern.js 框架能力,例如 Router、SSR、一体化调用等。这类入口约定下,开发者定义的入口并不是真正的 Webpack 编译入口。Modern.js 在启动时会生成一个封装过的入口,可以在 `node_modules/.modern/{entryName}/index.js` 找到真正的入口。
101
+ 框架模式指需要使用 Modern.js 框架能力,例如 Router、SSR、一体化调用等。这类入口约定下,开发者定义的入口并不是真正的 webpack 编译入口。Modern.js 在启动时会生成一个封装过的入口,可以在 `node_modules/.modern/{entryName}/index.js` 找到真正的入口。
98
102
 
99
103
  #### 约定式路由
100
104
 
@@ -135,7 +139,7 @@ export default () => {
135
139
 
136
140
  #### 自定义 Bootstrap
137
141
 
138
- 如果入口中存在 `index.[jt]sx` 文件,并且当文件默认导出函数时,Modern.js 会将默认的 bootstrap 函数作为入参传入,并用导出的函数替代默认的 bootstrap,这样开发者可以自定义将组件挂载到 DOM 节点上,或在挂载前添加自定义行为。例如:
142
+ 如果入口中存在 `index.[jt]sx` 文件,并且当文件默认导出函数时,Modern.js 会将默认的 `bootstrap` 函数作为入参传入,并用导出的函数替代默认的 `bootstrap`,这样开发者可以自定义将组件挂载到 DOM 节点上,或在挂载前添加自定义行为。例如:
139
143
 
140
144
  ```tsx
141
145
  export default (App: React.ComponentType, bootstrap: () => void) => {
@@ -178,9 +182,9 @@ export default AppWrapper;
178
182
 
179
183
  ### 构建模式入口
180
184
 
181
- 构建模式是指不使用任何 Modern.js 运行时的能力,完全由开发者自己定义项目 Webpack 的入口。
185
+ 构建模式是指不使用任何 Modern.js 运行时的能力,完全由开发者自己定义项目 webpack 的入口。
182
186
 
183
- 如果入口中存在 `index.[jt]sx` ,并且没有默认导出函数时,这时候该文件就是真正的 Webpack 入口文件。这里和 [Create React App](https://github.com/facebook/create-react-app) 类似,需要自己将组件挂载到 DOM 节点、添加热更新代码等。例如:
187
+ 如果入口中存在 `index.[jt]sx` ,并且没有默认导出函数时,这时候该文件就是真正的 webpack 入口文件。这里和 [Create React App](https://github.com/facebook/create-react-app) 类似,需要自己将组件挂载到 DOM 节点、添加热更新代码等。例如:
184
188
 
185
189
  ```js title=src/index.jsx
186
190
  import React from 'react';
@@ -29,3 +29,11 @@ sidebar_position: 3
29
29
  - webpack 编译出现 'compilation' argument 报错?
30
30
  - 编译时报错 `You may need additional loader`?
31
31
  - 打开页面后报错,提示 `exports is not defined`?
32
+
33
+ ## 热更新问题
34
+
35
+ 请参考 [「Modern.js Builder - 热更新问题」](https://modernjs.dev/builder/guide/faq/hmr.html),比如:
36
+
37
+ - 打包时 external React 后,热更新不生效?
38
+ - 开发环境设置文件名的 hash 后,热更新不生效?
39
+ - React 组件的热更新无法生效?
package/package.json CHANGED
@@ -15,13 +15,13 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-next-1686120584093",
18
+ "version": "0.0.0-next-1686150530663",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public"
22
22
  },
23
23
  "peerDependencies": {
24
- "@modern-js/builder-doc": "0.0.0-next-1686120584093"
24
+ "@modern-js/builder-doc": "0.0.0-next-1686150530663"
25
25
  },
26
26
  "devDependencies": {
27
27
  "classnames": "^2",
@@ -33,9 +33,9 @@
33
33
  "fs-extra": "^10",
34
34
  "@types/node": "^16",
35
35
  "@types/fs-extra": "^9",
36
- "@modern-js/builder-doc": "0.0.0-next-1686120584093",
37
- "@modern-js/doc-tools": "0.0.0-next-1686120584093",
38
- "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686120584093"
36
+ "@modern-js/builder-doc": "0.0.0-next-1686150530663",
37
+ "@modern-js/doc-tools": "0.0.0-next-1686150530663",
38
+ "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686150530663"
39
39
  },
40
40
  "scripts": {
41
41
  "dev": "modern dev",