@modern-js/main-doc 0.0.0-next-20221203140534 → 0.0.0-next-20221205074243

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +0 -2
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +17 -3
  4. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/builder.md +46 -0
  5. package/en/docusaurus-plugin-content-docs/current.json +18 -18
  6. package/package.json +3 -3
  7. package/zh/apis/app/commands/new.md +0 -2
  8. package/zh/apis/app/runtime/app/_category_.json +1 -1
  9. package/zh/apis/app/runtime/bff/_category_.json +1 -1
  10. package/zh/apis/app/runtime/core/_category_.json +1 -1
  11. package/zh/apis/app/runtime/core/bootstrap.md +17 -3
  12. package/zh/apis/app/runtime/model/_category_.json +1 -1
  13. package/zh/apis/app/runtime/router/_category_.json +1 -1
  14. package/zh/apis/app/runtime/ssr/_category_.json +1 -1
  15. package/zh/apis/app/runtime/testing/_category_.json +1 -1
  16. package/zh/apis/app/runtime/utility/_category_.json +1 -1
  17. package/zh/apis/app/runtime/web-server/_category_.json +1 -1
  18. package/zh/configure/app/output/ssg.md +118 -114
  19. package/zh/configure/app/server/ssr.md +0 -2
  20. package/zh/guides/advanced-features/custom-app.md +8 -2
  21. package/zh/guides/advanced-features/ssg.md +74 -63
  22. package/zh/guides/advanced-features/ssr.md +76 -11
  23. package/zh/guides/basic-features/builder.md +46 -0
  24. package/zh/guides/basic-features/css/_category_.json +1 -1
  25. package/zh/guides/basic-features/css/less-sass.md +1 -14
  26. package/zh/guides/basic-features/data-fetch.md +1 -1
  27. package/zh/guides/basic-features/routes.md +32 -35
  28. package/zh/guides/concept/entries.md +4 -4
  29. package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +2 -2
  30. package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +5 -2
  31. package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +4 -6
  32. package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +2 -4
  33. package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +1 -1
  34. package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +44 -50
  35. package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +1 -1
  36. package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +4 -4
  37. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +8 -21
  38. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +37 -13
  39. package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +3 -13
  40. package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +1 -21
  41. package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +9 -9
  42. package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +9 -14
  43. package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +7 -7
  44. package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +1 -1
  45. package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +2 -2
  46. package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +8 -17
  47. package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +23 -18
  48. package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +30 -30
  49. package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +4 -9
  50. package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +66 -63
  51. package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +35 -33
  52. package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +28 -102
  53. package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +4 -6
  54. package/zh/tutorials/first-app/c10-model/10.2-add-model.md +3 -3
  55. package/zh/tutorials/first-app/c10-model/10.3-use-model.md +21 -20
  56. package/zh/tutorials/first-app/c10-model/10.4-testing.md +2 -2
  57. package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +34 -68
  58. package/zh/tutorials/first-app/c11-container/11.2-add-container.md +40 -37
  59. package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +6 -4
  60. package/zh/tutorials/first-app/c11-container/11.4-testing.md +2 -2
  61. package/zh/tutorials/foundations/introduction.md +1 -1
  62. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/default-alias.md +0 -25
  63. package/zh/apis/app/runtime/default-alias.md +0 -23
  64. package/zh/guides/basic-features/image.md +0 -43
  65. package/zh/guides/topic-detail/compile-speed.md +0 -182
  66. package/zh/guides/troubleshooting/compile.md +0 -379
  67. package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -310
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-20221203140534
3
+ ## 0.0.0-next-20221205074243
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -21,4 +21,4 @@
21
21
  - Updated dependencies [3fae2d03b]
22
22
  - Updated dependencies [df41d71ad]
23
23
  - Updated dependencies [14b712da8]
24
- - @modern-js/builder-doc@0.0.0-next-20221203140534
24
+ - @modern-js/builder-doc@0.0.0-next-20221205074243
@@ -43,8 +43,6 @@ $ npx modern new
43
43
  ? 请选择你想要的操作 启用可选功能
44
44
  ? 启用可选功能 (Use arrow keys)
45
45
  ❯ 启用 Tailwind CSS 支持
46
- 启用 Less 支持
47
- 启用 Sass 支持
48
46
  启用「BFF」功能
49
47
  启用「微前端」模式
50
48
  启用「单元测试 / 集成测试」功能
@@ -7,25 +7,39 @@ Used to start and mount App, usually without manual calls。This API is only req
7
7
  ## Usage
8
8
 
9
9
  ```ts
10
+ import ReactDOM from 'react-dom/client'
10
11
  import { bootstrap } from '@modern-js/runtime';
11
12
 
12
- bootstrap(App, 'root');
13
+ bootstrap(App, 'root', undefined, ReactDOM);
13
14
  ```
14
15
 
15
16
  ## Function Signature
16
17
 
17
18
  ```ts
18
- function bootstrap(AppComponent: React.ComponentType<any>, rootId: string): React.ComponentType<any> | void
19
+ type BootStrap<T = unknown> = (
20
+ App: React.ComponentType,
21
+ id: string | HTMLElement | RuntimeContext,
22
+ root?: any,
23
+ ReactDOM?: {
24
+ render?: Renderer;
25
+ hydrate?: Renderer;
26
+ createRoot?: typeof createRoot;
27
+ hydrateRoot?: typeof hydrateRoot;
28
+ },
29
+ ) => Promise<T>;
19
30
  ```
20
31
 
21
32
  ### Input
22
33
 
23
34
  - `AppComponent`: reactElement instance created by [`createApp`](./create-app).
24
35
  - `rootId`: DOM root element id to mount,like `"root"`.
36
+ - `root`: ReactDOM.create the return value, which is used in the scenario where the root needs to destroy the component outside the bootstrap function.
37
+ - `ReactDOM`: ReactDOM object for distinguishing between React 18 and React 17 APIs.
25
38
 
26
39
  ## Example
27
40
 
28
41
  ```tsx
42
+ import ReactDOM from 'react-dom/client'
29
43
  import { createApp, bootstrap } from '@modern-js/runtime';
30
44
  import { router, state } from '@modern-js/runtime/plugins';
31
45
 
@@ -38,7 +52,7 @@ const WrappedApp = createApp({
38
52
  plugins: [router({}), state({})],
39
53
  })(App);
40
54
 
41
- bootstrap(WrappedApp, 'root');
55
+ bootstrap(WrappedApp, 'root', undefined, ReactDOM);
42
56
 
43
57
  ```
44
58
 
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Builder
3
+ sidebar_position: 2
4
+ ---
5
+
6
+ **Modern.js uses [Modern.js Builder](https://modernjs.dev/builder) to build your Web APP. **
7
+
8
+ Modern.js Builder is one of the core components of Modern.js. It is a build engine for modern 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
+
10
+ ## Build Architecture
11
+
12
+ From the perspective of building, Modern.js is divided into three layers, from top to bottom:
13
+
14
+ - Upper-layer framework: Modern.js.
15
+ - Universal build engine: Modern.js Builder.
16
+ - Low-level bundlers: webpack and rspack.
17
+
18
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-1117.png" style={{ maxWidth: '540px' }} />
19
+
20
+ ## Builder Documentation
21
+
22
+ 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
+
24
+ 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
+
26
+ ## Builder Config
27
+
28
+ 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
+
30
+ 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
+
32
+ ```ts title="modern.config.js"
33
+ export default defineConfig({
34
+ html: {
35
+ title: 'example',
36
+ },
37
+ });
38
+ ```
39
+
40
+ For details of building configs, please refer to [「Modern.js Builder - Builder Config」](https://modernjs.dev/builder/en/guide/basic/builder-config.html).
41
+
42
+ ## Building Features
43
+
44
+ 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
+
46
+ 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.
@@ -179,44 +179,44 @@
179
179
  "message": "Runtime",
180
180
  "description": "The label for category runtime in sidebar apisAppSidebar"
181
181
  },
182
- "sidebar.apisAppSidebar.category.核心 API": {
183
- "message": "Core API",
182
+ "sidebar.apisAppSidebar.category.核心": {
183
+ "message": "Core",
184
184
  "description": "The label for category Core API in sidebar apisAppSidebar"
185
185
  },
186
- "sidebar.apisAppSidebar.category.App API": {
187
- "message": "App API",
186
+ "sidebar.apisAppSidebar.category.App": {
187
+ "message": "App",
188
188
  "description": "The label for category App API in sidebar apisAppSidebar"
189
189
  },
190
- "sidebar.apisAppSidebar.category.BFF Server API": {
191
- "message": "BFF Server API",
190
+ "sidebar.apisAppSidebar.category.BFF Server": {
191
+ "message": "BFF Server",
192
192
  "description": "The label for category BFF Server API in sidebar apisAppSidebar"
193
193
  },
194
- "sidebar.apisAppSidebar.category.Model API": {
195
- "message": "Model API",
194
+ "sidebar.apisAppSidebar.category.Model": {
195
+ "message": "Model",
196
196
  "description": "The label for category Model API in sidebar apisAppSidebar"
197
197
  },
198
- "sidebar.apisAppSidebar.category.Container API": {
199
- "message": "Container API",
198
+ "sidebar.apisAppSidebar.category.Container": {
199
+ "message": "Container",
200
200
  "description": "The label for category Container API in sidebar apisAppSidebar"
201
201
  },
202
- "sidebar.apisAppSidebar.category.Testing API": {
203
- "message": "Testing API",
202
+ "sidebar.apisAppSidebar.category.Testing": {
203
+ "message": "Testing",
204
204
  "description": "The label for category Testing API in sidebar apisAppSidebar"
205
205
  },
206
- "sidebar.apisAppSidebar.category.Web Server API": {
207
- "message": "Web Server API",
206
+ "sidebar.apisAppSidebar.category.Web Server": {
207
+ "message": "Web Server",
208
208
  "description": "The label for category Web Server API in sidebar apisAppSidebar"
209
209
  },
210
- "sidebar.apisAppSidebar.category.Utility API": {
211
- "message": "Utility API",
210
+ "sidebar.apisAppSidebar.category.Utility": {
211
+ "message": "Utility",
212
212
  "description": "The label for category Utility API in sidebar apisAppSidebar"
213
213
  },
214
214
  "sidebar.apisAppSidebar.category.loadable": {
215
215
  "message": "loadable",
216
216
  "description": "The label for category loadable in sidebar apisAppSidebar"
217
217
  },
218
- "sidebar.apisAppSidebar.category.插件 API": {
219
- "message": "插件 API",
218
+ "sidebar.apisAppSidebar.category.插件": {
219
+ "message": "插件",
220
220
  "description": "The label for category 插件 API in sidebar apisAppSidebar"
221
221
  },
222
222
  "sidebar.apisMonorepoSidebar.category.文件约定": {
package/package.json CHANGED
@@ -11,20 +11,20 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-20221203140534",
14
+ "version": "0.0.0-next-20221205074243",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-20221203140534"
20
+ "@modern-js/builder-doc": "0.0.0-next-20221205074243"
21
21
  },
22
22
  "devDependencies": {
23
23
  "ts-node": "^10",
24
24
  "fs-extra": "^10",
25
25
  "@types/node": "^16",
26
26
  "@types/fs-extra": "^9",
27
- "@modern-js/builder-doc": "0.0.0-next-20221203140534"
27
+ "@modern-js/builder-doc": "0.0.0-next-20221205074243"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "npx ts-node ./scripts/sync.ts"
@@ -43,8 +43,6 @@ $ npx modern new
43
43
  ? 请选择你想要的操作 启用可选功能
44
44
  ? 启用可选功能 (Use arrow keys)
45
45
  ❯ 启用 Tailwind CSS 支持
46
- 启用 Less 支持
47
- 启用 Sass 支持
48
46
  启用「BFF」功能
49
47
  启用「微前端」模式
50
48
  启用「单元测试 / 集成测试」功能
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "APP API",
2
+ "label": "APP",
3
3
  "position": 4
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "BFF API",
2
+ "label": "BFF",
3
3
  "position": 8
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "核心 API",
2
+ "label": "核心",
3
3
  "position": 3
4
4
  }
@@ -7,25 +7,39 @@ title: bootstrap
7
7
  ## 使用姿势
8
8
 
9
9
  ```ts
10
+ import ReactDOM from 'react-dom/client'
10
11
  import { bootstrap } from '@modern-js/runtime';
11
12
 
12
- bootstrap(App, 'root');
13
+ bootstrap(App, 'root', undefined, ReactDOM);
13
14
  ```
14
15
 
15
16
  ## 函数签名
16
17
 
17
18
  ```ts
18
- function bootstrap(AppComponent: React.ComponentType<any>, rootId: string): React.ComponentType<any> | void
19
+ type BootStrap<T = unknown> = (
20
+ App: React.ComponentType,
21
+ id: string | HTMLElement | RuntimeContext,
22
+ root?: any,
23
+ ReactDOM?: {
24
+ render?: Renderer;
25
+ hydrate?: Renderer;
26
+ createRoot?: typeof createRoot;
27
+ hydrateRoot?: typeof hydrateRoot;
28
+ },
29
+ ) => Promise<T>;
19
30
  ```
20
31
 
21
32
  ### 参数
22
33
 
23
34
  - `AppComponent`:通过 [`createApp`](./create-app) 创建的 ReactElement 实例。
24
35
  - `rootId`:要挂载的 DOM 根元素 id,如 `"root"`。
36
+ - `root`: ReactDOM.createRoot 的返回值,用于 bootstrap 函数外需要 root 销毁组件的场景。
37
+ - `ReactDOM`: ReactDOM 对象,用于区分 React 18 和 React 17 API。
25
38
 
26
39
  ## 示例
27
40
 
28
41
  ```tsx
42
+ import ReactDOM from 'react-dom/client'
29
43
  import { createApp, bootstrap } from '@modern-js/runtime';
30
44
  import { router, state } from '@modern-js/runtime/plugins';
31
45
 
@@ -38,7 +52,7 @@ const WrappedApp = createApp({
38
52
  plugins: [router({}), state({})],
39
53
  })(App);
40
54
 
41
- bootstrap(WrappedApp, 'root');
55
+ bootstrap(WrappedApp, 'root', undefined, ReactDOM);
42
56
 
43
57
  ```
44
58
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "Model API",
2
+ "label": "Model",
3
3
  "position": 6
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "Router API",
2
+ "label": "Router",
3
3
  "position": 5
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "SSR API",
2
+ "label": "SSR",
3
3
  "position": 7
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "Testing API",
2
+ "label": "Testing",
3
3
  "position": 11
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "Utility API",
2
+ "label": "Utility",
3
3
  "position": 10
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "label": "Web Server API",
2
+ "label": "Web Server",
3
3
  "position": 9
4
4
  }