@modern-js/main-doc 2.0.0-beta.3 → 2.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +8 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/inspect.md +31 -10
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/serve.md +32 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/server.md +31 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +4 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/create-app.md +2 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/components/init-app.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/builder-plugins.md +70 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/with-master-app.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +11 -5
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +2 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-entry-dirs.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries.md +66 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/esbuild.md +16 -39
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-in-js.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-modules.md +86 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/less-sass.md +17 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/postcss.md +81 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/tailwindcss.md +95 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +66 -0
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +270 -0
- package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +116 -0
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +162 -0
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/upgrade.md +78 -0
- package/{zh/tutorials/first-app → en/docusaurus-plugin-content-docs/current/guides}/overview.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/lifecycle.md +15 -0
- package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/introduction.md +1 -1
- package/en/docusaurus-plugin-content-docs/current.json +11 -11
- package/package.json +4 -4
- package/zh/apis/app/commands/dev.md +9 -4
- package/zh/apis/app/commands/inspect.md +32 -11
- package/zh/apis/app/commands/new.md +1 -1
- package/zh/apis/app/commands/{start.md → serve.md} +3 -3
- package/zh/apis/app/hooks/src/index_.md +5 -4
- package/zh/apis/app/hooks/src/server.md +31 -0
- package/zh/apis/app/runtime/core/bootstrap.md +3 -4
- package/zh/apis/app/runtime/core/create-app.md +1 -18
- package/zh/apis/app/runtime/core/use-module-apps.md +64 -33
- package/zh/apis/app/runtime/web-server/hook.md +1 -1
- package/zh/apis/app/runtime/web-server/middleware.md +1 -0
- package/zh/components/debug-app.md +18 -0
- package/zh/components/default-mwa-generate.md +5 -0
- package/zh/components/deploy.md +1 -0
- package/zh/components/enable-micro-frontend.md +13 -0
- package/zh/components/global-proxy.md +28 -0
- package/zh/components/init-app.md +44 -0
- package/zh/components/micro-runtime-config.md +18 -0
- package/zh/components/prerequisites.md +19 -0
- package/zh/components/release-note.md +1 -0
- package/zh/configure/app/builder-plugins.md +72 -0
- package/zh/configure/app/deploy/_category_.json +4 -0
- package/zh/configure/app/deploy/microFrontend.md +64 -0
- package/zh/configure/app/dev/with-master-app.md +0 -2
- package/zh/configure/app/plugins.md +10 -4
- package/zh/configure/app/runtime/master-app.md +33 -36
- package/zh/configure/app/server/routes.md +2 -4
- package/zh/configure/app/source/disable-entry-dirs.md +37 -0
- package/zh/configure/app/source/entries-dir.md +0 -3
- package/zh/configure/app/source/entries.md +66 -3
- package/zh/configure/app/tools/esbuild.md +16 -39
- package/zh/guides/advanced-features/bff/bff-proxy.md +1 -1
- package/zh/guides/advanced-features/compatibility.md +14 -39
- package/zh/guides/advanced-features/eslint.md +21 -21
- package/zh/guides/advanced-features/ssg.md +20 -9
- package/zh/guides/advanced-features/ssr.md +95 -52
- package/zh/guides/advanced-features/testing.md +44 -1
- package/zh/guides/advanced-features/web-server.md +14 -3
- package/zh/guides/basic-features/css/tailwindcss.md +13 -6
- package/zh/guides/basic-features/data-fetch.md +398 -5
- package/zh/guides/basic-features/html.md +182 -0
- package/zh/guides/basic-features/mock.md +3 -9
- package/zh/guides/basic-features/proxy.md +2 -27
- package/zh/guides/basic-features/routes.md +35 -3
- package/zh/guides/concept/entries.md +108 -19
- package/zh/guides/get-started/quick-start.md +14 -83
- package/zh/guides/get-started/upgrade.md +11 -9
- package/zh/guides/{concept → topic-detail/framework-plugin}/lifecycle.md +0 -0
- package/zh/guides/topic-detail/micro-frontend/c01-introduction.md +29 -0
- package/zh/guides/topic-detail/micro-frontend/c02-development.md +191 -0
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.md +246 -0
- package/zh/guides/topic-detail/micro-frontend/c04-communicate.md +54 -0
- package/zh/guides/topic-detail/micro-frontend/{mixed-stack.md → c05-mixed-stack.md} +3 -3
- package/zh/guides/topic-detail/model/quick-start.md +1 -1
- package/zh/guides/topic-detail/model/test-model.md +2 -2
- package/zh/guides/topic-detail/monorepo/create-sub-project.md +2 -2
- package/zh/guides/topic-detail/monorepo/intro.md +1 -1
- package/zh/guides/troubleshooting/dependencies.md +0 -69
- package/zh/tutorials/first-app/_category_.json +1 -1
- package/zh/tutorials/first-app/c01-start.md +99 -0
- package/zh/tutorials/first-app/{c05-component/5.1-use-ui-library.md → c02-component.md} +13 -15
- package/zh/tutorials/first-app/c03-css.md +324 -0
- package/zh/tutorials/first-app/{c08-client-side-routing/8.1-code-based-routing.md → c04-routes.md} +52 -39
- package/zh/tutorials/first-app/c05-loader.md +82 -0
- package/zh/tutorials/first-app/c06-model.md +256 -0
- package/zh/tutorials/first-app/c07-container.md +283 -0
- package/zh/tutorials/first-app/c08-entries.md +137 -0
- package/zh/tutorials/foundations/introduction.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +0 -32
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-modern-mode.md +0 -34
- package/zh/apis/generator/overview.md +0 -32
- package/zh/configure/app/output/enable-modern-mode.md +0 -34
- package/zh/guides/advanced-features/custom-app.md +0 -72
- package/zh/guides/topic-detail/micro-frontend/communicate.md +0 -39
- package/zh/guides/topic-detail/micro-frontend/debugging.md +0 -168
- package/zh/guides/topic-detail/micro-frontend/introduction.md +0 -13
- package/zh/guides/topic-detail/micro-frontend/route-mode.md +0 -110
- package/zh/guides/topic-detail/monorepo/deploy.md +0 -43
- package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +0 -25
- package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +0 -118
- package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +0 -29
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +0 -47
- package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +0 -18
- package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +0 -31
- package/zh/tutorials/first-app/c01-getting-started/_category_.json +0 -3
- package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -79
- package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +0 -34
- package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +0 -19
- package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +0 -3
- package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +0 -55
- package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +0 -60
- package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +0 -11
- package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +0 -63
- package/zh/tutorials/first-app/c03-ide/_category_.json +0 -3
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +0 -54
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +0 -135
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +0 -67
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +0 -3
- package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +0 -72
- package/zh/tutorials/first-app/c05-component/_category_.json +0 -3
- package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +0 -110
- package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +0 -143
- package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +0 -84
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +0 -83
- package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +0 -77
- package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +0 -104
- package/zh/tutorials/first-app/c06-css-and-component/_category_.json +0 -3
- package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +0 -69
- package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +0 -100
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +0 -69
- package/zh/tutorials/first-app/c07-app-entry/_category_.json +0 -3
- package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +0 -3
- package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +0 -30
- package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +0 -95
- package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +0 -131
- package/zh/tutorials/first-app/c09-bff/_category_.json +0 -3
- package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +0 -21
- package/zh/tutorials/first-app/c10-model/10.2-add-model.md +0 -185
- package/zh/tutorials/first-app/c10-model/10.3-use-model.md +0 -55
- package/zh/tutorials/first-app/c10-model/10.4-testing.md +0 -69
- package/zh/tutorials/first-app/c10-model/_category_.json +0 -3
- package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +0 -240
- package/zh/tutorials/first-app/c11-container/11.2-add-container.md +0 -109
- package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +0 -63
- package/zh/tutorials/first-app/c11-container/11.4-testing.md +0 -56
- package/zh/tutorials/first-app/c11-container/_category_.json +0 -3
@@ -0,0 +1,116 @@
|
|
1
|
+
---
|
2
|
+
title: Entries
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
|
6
|
+
Entries are Modern.js default file convention, and each entry in the project is a separate page, corresponding to a server level route.
|
7
|
+
|
8
|
+
Many configurations, such as HTML templates, Meta information, whether SSR is enabled, SSG, server level routing rules are divided by the entry dimension.
|
9
|
+
|
10
|
+
## Single Entry and Multiple Entries
|
11
|
+
|
12
|
+
Modern.js initialization project is a single entry, the project structure is as follows:
|
13
|
+
|
14
|
+
```
|
15
|
+
.
|
16
|
+
├── src
|
17
|
+
│ ├── modern-app-env.d.ts
|
18
|
+
│ └── routes
|
19
|
+
│ ├── index.css
|
20
|
+
│ ├── layout.tsx
|
21
|
+
│ └── page.tsx
|
22
|
+
├── package.json
|
23
|
+
├── modern.config.ts
|
24
|
+
├── pnpm-lock.yaml
|
25
|
+
├── README.md
|
26
|
+
└── tsconfig.json
|
27
|
+
```
|
28
|
+
|
29
|
+
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:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
? Action: Create project element
|
33
|
+
? Create project element: New "entry"
|
34
|
+
? Entry name: new-entry
|
35
|
+
```
|
36
|
+
|
37
|
+
After execution, the `src/` directory will become the following structure:
|
38
|
+
|
39
|
+
```
|
40
|
+
.
|
41
|
+
├── modern-app-env.d.ts
|
42
|
+
├── myapp
|
43
|
+
│ └── routes
|
44
|
+
│ ├── index.css
|
45
|
+
│ ├── layout.tsx
|
46
|
+
│ └── page.tsx
|
47
|
+
└── new-entry
|
48
|
+
└── routes
|
49
|
+
├── index.css
|
50
|
+
├── layout.tsx
|
51
|
+
└── page.tsx
|
52
|
+
```
|
53
|
+
|
54
|
+
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.
|
55
|
+
|
56
|
+
After executing `pnpm run dev`, you can see that a `/new-entry` route has been added, and the migrated code route has not changed.
|
57
|
+
|
58
|
+
:::note
|
59
|
+
Modern.js will use the directory with the same name as the `name` in the `package.json` as the main entry, the default route is `/`, and the default route for other entries is `/{entryName}`.
|
60
|
+
:::
|
61
|
+
|
62
|
+
## Entry conditions
|
63
|
+
|
64
|
+
By default, the Modern.js entry currently scans the file under `src/`, identifies the entry, and generates the corresponding server level route.
|
65
|
+
|
66
|
+
:::tip
|
67
|
+
You can change the entry directory to another directory by [source.entriesDir](/docs/configure/app/source/entries-dir).
|
68
|
+
:::
|
69
|
+
|
70
|
+
Not all first-level directories under `src/` will become project entrances. The directory where the entry is located must meet one of the following four conditions:
|
71
|
+
|
72
|
+
|
73
|
+
1. Directory with `routes/`
|
74
|
+
2. Has the `App.[jt]sx?` file
|
75
|
+
3. With `index.[jt]sx?` file
|
76
|
+
2. With `pages/` directory (compatible Modern.js 1.0)
|
77
|
+
|
78
|
+
When the `src/` directory satisfies the entry feature, the Modern.js considers the current project to be a single entry application.
|
79
|
+
|
80
|
+
:::tip
|
81
|
+
Single entry The default entry name is `main`.
|
82
|
+
:::
|
83
|
+
|
84
|
+
When the project is not a single-entry application, Modern.js further look at the first-level directory under `src/`.
|
85
|
+
|
86
|
+
## Difference between entries
|
87
|
+
|
88
|
+
Entries to different conventions have different behaviors.
|
89
|
+
|
90
|
+
### routes
|
91
|
+
|
92
|
+
If the entry is the `routes/` convention, Modern.js will scan the files under `routes` at startup, and automatically generate the client route based on the file convention(react-router).
|
93
|
+
|
94
|
+
For details, please refer to [Routing](/docs/guides/basic-features/routes).
|
95
|
+
|
96
|
+
### App
|
97
|
+
|
98
|
+
If the entry is the `App.[jt]sx?` convention, the developer can freely set the client route in this file, or not set the client route.
|
99
|
+
|
100
|
+
For details, please refer to [Routing](/docs/guides/basic-features/routes).
|
101
|
+
|
102
|
+
### Index
|
103
|
+
|
104
|
+
Typically, the above two modes are sufficient, but when developers need to take over the React mount logic themselves, or take over the Webpack entry entirely, the `index.[jt]sx?`convention can be used.
|
105
|
+
|
106
|
+
If the entry is the `index.[jt]sx?` convention, the Modern.js determines the build behavior based on whether the file has a default component export.
|
107
|
+
|
108
|
+
For details, please refer to [customized App](/docs/guides/concept/entries#自定义-app).
|
109
|
+
|
110
|
+
## configuration
|
111
|
+
|
112
|
+
In Modern.js, you can manually configure the entry in `modern.config.[jt]s`, in addition to using the file convention to generate the entry.
|
113
|
+
|
114
|
+
:::tip
|
115
|
+
Details can be found in [source.entries](/docs/configure/app/source/entries).
|
116
|
+
:::
|
@@ -0,0 +1,162 @@
|
|
1
|
+
---
|
2
|
+
title: Quick Start
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
## Environment
|
7
|
+
|
8
|
+
### Node.js
|
9
|
+
|
10
|
+
Requires [Node.js LTS](https://github.com/nodejs/Release) and ensures that the Node version is greater than or equal to 14.19.0, 16.x version is recommended.
|
11
|
+
|
12
|
+
Modern.js recommend installing [nvm](https://github.com/nvm-sh/nvm#install--update-script) in the development environment and integrating [script to automatically switch node versions](https://github.com/nvm-sh/nvm#deeper-shell-integration) in the shell.
|
13
|
+
|
14
|
+
Then there is a `.nvmrc` file with the content of `lts/fermium` or `lts/gallium` in the root directory of the repository, it will automatically install or switch to the correct Node.js version when entering the repository.
|
15
|
+
|
16
|
+
### pnpm
|
17
|
+
|
18
|
+
[pnpm](https://pnpm.io/installation) is recommended for package management.
|
19
|
+
|
20
|
+
```bash
|
21
|
+
npm install -g pnpm
|
22
|
+
```
|
23
|
+
|
24
|
+
:::note
|
25
|
+
Modern.js also supports package management with `yarn` and `npm`.
|
26
|
+
:::
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Modern.js provides the `@modern-js/create` tool to create projects. Don't install globally, use `npx` to run on demand.
|
31
|
+
|
32
|
+
Projects can be created using an existing empty directory:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
mkdir myapp && cd myapp
|
36
|
+
npx @modern-js/create
|
37
|
+
```
|
38
|
+
|
39
|
+
Projects can also be created directly from the new directory:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
npx @modern-js/create myapp
|
43
|
+
```
|
44
|
+
|
45
|
+
## Initialize
|
46
|
+
|
47
|
+
import InitApp from '@site-docs/components/init-app.md'
|
48
|
+
|
49
|
+
<InitApp />
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
Execute `pnpm run dev` in the project to start the project:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
$ pnpm run dev
|
57
|
+
|
58
|
+
> modern dev
|
59
|
+
|
60
|
+
info Starting dev server...
|
61
|
+
info App running at:
|
62
|
+
|
63
|
+
> Local: http://localhost:8080/
|
64
|
+
> Network: http://10.94.58.87:8080/
|
65
|
+
> Network: http://10.254.68.105:8080/
|
66
|
+
|
67
|
+
Client ✔ done in 76.10ms
|
68
|
+
```
|
69
|
+
|
70
|
+
Open `http://localhost:8000/` in your browser and you will see the following:
|
71
|
+
|
72
|
+

|
73
|
+
|
74
|
+
## Configuration
|
75
|
+
|
76
|
+
The `modern.config.ts` files exist in Modern.js projects created by the generator.
|
77
|
+
|
78
|
+
Features can be enabled through the configuration file, or the default behavior of the coverage Modern.js. For example, add the following configuration to enable SSR:
|
79
|
+
|
80
|
+
```ts
|
81
|
+
import { defineConfig } from '@modern-js/app-tools';
|
82
|
+
|
83
|
+
// https://modernjs.dev/docs/apis/app/config
|
84
|
+
export default defineConfig({
|
85
|
+
runtime: {
|
86
|
+
router: true,
|
87
|
+
state: true,
|
88
|
+
},
|
89
|
+
server: {
|
90
|
+
ssr: true,
|
91
|
+
},
|
92
|
+
});
|
93
|
+
```
|
94
|
+
|
95
|
+
Re-execute `pnpm run dev`, in the browser Network menu, you can find that the project has completed page rendering at the server level.
|
96
|
+
|
97
|
+
## Build
|
98
|
+
|
99
|
+
Execute `pnpm run build` in the project to build the project production environment product:
|
100
|
+
|
101
|
+
```bash
|
102
|
+
$ pnpm run build
|
103
|
+
|
104
|
+
> modern build
|
105
|
+
|
106
|
+
info Create a production build...
|
107
|
+
|
108
|
+
info File sizes after production build:
|
109
|
+
|
110
|
+
File Size Gzipped
|
111
|
+
dist/static/js/lib-corejs.ffeb7fb8.js 214.96 kB 67.23 kB
|
112
|
+
dist/static/js/lib-react.09721b5c.js 152.61 kB 49.02 kB
|
113
|
+
dist/static/js/218.102e2f39.js 85.45 kB 28.5 kB
|
114
|
+
dist/static/js/lib-babel.a7bba875.js 11.93 kB 3.95 kB
|
115
|
+
dist/html/main/index.html 5.84 kB 2.57 kB
|
116
|
+
dist/static/js/main.3568a38e.js 3.57 kB 1.44 kB
|
117
|
+
dist/static/css/async/304.c3c481a5.css 2.62 kB 874 B
|
118
|
+
dist/asset-manifest.json 1.48 kB 349 B
|
119
|
+
dist/static/js/async/304.c45706bc.js 1.4 kB 575 B
|
120
|
+
dist/static/js/async/509.fcb06e14.js 283 B 230 B
|
121
|
+
|
122
|
+
Client ✔ done in 3.57s
|
123
|
+
```
|
124
|
+
|
125
|
+
The bundle is generated to `dist/` by default, and the directory structure is as follows:
|
126
|
+
|
127
|
+
```
|
128
|
+
.
|
129
|
+
├── asset-manifest.json
|
130
|
+
├── html
|
131
|
+
│ └── main
|
132
|
+
├── loader-routes
|
133
|
+
│ └── main
|
134
|
+
├── modern.config.json
|
135
|
+
├── route.json
|
136
|
+
└── static
|
137
|
+
├── css
|
138
|
+
└── js
|
139
|
+
```
|
140
|
+
|
141
|
+
## Verify
|
142
|
+
|
143
|
+
Execute `pnpm run serve` in the project to verify locally that the bundle is running correctly:
|
144
|
+
|
145
|
+
```bash
|
146
|
+
$ pnpm run serve
|
147
|
+
|
148
|
+
> modern serve
|
149
|
+
|
150
|
+
Starting the modern server...
|
151
|
+
info App running at:
|
152
|
+
|
153
|
+
> Local: http://localhost:8080/
|
154
|
+
> Network: http://10.94.58.87:8080/
|
155
|
+
> Network: http://10.254.68.105:8080/
|
156
|
+
```
|
157
|
+
|
158
|
+
Open http://localhost:8000/ in the browser and the content should be the same as when `pnpm run dev`.
|
159
|
+
|
160
|
+
## Deploy
|
161
|
+
|
162
|
+
After the local verification is completed, the products under `dist/` can be organized into the structure required by the server for deployment.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
---
|
2
|
+
title: Upgrade
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
|
6
|
+
## Upgrade with command
|
7
|
+
|
8
|
+
Modern.js provides the `upgrade` command to support projects to upgrade to the latest version.
|
9
|
+
|
10
|
+
Execute `pnpm run upgrade` in the project:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ pnpm run upgrade
|
14
|
+
|
15
|
+
> modern upgrade
|
16
|
+
|
17
|
+
[INFO] [Project Type]: Application
|
18
|
+
[INFO] [Modern.js Latest Version]: 2.0.0
|
19
|
+
[INFO] Upgrade Modern.js package version success!
|
20
|
+
```
|
21
|
+
|
22
|
+
You can see that the dependency in the project `package.json` has been changed to the latest.
|
23
|
+
|
24
|
+
## Specify version upgrade
|
25
|
+
|
26
|
+
Modern.js all packages are published using the **unified version number**.
|
27
|
+
|
28
|
+
According to the website Release Note, developers can also manually upgrade the project to the desired version.
|
29
|
+
|
30
|
+
:::tip
|
31
|
+
When upgrading, you need to upgrade to all packages provided by the Modern.js, rather than upgrading a single dependency.
|
32
|
+
:::
|
33
|
+
|
34
|
+
## lock child dependency
|
35
|
+
|
36
|
+
When there is a problem with one of the child dependencies of the project, and the Modern.js cannot be updated immediately, you can use the package manager to lock the child dependency version.
|
37
|
+
|
38
|
+
### pnpm
|
39
|
+
|
40
|
+
For projects using pnpm, add the following configuration to the `package.json` in the **project root directory** and re-execute `pnpm install`:
|
41
|
+
|
42
|
+
```json
|
43
|
+
{
|
44
|
+
"pnpm": {
|
45
|
+
"overrides": {
|
46
|
+
"package-name": "^1.0.0"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
### Yarn
|
53
|
+
|
54
|
+
For projects using Yarn, add the following configuration to the `package.json` in the **project root directory** and re-execute `yarn install`:
|
55
|
+
|
56
|
+
```json
|
57
|
+
{
|
58
|
+
"resolutions": {
|
59
|
+
"package-name": "^1.0.0"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Npm
|
65
|
+
|
66
|
+
For projects using Npm, add the following configuration to the `package.json` in the **project root directory** and re-execute `npm install`:
|
67
|
+
|
68
|
+
```json
|
69
|
+
{
|
70
|
+
"overrides": {
|
71
|
+
"package-name": "^1.0.0"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
:::info
|
77
|
+
For Monorepo repositories, the dependency version can only be locked in the `package.json` in the project root directory, and all packages in Monorepo are affected.
|
78
|
+
:::
|
package/{zh/tutorials/first-app → en/docusaurus-plugin-content-docs/current/guides}/overview.md
RENAMED
@@ -2,10 +2,10 @@
|
|
2
2
|
sidebar_position: 0
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# Overview
|
6
6
|
|
7
7
|
import OverviewNav from '@site/src/components/OverviewNav';
|
8
|
-
import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json'
|
9
|
-
import Link from '@docusaurus/Link';
|
10
8
|
|
11
|
-
|
9
|
+
import sidebarData from '@site/plugins/overview-loader!@site/plugins/overview-data.json';
|
10
|
+
|
11
|
+
<OverviewNav cards={sidebarData.docsSidebars.guidesSidebar} />
|
package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/lifecycle.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
title: Lifecycle
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
Modern.js application has a complete lifecycle, including CLI, Server Side and Runtime three stages.
|
7
|
+
|
8
|
+
Modern.js lifecycle is as follows:
|
9
|
+
|
10
|
+
|
11
|
+
:::note
|
12
|
+
The rectangle of the pink box represents the plugin hook provided by the Modern.js, and the light yellow base color ellipse represents the linkage point with the next stage.
|
13
|
+
:::
|
14
|
+
|
15
|
+

|
@@ -40,4 +40,4 @@ It mainly contains the following features:
|
|
40
40
|
|
41
41
|
If you are a front-end beginner, you may find these concepts a bit complicated. We provide some [JavaScript and React](/docs/tutorials/foundations/basic) learning materials, you can do some understanding of them first。
|
42
42
|
|
43
|
-
If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/docs/tutorials/first-app/
|
43
|
+
If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/docs/tutorials/first-app/c01-start), or read [Guide](/docs/guides/overview).
|
@@ -4,7 +4,7 @@
|
|
4
4
|
"description": "The label for version current"
|
5
5
|
},
|
6
6
|
"sidebar.tutorialsSidebar.category.基础": {
|
7
|
-
"message": "
|
7
|
+
"message": "Basic",
|
8
8
|
"description": "The label for category 基础 in sidebar tutorialsSidebar"
|
9
9
|
},
|
10
10
|
"sidebar.tutorialsSidebar.category.创建第一个应用": {
|
@@ -56,23 +56,23 @@
|
|
56
56
|
"description": "The label for category 11: 添加容器组件 in sidebar tutorialsSidebar"
|
57
57
|
},
|
58
58
|
"sidebar.guidesSidebar.category.开始": {
|
59
|
-
"message": "
|
59
|
+
"message": "Start",
|
60
60
|
"description": "The label for category 开始 in sidebar guidesSidebar"
|
61
61
|
},
|
62
62
|
"sidebar.guidesSidebar.category.核心概念": {
|
63
|
-
"message": "
|
63
|
+
"message": "Core Concept",
|
64
64
|
"description": "The label for category 核心概念 in sidebar guidesSidebar"
|
65
65
|
},
|
66
66
|
"sidebar.guidesSidebar.category.基础功能": {
|
67
|
-
"message": "
|
67
|
+
"message": "Basic Features",
|
68
68
|
"description": "The label for category 基础功能 in sidebar guidesSidebar"
|
69
69
|
},
|
70
70
|
"sidebar.guidesSidebar.category.CSS 开发方案": {
|
71
|
-
"message": "CSS
|
71
|
+
"message": "CSS Development",
|
72
72
|
"description": "The label for category CSS 开发方案 in sidebar guidesSidebar"
|
73
73
|
},
|
74
74
|
"sidebar.guidesSidebar.category.进阶功能": {
|
75
|
-
"message": "
|
75
|
+
"message": "Advanced Features",
|
76
76
|
"description": "The label for category 进阶功能 in sidebar guidesSidebar"
|
77
77
|
},
|
78
78
|
"sidebar.guidesSidebar.category.BFF": {
|
@@ -80,15 +80,15 @@
|
|
80
80
|
"description": "The label for category BFF in sidebar guidesSidebar"
|
81
81
|
},
|
82
82
|
"sidebar.guidesSidebar.category.专题详解": {
|
83
|
-
"message": "
|
83
|
+
"message": "Topic Detail",
|
84
84
|
"description": "The label for category 专题详解 in sidebar guidesSidebar"
|
85
85
|
},
|
86
86
|
"sidebar.guidesSidebar.category.Reduck 状态管理": {
|
87
|
-
"message": "Reduck
|
87
|
+
"message": "Reduck State Manager",
|
88
88
|
"description": "The label for category Reduck 状态管理 in sidebar guidesSidebar"
|
89
89
|
},
|
90
90
|
"sidebar.guidesSidebar.category.微前端": {
|
91
|
-
"message": "
|
91
|
+
"message": "Micro-frontend",
|
92
92
|
"description": "The label for category 微前端 in sidebar guidesSidebar"
|
93
93
|
},
|
94
94
|
"sidebar.guidesSidebar.category.Monorepo": {
|
@@ -96,11 +96,11 @@
|
|
96
96
|
"description": "The label for category Monorepo in sidebar guidesSidebar"
|
97
97
|
},
|
98
98
|
"sidebar.guidesSidebar.category.包版本管理": {
|
99
|
-
"message": "
|
99
|
+
"message": "Package Version Manager",
|
100
100
|
"description": "The label for category 包版本管理 in sidebar guidesSidebar"
|
101
101
|
},
|
102
102
|
"sidebar.guidesSidebar.category.自定义插件": {
|
103
|
-
"message": "
|
103
|
+
"message": "Customized plugins",
|
104
104
|
"description": "The label for category 自定义插件 in sidebar guidesSidebar"
|
105
105
|
},
|
106
106
|
"sidebar.guidesSidebar.category.项目生成器": {
|
package/package.json
CHANGED
@@ -11,20 +11,20 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.0.0-beta.
|
14
|
+
"version": "2.0.0-beta.5",
|
15
15
|
"publishConfig": {
|
16
16
|
"registry": "https://registry.npmjs.org/",
|
17
17
|
"access": "public"
|
18
18
|
},
|
19
19
|
"peerDependencies": {
|
20
|
-
"@modern-js/builder-doc": "2.0.0-beta.
|
20
|
+
"@modern-js/builder-doc": "2.0.0-beta.4"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
|
+
"@modern-js/builder-doc": "2.0.0-beta.4",
|
23
24
|
"ts-node": "^10",
|
24
25
|
"fs-extra": "^10",
|
25
26
|
"@types/node": "^16",
|
26
|
-
"@types/fs-extra": "^9"
|
27
|
-
"@modern-js/builder-doc": "2.0.0-beta.3"
|
27
|
+
"@types/fs-extra": "^9"
|
28
28
|
},
|
29
29
|
"scripts": {
|
30
30
|
"build": "npx ts-node ./scripts/sync.ts"
|
@@ -2,10 +2,10 @@
|
|
2
2
|
sidebar_position: 1
|
3
3
|
---
|
4
4
|
|
5
|
-
# dev
|
5
|
+
# dev / start
|
6
6
|
|
7
7
|
```bash
|
8
|
-
Usage: modern dev [options]
|
8
|
+
Usage: modern dev / modern start [options]
|
9
9
|
|
10
10
|
本地开发命令
|
11
11
|
|
@@ -17,10 +17,15 @@ Options:
|
|
17
17
|
--api-only 仅启动 API 接口服务
|
18
18
|
```
|
19
19
|
|
20
|
-
`modern dev`
|
20
|
+
`modern dev` 命令用于启动一个本地开发服务器,对源代码进行开发环境编译,同时监听源文件变化,默认支持模块热更新和 React Fast Refresh。
|
21
|
+
|
22
|
+
`modern start` 是 `modern dev` 命令的别名,两者的功能和用法完全一致。
|
21
23
|
|
22
24
|
```bash
|
23
|
-
|
25
|
+
$ modern dev
|
26
|
+
|
27
|
+
info Starting dev server...
|
28
|
+
info App running at:
|
24
29
|
|
25
30
|
> Local: http://localhost:8080/
|
26
31
|
> Network: http://192.168.0.1:8080/
|
@@ -5,35 +5,56 @@ sidebar_position: 7
|
|
5
5
|
```
|
6
6
|
Usage: modern inspect [options]
|
7
7
|
|
8
|
-
inspect internal webpack config
|
9
|
-
|
10
8
|
Options:
|
11
9
|
--env <env> 查看指定环境下的配置 (default: "development")
|
12
10
|
--output <output> 指定在 dist 目录下输出的路径 (default: "/")
|
13
|
-
--no-console 不在终端中输出完整结果
|
14
11
|
--verbose 在结果中展示函数的完整内容
|
15
12
|
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
|
16
13
|
-h, --help 显示命令帮助
|
17
14
|
```
|
18
15
|
|
19
|
-
`modern inspect` 命令,用于查看项目的 webpack
|
16
|
+
`modern inspect` 命令,用于查看项目的 [Modern.js Builder 配置](https://modernjs.dev/builder/zh/guide/basic/builder-config.html) 以及 webpack 配置。
|
17
|
+
|
18
|
+
在项目根目录下执行命令 `npx modern inspect` 后,会在项目的 `dist` 目录生成以下文件:
|
20
19
|
|
21
|
-
|
20
|
+
- `builder.config.js`: 表示在构建时使用的 Modern.js Builder 配置。
|
21
|
+
- `webpack.config.web.js`: 表示在构建时使用的 webpack 配置。
|
22
|
+
|
23
|
+
```bash
|
24
|
+
➜ npx modern inspect
|
25
|
+
|
26
|
+
Inspect config succeed, open following files to view the content:
|
27
|
+
|
28
|
+
- Builder Config: /root/my-project/dist/builder.config.js
|
29
|
+
- Webpack Config (web): /root/my-project/dist/webpack.config.web.js
|
30
|
+
```
|
22
31
|
|
23
32
|
## 指定环境
|
24
33
|
|
25
|
-
|
34
|
+
默认情况下,inspect 命令会输出开发环境的配置,你可以添加 `--env production` 选项来输出生产环境的配置:
|
26
35
|
|
27
36
|
```bash
|
28
37
|
modern inspect --env production
|
29
38
|
```
|
30
39
|
|
31
|
-
##
|
40
|
+
## 完整内容
|
32
41
|
|
33
|
-
|
42
|
+
默认情况下,inspect 命令会省略配置对象中的函数内容,你可以添加 `--verbose` 选项来输出函数的完整内容:
|
34
43
|
|
35
|
-
|
44
|
+
```bash
|
45
|
+
modern inspect --verbose
|
46
|
+
```
|
36
47
|
|
37
|
-
|
48
|
+
## SSR 构建配置
|
38
49
|
|
39
|
-
如果项目开启了
|
50
|
+
如果项目开启了 SSR 能力,则在 `dist` 目录会另外生成一份 `webpack.config.node.js` 文件,对应 SSR 构建时的 webpack 配置。
|
51
|
+
|
52
|
+
```bash
|
53
|
+
➜ npx modern inspect
|
54
|
+
|
55
|
+
Inspect config succeed, open following files to view the content:
|
56
|
+
|
57
|
+
- Builder Config: /root/my-project/dist/builder.config.js
|
58
|
+
- Webpack Config (web): /root/my-project/dist/webpack.config.web.js
|
59
|
+
- Webpack Config (node): /root/my-project/dist/webpack.config.node.js
|
60
|
+
```
|
@@ -3,9 +3,9 @@ sidebar_position: 6
|
|
3
3
|
---
|
4
4
|
|
5
5
|
```bash
|
6
|
-
Usage: modern
|
6
|
+
Usage: modern serve [options]
|
7
7
|
|
8
|
-
|
8
|
+
run server
|
9
9
|
|
10
10
|
Options:
|
11
11
|
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
|
@@ -13,7 +13,7 @@ Options:
|
|
13
13
|
--api-only 仅启动 API 接口服务
|
14
14
|
```
|
15
15
|
|
16
|
-
通常使用 `modern
|
16
|
+
通常使用 `modern serve` 命令在生产环境下启用应用工程, 需要提前执行 [`build`](/docs/apis/app/commands/build) 命令构建出对应产物。
|
17
17
|
|
18
18
|
默认情况下,应用将会在 `localhost:8080` 启动,可以通过 `server.port` 修改 Server 端口号:
|
19
19
|
|
@@ -12,11 +12,12 @@ sidebar_position: 3
|
|
12
12
|
只需要 `src/index.[tj]s` 默认导出函数:
|
13
13
|
|
14
14
|
```js title=src/index.js
|
15
|
+
import ReactDOM from 'react-dom/client';
|
15
16
|
import { bootstrap } from '@modern-js/runtime';
|
16
17
|
|
17
|
-
export default App => {
|
18
|
+
export default (App: React.ComponentType) => {
|
18
19
|
// do something before bootstrap...
|
19
|
-
bootstrap(App, 'root');
|
20
|
+
bootstrap(App, 'root', undefined, ReactDOM);
|
20
21
|
};
|
21
22
|
```
|
22
23
|
|
@@ -28,8 +29,8 @@ export default App => {
|
|
28
29
|
|
29
30
|
```js title=src/index.jsx
|
30
31
|
import React from 'react';
|
31
|
-
import ReactDOM from 'react-dom';
|
32
|
+
import ReactDOM from 'react-dom/client';
|
32
33
|
import App from './App';
|
33
34
|
|
34
|
-
ReactDOM.
|
35
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
|
35
36
|
```
|