@modern-js/main-doc 2.35.0 → 2.35.1
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/apis/app/commands.mdx +12 -11
- package/docs/en/components/debug-app.mdx +1 -3
- package/docs/en/components/global-proxy-config.mdx +4 -13
- package/docs/en/components/global-proxy.mdx +2 -4
- package/docs/en/components/init-app.mdx +1 -1
- package/docs/en/configure/app/builder-plugins.mdx +2 -2
- package/docs/en/configure/app/plugins.mdx +3 -4
- package/docs/en/configure/app/server/base-url.mdx +0 -2
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/guides/basic-features/alias.mdx +1 -1
- package/docs/en/guides/basic-features/css.mdx +35 -15
- package/docs/en/guides/basic-features/data-fetch.mdx +12 -12
- package/docs/en/guides/basic-features/html.mdx +2 -2
- package/docs/en/guides/basic-features/routes.mdx +27 -15
- package/docs/en/guides/get-started/quick-start.mdx +8 -17
- package/docs/en/guides/get-started/upgrade.mdx +10 -4
- package/docs/en/guides/topic-detail/framework-plugin/implement.mdx +2 -0
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -0
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +24 -17
- package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +51 -37
- package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +1 -0
- package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
- package/docs/en/tutorials/first-app/c02-component.mdx +4 -3
- package/docs/zh/apis/app/commands.mdx +10 -9
- package/docs/zh/apis/app/hooks/api/api.mdx +2 -1
- package/docs/zh/apis/app/hooks/server/index_.mdx +2 -1
- package/docs/zh/components/debug-app.mdx +1 -3
- package/docs/zh/components/global-proxy-config.mdx +4 -13
- package/docs/zh/components/global-proxy.mdx +2 -4
- package/docs/zh/configure/app/builder-plugins.mdx +1 -1
- package/docs/zh/configure/app/plugins.mdx +1 -2
- package/docs/zh/configure/app/server/base-url.mdx +0 -2
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/guides/basic-features/alias.mdx +1 -1
- package/docs/zh/guides/basic-features/css.mdx +35 -15
- package/docs/zh/guides/basic-features/data-fetch.mdx +11 -12
- package/docs/zh/guides/basic-features/html.mdx +4 -5
- package/docs/zh/guides/basic-features/routes.mdx +26 -19
- package/docs/zh/guides/get-started/quick-start.mdx +8 -17
- package/docs/zh/guides/get-started/upgrade.mdx +10 -4
- package/docs/zh/guides/topic-detail/framework-plugin/hook-list.mdx +1 -1
- package/docs/zh/guides/topic-detail/framework-plugin/implement.mdx +2 -0
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +45 -21
- package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +51 -33
- package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +1 -0
- package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -0
- package/docs/zh/tutorials/first-app/c02-component.mdx +4 -3
- package/package.json +7 -7
@@ -30,7 +30,6 @@ After running `modern dev`, Modern.js will watch source file changes and apply h
|
|
30
30
|
$ modern dev
|
31
31
|
|
32
32
|
info Starting dev server...
|
33
|
-
info App running at:
|
34
33
|
|
35
34
|
> Local: http://localhost:8080/
|
36
35
|
> Network: http://192.168.0.1:8080/
|
@@ -42,7 +41,7 @@ In multi-page (MPA) projects, the `--entry` option can be added to specify one o
|
|
42
41
|
|
43
42
|
For example, execute `modern dev --entry`, the entry selector will be displayed in the command line interface:
|
44
43
|
|
45
|
-
```
|
44
|
+
```text
|
46
45
|
$ modern dev --entry
|
47
46
|
|
48
47
|
? Please select the entry that needs to be built
|
@@ -86,14 +85,16 @@ Options:
|
|
86
85
|
|
87
86
|
execute `npx modern build --analyze` command, can produce an HTML file that analyzes the volume of the bundle while packaging the production code:
|
88
87
|
|
89
|
-
```
|
88
|
+
```text
|
90
89
|
Bundle Analyzer saved report to /example/dist/report.html
|
91
|
-
File sizes after production build:
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
info Production file sizes:
|
92
|
+
|
93
|
+
File Size Gzipped
|
94
|
+
dist/static/js/lib-react.09721b5c.js 152.6 kB 49.0 kB
|
95
|
+
dist/html/main/index.html 5.8 kB 2.5 kB
|
96
|
+
dist/static/js/main.3568a38e.js 3.5 kB 1.4 kB
|
97
|
+
dist/static/css/main.03221f72.css 1.4 kB 741 B
|
97
98
|
```
|
98
99
|
|
99
100
|
Open the above HTML file in the browser, you can see the tile diagram of the bundled files, and perform package volume analysis and optimization:
|
@@ -125,7 +126,7 @@ Options:
|
|
125
126
|
|
126
127
|
In the project, execute the `new` command to add entries as follows:
|
127
128
|
|
128
|
-
```
|
129
|
+
```text
|
129
130
|
$ npx modern new
|
130
131
|
? Please select the operation you want: Create Element
|
131
132
|
? Please select the type of element to create: New "entry"
|
@@ -136,7 +137,7 @@ $ npx modern new
|
|
136
137
|
|
137
138
|
In the project, execute the `new` command to enable features as follows:
|
138
139
|
|
139
|
-
```
|
140
|
+
```text
|
140
141
|
$ npx modern new
|
141
142
|
? Please select the operation you want: Enable Features
|
142
143
|
? Please select the feature name: (Use arrow keys)
|
@@ -156,7 +157,7 @@ pnpm does not support the use of JSON strings as parameter values currently. Use
|
|
156
157
|
|
157
158
|
## modern serve
|
158
159
|
|
159
|
-
|
160
|
+
The `modern serve` command is used to start a Modern.js project in the production environment. It can also be used to preview the artifacts built for the production environment locally. Please note that you need to execute the [`build`](/apis/app/commands#modern-build) command beforehand to generate the corresponding artifacts.
|
160
161
|
|
161
162
|
```bash
|
162
163
|
Usage: modern serve [options]
|
@@ -6,12 +6,10 @@ $ pnpm run dev
|
|
6
6
|
> modern dev
|
7
7
|
|
8
8
|
info Starting dev server...
|
9
|
-
|
9
|
+
ready Client compiled in 50ms
|
10
10
|
|
11
11
|
> Local: http://localhost:8080/
|
12
12
|
> Network: http://192.168.0.1:8080/
|
13
|
-
|
14
|
-
Client ✔ done in 76.10ms
|
15
13
|
```
|
16
14
|
|
17
15
|
Open `http://localhost:8000/` in your browser to see the page content.
|
@@ -7,16 +7,9 @@ This option is used to configure a global proxy based on [whistle](https://wprox
|
|
7
7
|
|
8
8
|
Before using this option, you need to install and register the `@modern-js/plugin-proxy` plugin:
|
9
9
|
|
10
|
-
|
11
|
-
# npm
|
12
|
-
npm add @modern-js/plugin-proxy -D
|
13
|
-
|
14
|
-
# yarn
|
15
|
-
yarn add @modern-js/plugin-proxy -D
|
10
|
+
import { PackageManagerTabs } from '@theme';
|
16
11
|
|
17
|
-
|
18
|
-
pnpm add @modern-js/plugin-proxy -D
|
19
|
-
```
|
12
|
+
<PackageManagerTabs command="add @modern-js/plugin-proxy -D" />
|
20
13
|
|
21
14
|
After the installation, please register the plugin in the `modern.config.ts` file:
|
22
15
|
|
@@ -75,13 +68,11 @@ module.exports = {
|
|
75
68
|
Execute `dev`, when the prompt is as follows, the proxy server starts successfully:
|
76
69
|
|
77
70
|
```bash
|
78
|
-
App running at:
|
79
|
-
|
80
71
|
Local: http://localhost:8080/
|
81
72
|
Network: http://192.168.0.1:8080/
|
82
73
|
|
83
|
-
|
84
|
-
|
74
|
+
info Starting proxy server.....
|
75
|
+
success Proxy server start on localhost:8899
|
85
76
|
```
|
86
77
|
|
87
78
|
Access the `localhost:8899` to view the Network and configure proxy rules on the UI interface:
|
@@ -11,13 +11,11 @@ Specific proxy rules can be set via the [`dev.proxy`](/configure/app/dev/proxy)
|
|
11
11
|
After installing the proxy plugin and configuring the proxy rules, run the `pnpm run dev` command:
|
12
12
|
|
13
13
|
```bash
|
14
|
-
App running at:
|
15
|
-
|
16
14
|
Local: http://localhost:8080/
|
17
15
|
Network: http://192.168.0.1:8080/
|
18
16
|
|
19
|
-
|
20
|
-
|
17
|
+
info Starting proxy server.....
|
18
|
+
success Proxy server start on localhost:8899
|
21
19
|
```
|
22
20
|
|
23
21
|
You can see that the proxy server has started successfully in the console.
|
@@ -14,7 +14,7 @@ After create the project, Modern.js will automatically install dependencies and
|
|
14
14
|
[INFO] git repository has been automatically created
|
15
15
|
[INFO] Success!
|
16
16
|
You can run the following command in the directory of the new project:
|
17
|
-
pnpm run dev # Starting
|
17
|
+
pnpm run dev # Starting dev server
|
18
18
|
pnpm run build # Build the app for production
|
19
19
|
pnpm run serve # Preview the production build locally
|
20
20
|
pnpm run lint # Run ESLint and automatically fix problems
|
@@ -15,8 +15,8 @@ Modern.js Builder is the build tool of Modern.js, please read [Builder](/guides/
|
|
15
15
|
|
16
16
|
This option **is used to configure the Modern.js Builder plugins**. If you need to configure other types of plugins, please select the corresponding configs:
|
17
17
|
|
18
|
-
- Use [plugins](/configure/app/
|
19
|
-
- Use [tools.
|
18
|
+
- Use [plugins](/configure/app/plugins) to configure Modern.js framework plugins.
|
19
|
+
- Use [tools.bundlerChain](/configure/app/tools/bundler-chain) to configure Rspack or webpack plugins.
|
20
20
|
- Use [tools.babel](/configure/app/tools/babel) to configure Babel plugins.
|
21
21
|
|
22
22
|
## When to use
|
@@ -15,10 +15,9 @@ Refer to [How to Develop Plugins](/guides/topic-detail/framework-plugin/implemen
|
|
15
15
|
|
16
16
|
This option is used to configure framework plugins. If you need to configure other types of plugins, please choose the corresponding configuration method:
|
17
17
|
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
21
|
-
- To configure Babel plugins, use the [tools.babel](/configure/app/tools/babel) option.
|
18
|
+
- Use [builderPlugins](/configure/app/builder-plugins) to configure Modern.js Builder plugins.
|
19
|
+
- Use [tools.bundlerChain](/configure/app/tools/bundler-chain) to configure Rspack or webpack plugins.
|
20
|
+
- Use [tools.babel](/configure/app/tools/babel) to configure Babel plugins.
|
22
21
|
|
23
22
|
## Plugin types
|
24
23
|
|
@@ -49,6 +49,6 @@ import('./bootstrap.jsx');
|
|
49
49
|
At this point, you can consume any remote module in the current page.
|
50
50
|
|
51
51
|
:::info
|
52
|
-
Modern.js does not have
|
52
|
+
Modern.js does not have ModuleFederationPlugin plugin built in. Please configure the ModuleFederationPlugin yourself via [tools.bundlerChain](/configure/app/tools/bundler-chain).
|
53
53
|
|
54
54
|
:::
|
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
sidebar_position:
|
2
|
+
sidebar_position: 1
|
3
3
|
---
|
4
4
|
|
5
5
|
# Styling
|
@@ -61,16 +61,31 @@ If you need to use other CSS-in-JS libraries such as [styled-jsx](https://www.np
|
|
61
61
|
|
62
62
|
## Using Tailwind CSS
|
63
63
|
|
64
|
-
[Tailwind CSS](https://tailwindcss.com/) is a CSS framework and design system based on Utility Class, which can quickly add common styles to components, and support flexible extension of theme styles.
|
64
|
+
[Tailwind CSS](https://tailwindcss.com/) is a CSS framework and design system based on Utility Class, which can quickly add common styles to components, and support flexible extension of theme styles.
|
65
65
|
|
66
|
-
|
66
|
+
To use [Tailwind CSS](https://tailwindcss.com/) in Modern.js, you can follow the steps below:
|
67
|
+
|
68
|
+
1. Run `pnpm run new` in the root directory of your project and make the following selections:
|
67
69
|
|
68
70
|
```text
|
69
71
|
? Please select the operation you want: Enable features
|
70
72
|
? Please select the feature name: Enable Tailwind CSS
|
71
73
|
```
|
72
74
|
|
73
|
-
|
75
|
+
After successful initialization, you will see the following additions to the `package.json` file:
|
76
|
+
|
77
|
+
```json title="./package.json"
|
78
|
+
{
|
79
|
+
"dependencies": {
|
80
|
+
"tailwindcss": "^3.0.0"
|
81
|
+
},
|
82
|
+
"devDependencies": {
|
83
|
+
"@modern-js/plugin-tailwindcss": "^2.0.0"
|
84
|
+
}
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
2. Register the Tailwind plugin in `modern.config.ts`:
|
74
89
|
|
75
90
|
```ts title="modern.config.ts"
|
76
91
|
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
@@ -80,29 +95,34 @@ export default defineConfig({
|
|
80
95
|
});
|
81
96
|
```
|
82
97
|
|
83
|
-
|
98
|
+
3. Create a `index.css` file and add the following code:
|
99
|
+
|
100
|
+
```css title="index.css"
|
101
|
+
@tailwind base;
|
102
|
+
@tailwind components;
|
103
|
+
@tailwind utilities;
|
104
|
+
```
|
105
|
+
|
106
|
+
:::info
|
107
|
+
Depending on your needs, you can selectively import the CSS styles provided by Tailwind CSS. Please refer to the [`@tailwind` documentation](https://tailwindcss.com/docs/functions-and-directives#tailwind) for detailed usage of the `@tailwind` directive.
|
108
|
+
:::
|
109
|
+
|
110
|
+
4. Import the `index.css` file, for example, add the following code in the root component `src/App.jsx`:
|
84
111
|
|
85
112
|
```js
|
86
|
-
import '
|
87
|
-
import 'tailwindcss/components.css';
|
88
|
-
import 'tailwindcss/utilities.css';
|
113
|
+
import './index.css';
|
89
114
|
```
|
90
115
|
|
91
|
-
|
116
|
+
5. Now you can use the Utility Classes provided by Tailwind CSS in your components:
|
92
117
|
|
93
118
|
```tsx
|
94
|
-
const
|
119
|
+
const Hello = () => (
|
95
120
|
<div className="h-12 w-48">
|
96
121
|
<p className="text-xl font-medium text-black">hello world</p>
|
97
122
|
</div>
|
98
123
|
);
|
99
124
|
```
|
100
125
|
|
101
|
-
:::info Additional Information
|
102
|
-
Depending on your needs, you can selectively import the CSS files provided by Tailwind CSS. Since using `@tailwind` is equivalent to directly importing CSS files, you can refer to the comments in the [`@tailwind` usage](https://tailwindcss.com/docs/functions-and-directives#tailwind) documentation for the purpose of the CSS files provided by Tailwind CSS.
|
103
|
-
|
104
|
-
:::
|
105
|
-
|
106
126
|
### Configuring Tailwind CSS
|
107
127
|
|
108
128
|
In Modern.js, you have two ways to configure Tailwind CSS:
|
@@ -1,10 +1,11 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
title: Data Fetching
|
3
|
+
sidebar_position: 3
|
3
4
|
---
|
4
5
|
|
5
6
|
# Data Fetching
|
6
7
|
|
7
|
-
Modern.js provides out-of-the-box data fetching capabilities,
|
8
|
+
Modern.js provides out-of-the-box data fetching capabilities,developers can fetch data in the project through these APIs.
|
8
9
|
|
9
10
|
It should be noted that these APIs do not help applications initiate requests, but rather help developers better manage data and improve project performance.
|
10
11
|
|
@@ -13,7 +14,7 @@ It should be noted that these APIs do not help applications initiate requests, b
|
|
13
14
|
Modern.js recommends using [conventional routing](/guides/basic-features/routes) for routing management. Through Modern.js's [conventional (nested) routing](/guides/basic-features/routes#conventional-routing), each routing component (`layout.ts` or `page.ts`) can have a same-named `loader` file. The `loader` file needs to export a function that will be executed before the component is rendered to provide data for the routing component.
|
14
15
|
|
15
16
|
:::info
|
16
|
-
Modern.js v1 supports fetching data via [useLoader](
|
17
|
+
Modern.js v1 supports fetching data via [useLoader](</guides/basic-features/data-fetch.html#useloader-(old-version)>), which is no longer the recommended usage. We do not recommend mixing the two except during the migration process.
|
17
18
|
|
18
19
|
:::
|
19
20
|
|
@@ -216,25 +217,24 @@ If you want to get the data returned by the `loader` in `entry1/routes/layout.ts
|
|
216
217
|
|
217
218
|
:::info
|
218
219
|
This feature is currently experimental and the API may change in the future.
|
219
|
-
Currently only supports CSR, please look forward to Streaming SSR.
|
220
220
|
:::
|
221
221
|
|
222
222
|
Create `user/layout.loader.ts` and add the following code:
|
223
223
|
|
224
224
|
```ts title="routes/user/layout.loader.ts"
|
225
|
-
import { defer } from
|
225
|
+
import { defer } from '@modern-js/runtime/router';
|
226
226
|
|
227
227
|
const loader = () =>
|
228
|
-
defer({
|
229
|
-
|
228
|
+
defer({
|
229
|
+
userInfo: new Promise(resolve => {
|
230
230
|
setTimeout(() => {
|
231
231
|
resolve({
|
232
232
|
age: 1,
|
233
|
-
name: 'user layout'
|
234
|
-
})
|
235
|
-
}, 1000)
|
236
|
-
})
|
237
|
-
})
|
233
|
+
name: 'user layout',
|
234
|
+
});
|
235
|
+
}, 1000);
|
236
|
+
}),
|
237
|
+
});
|
238
238
|
|
239
239
|
export default loader;
|
240
240
|
```
|
@@ -165,9 +165,9 @@ export default function Document(): React.ReactElement {
|
|
165
165
|
|
166
166
|
## HTML Syntax
|
167
167
|
|
168
|
-
Modern.js also supports HTML
|
168
|
+
Modern.js also supports generating HTML files using HTML (EJS) syntax.
|
169
169
|
|
170
|
-
|
170
|
+
By default, Modern.js projects come with a built-in HTML template for generating HTML code. If you need to customize the HTML template, you can use two methods: **Custom HTML Fragments** and **Fully Custom HTML Templates**.
|
171
171
|
|
172
172
|
### Custom HTML Fragments
|
173
173
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
---
|
2
|
-
sidebar_position:
|
2
|
+
sidebar_position: 2
|
3
3
|
---
|
4
4
|
|
5
5
|
# Routing
|
@@ -140,6 +140,7 @@ To simplify the introduction of the relationship between `<Layout>` and `<Outlet
|
|
140
140
|
</UserLayout>
|
141
141
|
</Layout>
|
142
142
|
```
|
143
|
+
|
143
144
|
In summary, if there is a `layout.tsx` file under the sub-route's file directory, the `<Outlet>` in the parent `layout.tsx` will represent the `layout.tsx` in the sub-route file directory. Otherwise, it will represent the `page.tsx` in the sub-route file directory.
|
144
145
|
|
145
146
|
#### Page
|
@@ -148,12 +149,12 @@ All routes should end with the `<Page>` component. If the developer introduces t
|
|
148
149
|
|
149
150
|
#### Config
|
150
151
|
|
151
|
-
Each `Layout
|
152
|
+
Each `Layout`,`$` or `Page` file can define its own `config` file, such as `page.config.ts`. In this file, we have an conventinal on a named export called `handle`, which you can define any properties:
|
152
153
|
|
153
154
|
```ts title="routes/blog/page.config.ts"
|
154
155
|
export const handle = {
|
155
|
-
breadcrumbName: 'profile'
|
156
|
-
}
|
156
|
+
breadcrumbName: 'profile',
|
157
|
+
};
|
157
158
|
```
|
158
159
|
|
159
160
|
These properties as defined are available via the [`useMatches`](https://reactrouter.com/en/main/hooks/use-matches) hook:
|
@@ -161,12 +162,11 @@ These properties as defined are available via the [`useMatches`](https://reactro
|
|
161
162
|
```ts title="routes/layout.ts"
|
162
163
|
export default () => {
|
163
164
|
const matches = useMatches;
|
164
|
-
const breadcrumbs = matches.map(
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
}
|
165
|
+
const breadcrumbs = matches.map(
|
166
|
+
matchedRoute => matchedRoute?.handle?.breadcrumbName,
|
167
|
+
);
|
168
|
+
return <Breadcrumb names={breadcrumbs}></Breadcrumb>;
|
169
|
+
};
|
170
170
|
```
|
171
171
|
|
172
172
|
### Dynamic Routing
|
@@ -227,6 +227,7 @@ For example, the following directory structure:
|
|
227
227
|
```
|
228
228
|
|
229
229
|
When accessing any path that does not match(For example `/blog/a`), the `routes/$.tsx` component will be rendered, because there is `layout.tsx` here, the rendered UI is as follows.
|
230
|
+
|
230
231
|
```tsx
|
231
232
|
<RootLayout>
|
232
233
|
<BlogLayout>
|
@@ -364,6 +365,17 @@ export default () => {
|
|
364
365
|
};
|
365
366
|
```
|
366
367
|
|
368
|
+
If you want to redirect in a component,you can navigate by `useNavigate` hook, for example:
|
369
|
+
|
370
|
+
```ts title="routes/user/page.ts"
|
371
|
+
import { useNavigate } from '@modern-js/runtime/router';
|
372
|
+
|
373
|
+
export default () => {
|
374
|
+
const navigate = useNavigate();
|
375
|
+
navigate('/login');
|
376
|
+
};
|
377
|
+
```
|
378
|
+
|
367
379
|
### ErrorBoundary
|
368
380
|
|
369
381
|
In each directory under `routes/`, developers can also define an `error.tsx` file that exports an `<ErrorBoundary>` component by default.
|
@@ -391,7 +403,6 @@ export const ErrorBoundary = () => {
|
|
391
403
|
|
392
404
|
In each root `Layout` component (`routes/layout.ts`), you can dynamically define runtime configuration:
|
393
405
|
|
394
|
-
|
395
406
|
```tsx title="src/routes/layout.tsx"
|
396
407
|
// Define runtime config
|
397
408
|
import type { AppConfig } from '@modern-js/runtime';
|
@@ -489,6 +500,7 @@ To further improve the user experience and reduce loading time, Modern.js suppor
|
|
489
500
|
```
|
490
501
|
|
491
502
|
:::info
|
503
|
+
|
492
504
|
- This feature is currently only supported in Webpack projects and not yet supported in Rspack projects.
|
493
505
|
- Preloading data currently only preloads the data returned by the [Data Loader](/guides/basic-features/data-fetch) in SSR projects.
|
494
506
|
|
@@ -508,13 +520,13 @@ The `prefetch` attribute has three optional values:
|
|
508
520
|
- By using `render`, static assets will only be loaded when the system is idle, and will not compete with the static assets of the initial screen for network assets.
|
509
521
|
- In the SSR scenario, data will also be pre-fetched.
|
510
522
|
|
511
|
-
import Motivation from '@site-docs-en/components/convention-routing-motivation'
|
523
|
+
import Motivation from '@site-docs-en/components/convention-routing-motivation';
|
512
524
|
|
513
|
-
<Motivation/>
|
525
|
+
<Motivation />
|
514
526
|
|
515
|
-
import Practice from '@site-docs-en/components/routes-practice'
|
527
|
+
import Practice from '@site-docs-en/components/routes-practice';
|
516
528
|
|
517
|
-
<Practice/>
|
529
|
+
<Practice />
|
518
530
|
|
519
531
|
## Self-controlled Routing
|
520
532
|
|
@@ -91,23 +91,15 @@ $ pnpm run build
|
|
91
91
|
|
92
92
|
> modern build
|
93
93
|
|
94
|
-
info
|
95
|
-
|
96
|
-
info
|
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-
|
100
|
-
dist/
|
101
|
-
dist/static/js/
|
102
|
-
dist/static/
|
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
|
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/
|
@@ -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 `
|
11
|
+
Run the `upgrade` script in the project:
|
12
12
|
|
13
|
-
|
14
|
-
|
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
|
35
|
+
import ReleaseNote from '@site-docs-en/components/release-note';
|
30
36
|
|
31
37
|
<ReleaseNote />
|
32
38
|
|
@@ -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.
|