@modern-js/main-doc 2.34.0 → 2.35.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/docs/en/apis/app/commands.mdx +12 -11
  2. package/docs/en/apis/app/hooks/config/public.mdx +2 -2
  3. package/docs/en/apis/app/hooks/config/upload.mdx +3 -3
  4. package/docs/en/components/debug-app.mdx +1 -3
  5. package/docs/en/components/global-proxy-config.mdx +4 -13
  6. package/docs/en/components/global-proxy.mdx +2 -4
  7. package/docs/en/components/init-app.mdx +1 -1
  8. package/docs/en/components/tech-stack-node-framework.mdx +1 -0
  9. package/docs/en/configure/app/builder-plugins.mdx +2 -2
  10. package/docs/en/configure/app/plugins.mdx +3 -4
  11. package/docs/en/configure/app/server/base-url.mdx +0 -2
  12. package/docs/en/configure/app/source/config-dir.mdx +2 -2
  13. package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
  14. package/docs/en/guides/advanced-features/eslint.mdx +1 -1
  15. package/docs/en/guides/basic-features/alias.mdx +12 -51
  16. package/docs/en/guides/basic-features/css.mdx +35 -15
  17. package/docs/en/guides/basic-features/data-fetch.mdx +12 -12
  18. package/docs/en/guides/basic-features/env-vars.mdx +1 -1
  19. package/docs/en/guides/basic-features/html.mdx +2 -2
  20. package/docs/en/guides/basic-features/routes.mdx +31 -19
  21. package/docs/en/guides/concept/builder.mdx +1 -1
  22. package/docs/en/guides/get-started/glossary.mdx +1 -1
  23. package/docs/en/guides/get-started/introduction.mdx +21 -1
  24. package/docs/en/guides/get-started/quick-start.mdx +8 -17
  25. package/docs/en/guides/get-started/tech-stack.mdx +138 -0
  26. package/docs/en/guides/get-started/upgrade.mdx +10 -4
  27. package/docs/en/guides/topic-detail/changesets/add.mdx +1 -1
  28. package/docs/en/guides/topic-detail/changesets/changelog.mdx +3 -3
  29. package/docs/en/guides/topic-detail/changesets/commit.mdx +3 -3
  30. package/docs/en/guides/topic-detail/changesets/release-note.mdx +3 -3
  31. package/docs/en/guides/topic-detail/changesets/release.mdx +1 -1
  32. package/docs/en/guides/topic-detail/framework-plugin/implement.mdx +6 -4
  33. package/docs/en/guides/topic-detail/generator/create/use.mdx +1 -9
  34. package/docs/en/guides/topic-detail/generator/plugin/context.md +1 -1
  35. package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -0
  36. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +24 -17
  37. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +51 -37
  38. package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +1 -0
  39. package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
  40. package/docs/en/tutorials/first-app/c02-component.mdx +4 -3
  41. package/docs/zh/apis/app/commands.mdx +10 -9
  42. package/docs/zh/apis/app/hooks/api/api.mdx +2 -1
  43. package/docs/zh/apis/app/hooks/server/index_.mdx +2 -1
  44. package/docs/zh/community/blog/2022-0708-updates.md +4 -4
  45. package/docs/zh/community/blog/overview.md +1 -1
  46. package/docs/zh/components/debug-app.mdx +1 -3
  47. package/docs/zh/components/global-proxy-config.mdx +4 -13
  48. package/docs/zh/components/global-proxy.mdx +2 -4
  49. package/docs/zh/components/tech-stack-node-framework.mdx +1 -0
  50. package/docs/zh/configure/app/builder-plugins.mdx +1 -1
  51. package/docs/zh/configure/app/plugins.mdx +1 -2
  52. package/docs/zh/configure/app/server/base-url.mdx +0 -2
  53. package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
  54. package/docs/zh/guides/advanced-features/eslint.mdx +1 -1
  55. package/docs/zh/guides/basic-features/alias.mdx +12 -51
  56. package/docs/zh/guides/basic-features/css.mdx +35 -15
  57. package/docs/zh/guides/basic-features/data-fetch.mdx +11 -12
  58. package/docs/zh/guides/basic-features/html.mdx +4 -5
  59. package/docs/zh/guides/basic-features/routes.mdx +26 -19
  60. package/docs/zh/guides/get-started/introduction.mdx +20 -0
  61. package/docs/zh/guides/get-started/quick-start.mdx +8 -17
  62. package/docs/zh/guides/get-started/tech-stack.mdx +138 -0
  63. package/docs/zh/guides/get-started/upgrade.mdx +10 -4
  64. package/docs/zh/guides/topic-detail/changesets/add.mdx +1 -1
  65. package/docs/zh/guides/topic-detail/changesets/changelog.mdx +3 -3
  66. package/docs/zh/guides/topic-detail/changesets/commit.mdx +3 -3
  67. package/docs/zh/guides/topic-detail/changesets/release-note.mdx +3 -3
  68. package/docs/zh/guides/topic-detail/changesets/release.mdx +1 -1
  69. package/docs/zh/guides/topic-detail/framework-plugin/hook-list.mdx +1 -1
  70. package/docs/zh/guides/topic-detail/framework-plugin/implement.mdx +7 -5
  71. package/docs/zh/guides/topic-detail/generator/create/use.mdx +0 -8
  72. package/docs/zh/guides/topic-detail/generator/plugin/context.md +1 -1
  73. package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +45 -21
  74. package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +51 -33
  75. package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +1 -0
  76. package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -0
  77. package/docs/zh/tutorials/first-app/c02-component.mdx +4 -3
  78. package/package.json +7 -7
@@ -64,7 +64,7 @@ With SSR, the server generates HTML that already contains dynamic content and se
64
64
 
65
65
  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.
66
66
 
67
- 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.
67
+ 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 assets service.
68
68
 
69
69
  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.
70
70
 
@@ -66,6 +66,26 @@ It mainly includes the following features:
66
66
  - 🌏 **Ecology**: Self-developed state management, micro-frontend, module packaging, Monorepo solutions, and other peripheral needs.
67
67
  - 🕸 **Routing Modes**: Includes self-controlled routing, file-convention-based routing (nested routing), etc.
68
68
 
69
- ## Next
69
+ ## Comparison with Others
70
+
71
+ ### Next.js
72
+
73
+ Next.js is one of the most popular React frameworks in the community. It is developed by Vercel.
74
+
75
+ Next.js defaults to using React Server Components, which means **you will need to render your web application on the server and pay for the server-side rendering costs**. In addition, Server Components is not yet a stable technology, and many popular React libraries in the community have not yet finished adapting to RSC. At this stage, you may need to use the Next.js's Pages Router to avoid issues caused by Server Components.
76
+
77
+ If you want to build a single-page application (SPA) and render it on the client side, Next.js may not be the best choice because many of its features are designed around server-first principles. If you need to use client-side rendering, you can only use limited functionality through Next.js's "static exports" feature.
78
+
79
+ On the other hand, Modern.js considers both client-side rendering (CSR) and server-side rendering (SSR) to be equally important. When you build a Modern.js application, it defaults to client-side rendering, and you don't need to understand the uses and limitations of Server Components. You can also enable SSR whenever you need it, and even enable SSR for specific pages. The whole process is fully progressive. Please note that Modern.js does not currently support Server Components. We will continue to monitor its potential and provide support when appropriate.
80
+
81
+ ### Umi
82
+
83
+ Umi is a popular React framework in the Chinese community and serves as the underlying frontend framework for the Ant Group. Modern.js and Umi share many similarities, such as support for plugin system, convention-based routing, and micro-generators.
84
+
85
+ **The main difference between Modern.js and Umi is their approach to optimizing build speed**. Umi uses MFSU technology to improve build speed, while Modern.js uses Rspack to achieve 5 to 10 times faster build speed. From our perspective, Rust tools like Rspack are more in line with the long-term evolution of the front-end toolchain, as they can strike a good balance between performance, stability, and ecosystem compatibility.
86
+
87
+ In addition, Modern.js provides richer server-side features, including comprehensive SSR capabilities, integrated BFF development capabilities, and support for custom web servers. These capabilities have been extensively validated by ByteDance in numerous online applications and can be directly used in production environments.
88
+
89
+ ## Next Step
70
90
 
71
91
  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.
@@ -91,23 +91,15 @@ $ pnpm run build
91
91
 
92
92
  > modern build
93
93
 
94
- info Create a production build...
95
-
96
- info File sizes after production build:
94
+ info Staring production build...
95
+ ready Client compiled in 50ms
96
+ info Production file sizes:
97
97
 
98
98
  File Size Gzipped
99
- dist/static/js/lib-corejs.ffeb7fb8.js 214.96 kB 67.23 kB
100
- dist/static/js/lib-react.09721b5c.js 152.61 kB 49.02 kB
101
- dist/static/js/218.102e2f39.js 85.45 kB 28.5 kB
102
- dist/static/js/lib-babel.a7bba875.js 11.93 kB 3.95 kB
103
- dist/html/main/index.html 5.84 kB 2.57 kB
104
- dist/static/js/main.3568a38e.js 3.57 kB 1.44 kB
105
- dist/static/css/async/304.c3c481a5.css 2.62 kB 874 B
106
- dist/asset-manifest.json 1.48 kB 349 B
107
- dist/static/js/async/304.c45706bc.js 1.4 kB 575 B
108
- dist/static/js/async/509.fcb06e14.js 283 B 230 B
109
-
110
- Client ✔ done in 3.57s
99
+ dist/static/js/lib-react.09721b5c.js 152.6 kB 49.0 kB
100
+ dist/html/main/index.html 5.8 kB 2.5 kB
101
+ dist/static/js/main.3568a38e.js 3.5 kB 1.4 kB
102
+ dist/static/css/main.03221f72.css 1.4 kB 741 B
111
103
  ```
112
104
 
113
105
  By default, the build artifacts are generated in `dist/`, with the following directory structure:
@@ -135,8 +127,7 @@ $ pnpm run serve
135
127
 
136
128
  > modern serve
137
129
 
138
- Starting the modern server...
139
- info App running at:
130
+ info Starting production server...
140
131
 
141
132
  > Local: http://localhost:8080/
142
133
  > Network: http://192.168.0.1:8080/
@@ -0,0 +1,138 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Tech Stack
6
+
7
+ The Modern.js framework comes with built-in popular libraries and development tools from the community.
8
+
9
+ In this document, you can learn about the main technology stack involved in the Modern.js framework, as well as some optional libraries and tools.
10
+
11
+ ---
12
+
13
+ ## UI Library
14
+
15
+ Modern.js uses [React 18](https://react.dev/) to build user interfaces and is also compatible with React 17.
16
+
17
+ The underlying Builder of Modern.js also supports building Vue applications. If you need to use Vue, you can refer to ["Building Vue App"](https://modernjs.dev/builder/en/guide/framework/vue3.html).
18
+
19
+ ---
20
+
21
+ ## Routing
22
+
23
+ Modern.js uses [React Router 6](https://reactrouter.com/en/main) for routing and is also compatible with React Router 5.
24
+
25
+ Modern.js supports conventional routing, self-controlled routing, or other routing schemes. Please refer to ["Routing"](/en/guides/basic-features/routes) to make your choice.
26
+
27
+ ---
28
+
29
+ ## Micro Frontends
30
+
31
+ Modern.js provides out-of-the-box support for the [Garfish](https://www.garfishjs.org/) micro frontend framework.
32
+
33
+ We are also working with Zack Jackson, the author of [Module Federation](https://webpack.js.org/concepts/module-federation/), to provide a more comprehensive solution.
34
+
35
+ ---
36
+
37
+ ## State Management
38
+
39
+ Modern.js can be used with any community state management library, such as [Redux](https://redux.js.org/), [Jotai](https://jotai.org/), [Zustand](https://docs.pmnd.rs/zustand), [Valtio](https://valtio.pmnd.rs/), and more.
40
+
41
+ Modern.js also provides a wrapper around Redux called Reduck for state management. You can refer to ["Reduck State Management"](/en/guides/topic-detail/model/quick-start) for usage.
42
+
43
+ ---
44
+
45
+ ## Package Manager
46
+
47
+ Modern.js can be used with any community package manager, such as [npm](https://www.npmjs.com/package/npm), [yarn](https://classic.yarnpkg.com/lang/en/), [pnpm](https://pnpm.io/), or [Bun](https://bun.sh/).
48
+
49
+ We recommend using pnpm for faster installation speed.
50
+
51
+ ---
52
+
53
+ ## Bundler
54
+
55
+ Modern.js uses [Webpack 5](https://webpack.js.org/) or [Rspack](https://www.rspack.dev/) to bundle your web applications.
56
+
57
+ The default bundler used is Webpack 5. You can refer to ["Using Rspack"](/en/guides/advanced-features/rspack-start) to switch to the faster Rspack.
58
+
59
+ ---
60
+
61
+ ## Transpiler
62
+
63
+ Modern.js uses [Babel](https://babeljs.io/), [SWC](https://swc.rs/), or [esbuild](https://esbuild.github.io/) as JavaScript transpiler to transform TypeScript or JSX into JavaScript code that can run in browsers and perform syntax downgrades.
64
+
65
+ - When using Webpack for bundling, the default tool is Babel, which can be switched to SWC or esbuild.
66
+ - When using Rspack for bundling, the default tool is SWC, which can be switched to Babel.
67
+
68
+ ---
69
+
70
+ ## Minimizer
71
+
72
+ During production builds, Modern.js uses [Terser](https://github.com/terser/terser), [SWC](https://swc.rs/), or [esbuild](https://esbuild.github.io/) to minify JavaScript code, and [cssnano](https://cssnano.co/) to minify CSS code.
73
+
74
+ - When using Webpack for bundling, the default tool for minifying JS code is Terser, which can be switched to SWC or esbuild.
75
+ - When using Rspack for bundling, the default tool for minifying JS code is SWC, and switching to other tools is not currently supported.
76
+
77
+ ---
78
+
79
+ ## CSS Transformer
80
+
81
+ Modern.js uses [PostCSS](https://postcss.org/) to transform CSS code and enables [autoprefixer](https://github.com/postcss/autoprefixer) by default to add CSS prefixes.
82
+
83
+ Modern.js supports enabling ["Tailwind CSS"](/en/guides/basic-features/css.html#using-tailwind-css) and is compatible with both Tailwind CSS v2 and v3.
84
+
85
+ ---
86
+
87
+ ## CSS Preprocessors
88
+
89
+ Modern.js supports three CSS preprocessors: [Sass](https://sass-lang.com/), [Less](https://lesscss.org/), and [Stylus](https://stylus-lang.com/):
90
+
91
+ - Sass and Less are supported by default and ready to use.
92
+ - Stylus is optional and can be used by referring to the ["Stylus Plugin"](https://modernjs.dev/builder/en/plugins/plugin-stylus.html).
93
+
94
+ ---
95
+
96
+ ## CSS Modules
97
+
98
+ Modern.js provides out-of-the-box support for [CSS Modules](https://github.com/css-modules/css-modules), which is implemented internally based on [css-loader](https://www.npmjs.com/package/css-loader).
99
+
100
+ Please refer to ["Use CSS Modules"](https://modernjs.dev/builder/en/guide/basic/css-modules.html) for usage instructions.
101
+
102
+ ---
103
+
104
+ ## CSS-in-JS
105
+
106
+ Modern.js supports the use of [styled-components](https://styled-components.com/). Please refer to ["Using CSS-in-JS"](/en/guides/basic-features/css.html#using-css-in-js) for usage instructions.
107
+
108
+ If you need to use other CSS-in-JS solutions, you can integrate them into your project on your own.
109
+
110
+ ---
111
+
112
+ ## Testing Framework
113
+
114
+ Modern.js supports the use of [Jest](https://jestjs.io/) for unit testing or integration testing. This feature is optional. Please refer to ["Using Jest"](/en/guides/advanced-features/testing) to enable it.
115
+
116
+ If you need to use [Vitest](https://vitest.dev/) or other testing frameworks, you can integrate them into your project on your own.
117
+
118
+ ---
119
+
120
+ ## UI Components
121
+
122
+ Modern.js can be used with any React UI component library from the community, such as [MUI](https://mui.com/), [Ant Design](https://ant.design/), [Arco Design](https://github.com/arco-design/arco-design), [Semi Design](https://semi.design/), [Radix UI](https://www.radix-ui.com/), and more.
123
+
124
+ Additionally, Modern.js provides built-in support for [on-demand import](/configure/app/source/transform-import) of Ant Design and Arco Design.
125
+
126
+ ---
127
+
128
+ ## Component Development
129
+
130
+ Modern.js supports the use of [Storybook](https://storybook.js.org/) for developing UI components. This feature is optional. Please refer to ["Using Storybook"](/en/guides/advanced-features/using-storybook) to enable it.
131
+
132
+ ---
133
+
134
+ ## Node.js Framework
135
+
136
+ import TechStackNodeFramework from '@site-docs-en/components/tech-stack-node-framework';
137
+
138
+ <TechStackNodeFramework />
@@ -8,11 +8,13 @@ sidebar_position: 3
8
8
 
9
9
  Modern.js provides the `upgrade` command to support upgrading the project to the latest version of Modern.js.
10
10
 
11
- Run `pnpm run upgrade` in the project:
11
+ Run the `upgrade` script in the project:
12
12
 
13
- ```bash
14
- $ pnpm run upgrade
13
+ import { PackageManagerTabs } from '@theme';
14
+
15
+ <PackageManagerTabs command="run upgrade" />
15
16
 
17
+ ```bash
16
18
  > modern upgrade
17
19
 
18
20
  [INFO] [Project Type]: Web App
@@ -22,11 +24,15 @@ $ pnpm run upgrade
22
24
 
23
25
  You can see that the dependencies in the project's `package.json` have been updated to the latest version.
24
26
 
27
+ :::tip
28
+ If the `upgrade` command is not declared in the project's `package.json`, you can execute `npx modern upgrade` as an equivalent alternative.
29
+ :::
30
+
25
31
  ## Upgrade to a specified version
26
32
 
27
33
  All packages of Modern.js are currently released with a **uniform version number**.
28
34
 
29
- import ReleaseNote from "@site-docs-en/components/release-note"
35
+ import ReleaseNote from '@site-docs-en/components/release-note';
30
36
 
31
37
  <ReleaseNote />
32
38
 
@@ -22,7 +22,7 @@ A changeset includes:
22
22
  The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
23
23
  :::
24
24
 
25
- ### NPM Module
25
+ ### Modern.js Module
26
26
 
27
27
  #### Run the change command in the root directory:
28
28
 
@@ -160,11 +160,11 @@ Configure `changlog` as `./my-changelog-config.js`:
160
160
  }
161
161
  ```
162
162
 
163
- ### Using Npm Module
163
+ ### Using Modern.js Module
164
164
 
165
- Customizing changelog can also be managed using the NPM module project to provide a common solution.
165
+ Customizing changelog can also be managed using the Modern.js Module to provide a common solution.
166
166
 
167
- #### Use `npx @modern-js/create@latest` to create a module project.
167
+ #### Use `npx @modern-js/create@latest` to create a Modern.js Module.
168
168
 
169
169
  ```md
170
170
  ? Please select the type of project you want to create: Npm Module
@@ -191,11 +191,11 @@ Configure `commit` as `./my-commit-config.js`:
191
191
  }
192
192
  ```
193
193
 
194
- ### Using NPM Module
194
+ ### Using Modern.js Module
195
195
 
196
- Customizing commit can also be managed using the NPM module project to provide a common solution.
196
+ Customizing commit can also be managed using the Modern.js Module to provide a common solution.
197
197
 
198
- #### Use `npx @modern-js/create@latest` to create a module project
198
+ #### Use `npx @modern-js/create@latest` to create a mModern.js Module
199
199
 
200
200
  ```md
201
201
  ? Please select the type of project you want to create: Npm Module
@@ -204,11 +204,11 @@ You can also define the command parameters directly in `package.json`:
204
204
 
205
205
  Run the command `pnpm run gen-release-note` directly.
206
206
 
207
- ### Using NPM Module
207
+ ### Using Modern.js Module
208
208
 
209
- Customizing release note can also be managed using the NPM module project to provide a common solution.
209
+ Customizing release note can also be managed using the Modern.js Module to provide a common solution.
210
210
 
211
- #### Use `npx @modern-js/create@latest` to create a module project
211
+ #### Use `npx @modern-js/create@latest` to create a Modern.js Module
212
212
 
213
213
  ```md
214
214
  ? Please select the type of project you want to create: Npm Module
@@ -13,7 +13,7 @@ The following example commands are all using pnpm. If you need to use other pack
13
13
 
14
14
  :::
15
15
 
16
- ### Npm Module
16
+ ### Modern.js Module
17
17
 
18
18
  #### Run the bump command in the root directory
19
19
 
@@ -33,7 +33,7 @@ In addition, plugins allow configuration of the execution order with other plugi
33
33
 
34
34
  ### Plugin Types
35
35
 
36
- Modern.js supports various types of project development, such as application development (`app-tools`), module development (`module-tools`), etc.
36
+ Modern.js supports various types of project development, such as application development (Modern.js Framework), module development (Modern.js Module), etc.
37
37
 
38
38
  To balance the differences and commonalities between various types of project development, Modern.js organizes plugins as shown in the following figure:
39
39
 
@@ -170,6 +170,8 @@ export const myPlugin = (): CliPlugin => ({
170
170
  });
171
171
  ```
172
172
 
173
+ Note that the setup function of the next plugin is not executed until the async setup function of the current plugin has finished. Therefore, you should avoid performing time-consuming asynchronous operations in the setup function to avoid slowing down the startup performance of the CLI.
174
+
173
175
  ## Adding Plugins
174
176
 
175
177
  Custom plugins can be used by following the instructions in the [plugins](/configure/app/plugins) section of the documentation. Below is the recommended way to implement plugins in Modern.js.
@@ -203,9 +205,9 @@ export default defineConfig({
203
205
 
204
206
  ### Publishing a Plugin on npm
205
207
 
206
- If you want to publish your Modern.js plugin on npm, it's recommended to use the module project solution provided by Modern.js to manage and build the plugin.
208
+ If you want to publish your Modern.js plugin on npm, it's recommended to use the [Modern.js Module](https://modernjs.dev/module-tools) to manage and build the plugin.
207
209
 
208
- First, create an empty module project solution and adjust the package name:
210
+ First, create an empty Modern.js Module project and adjust the package name:
209
211
 
210
212
  ```json
211
213
  {
@@ -214,7 +216,7 @@ First, create an empty module project solution and adjust the package name:
214
216
  }
215
217
  ```
216
218
 
217
- create plugin main file:
219
+ Create plugin main file:
218
220
 
219
221
  ```ts title=src/index.ts
220
222
  import type { CliPlugin } from '@modern-js/core';
@@ -48,19 +48,11 @@ npx @modern-js/create@latest npm-module
48
48
  ? Please select the package manager: pnpm
49
49
  ```
50
50
 
51
- ### Create a Modern Doc Project
52
-
53
- ```bash
54
- npx @modern-js/create@latest doc-website
55
- ? Please select the type of project you want to create: Doc Site
56
- ? Please select the package manager: pnpm
57
- ```
58
-
59
51
  ### Create Monorepo Project
60
52
 
61
53
  ```bash
62
54
  npx @modern-js/create@latest monorepo
63
- ? Please select the type of project you want to create: Doc Site
55
+ ? Please select the type of project you want to create: Monorepo
64
56
  ? Please select the package manager: pnpm
65
57
  ```
66
58
 
@@ -25,7 +25,7 @@ Only some APIs are briefly explained below. For the complete API, please refer t
25
25
 
26
26
  ## Customize Input
27
27
 
28
- Both Modern.js Web App and Npm Module schemes have default input interactions. These APIs can be used to add, modify, hide, and provide default values for these inputs.
28
+ Both Modern.js Framework and Modern.js Module have default input interactions. These APIs can be used to add, modify, hide, and provide default values for these inputs.
29
29
 
30
30
  For example:
31
31
 
@@ -2,6 +2,7 @@
2
2
  sidebar_position: 1
3
3
  title: Introduction
4
4
  ---
5
+
5
6
  # Introduction
6
7
 
7
8
  import MicroFrontend from '@modern-js/builder-doc/docs/en/shared/micro-frontend.md';
@@ -13,6 +13,7 @@ Through this chapter you can learn:
13
13
  ## Create an app
14
14
 
15
15
  Currently supports two routing modes
16
+
16
17
  - Self-controlled routing
17
18
  - Conventional routing
18
19
 
@@ -20,7 +21,6 @@ First, clarify the routing mode of the main application [create a file-based rou
20
21
 
21
22
  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
23
 
23
-
24
24
  ### File-based Routing Main App
25
25
 
26
26
  Initialize the project with a command line:
@@ -39,11 +39,12 @@ After the project is created, we can enable the `micro frontend` through `pnpm r
39
39
 
40
40
  Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
41
41
 
42
- import EnableMicroFrontend from "@site-docs-en/components/enable-micro-frontend";
42
+ import EnableMicroFrontend from '@site-docs-en/components/enable-micro-frontend';
43
43
 
44
44
  <EnableMicroFrontend />
45
45
 
46
46
  Then we create two new directories in the routes folder
47
+
47
48
  - table (for loading conventional routing sub-applications)
48
49
  - dashboard (for loading self-controlled routing sub-applications)
49
50
 
@@ -61,8 +62,8 @@ const Index = () => {
61
62
  <div>
62
63
  <Table />
63
64
  </div>
64
- )
65
- }
65
+ );
66
+ };
66
67
 
67
68
  export default Index;
68
69
  ```
@@ -79,11 +80,12 @@ const Index = () => {
79
80
  <div>
80
81
  <Dashboard />
81
82
  </div>
82
- )
83
- }
83
+ );
84
+ };
84
85
 
85
86
  export default Index;
86
87
  ```
88
+
87
89
  #### route link
88
90
 
89
91
  At this time, the main application configuration has been completed, and the sub-application can be loaded through the route, and the `layout.tsx` of the main application can be modified to jump to the route:
@@ -93,9 +95,15 @@ import { Outlet, Link } from '@modern-js/runtime/router';
93
95
 
94
96
  const Layout = () => (
95
97
  <div>
96
- <div><Link to={'/table'}>Load file-base routing sub-app</Link></div>
97
- <div><Link to={'/dashboard'}>Load self-controlled routing sub-app</Link></div>
98
- <div><Link to={'/'}>unmount sub-app</Link></div>
98
+ <div>
99
+ <Link to={'/table'}>Load file-base routing sub-app</Link>
100
+ </div>
101
+ <div>
102
+ <Link to={'/dashboard'}>Load self-controlled routing sub-app</Link>
103
+ </div>
104
+ <div>
105
+ <Link to={'/'}>unmount sub-app</Link>
106
+ </div>
99
107
  <Outlet />
100
108
  </div>
101
109
  );
@@ -127,7 +135,7 @@ Since it is a self-controlled route, we delete the `routes/` folder and add the
127
135
 
128
136
  #### Load sub-app
129
137
 
130
- import CustomRouterMicroFrontend from "@site-docs-en/components/custom-router-micro-frontend";
138
+ import CustomRouterMicroFrontend from '@site-docs-en/components/custom-router-micro-frontend';
131
139
 
132
140
  <CustomRouterMicroFrontend />
133
141
 
@@ -155,7 +163,7 @@ import { garfishPlugin } from '@modern-js/plugin-garfish';
155
163
 
156
164
  export default defineConfig({
157
165
  dev: {
158
- port: 8081
166
+ port: 8081,
159
167
  },
160
168
  runtime: {
161
169
  router: true,
@@ -172,10 +180,8 @@ add `src/routes/page.tsx`:
172
180
 
173
181
  ```js title="src/routes/page.tsx"
174
182
  const Index = () => {
175
- return (
176
- <div className="container-box">subApp</div>
177
- )
178
- }
183
+ return <div className="container-box">subApp</div>;
184
+ };
179
185
 
180
186
  export default Index;
181
187
  ```
@@ -204,7 +210,7 @@ import { garfishPlugin } from '@modern-js/plugin-garfish';
204
210
 
205
211
  export default defineConfig({
206
212
  dev: {
207
- port: 8082
213
+ port: 8082,
208
214
  },
209
215
  runtime: {
210
216
  router: true,
@@ -224,7 +230,7 @@ And add code in `src/App.tsx`, note that you need to parse from `props` and pass
224
230
  ```js title="src/App.tsx"
225
231
  import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
226
232
 
227
- export default (props: {basename: string}) => {
233
+ export default (props: { basename: string }) => {
228
234
  const { basename } = props;
229
235
 
230
236
  return (
@@ -241,6 +247,7 @@ export default (props: {basename: string}) => {
241
247
  ## Debug
242
248
 
243
249
  Start the application by executing the `pnpm run dev` command in the directory in sequence:
250
+
244
251
  - masterApp `http://localhost:8080`
245
252
  - table subapplication (conventional routing) `http://localhost:8081`
246
253
  - dashboard subapplication (self-controlled routing) `http://localhost:8082`