@modern-js/main-doc 0.0.0-next-1678680921211 → 0.0.0-next-1678718202017
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/en/apis/app/hooks/api/framework/lambda.mdx +3 -3
- package/en/apis/app/hooks/api/functions/api.mdx +3 -3
- package/en/apis/app/hooks/src/routes.mdx +2 -2
- package/en/apis/app/hooks/src/server.mdx +1 -1
- package/en/apis/app/runtime/router/router.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +1 -1
- package/en/apis/app/runtime/web-server/middleware.mdx +1 -1
- package/en/components/enable-bff.mdx +1 -1
- package/en/components/init-app.mdx +3 -3
- package/en/components/init-rspack-app.mdx +3 -3
- package/en/configure/app/output/ssg.mdx +1 -1
- package/en/configure/app/server/public-routes.mdx +1 -1
- package/en/configure/app/server/ssr.mdx +2 -2
- package/en/configure/app/source/design-system.mdx +1 -1
- package/en/configure/app/source/disable-entry-dirs.mdx +1 -1
- package/en/configure/app/source/entries.mdx +2 -2
- package/en/guides/advanced-features/code-split.mdx +1 -1
- package/en/guides/advanced-features/compatibility.mdx +1 -1
- package/en/guides/advanced-features/eslint.mdx +1 -1
- package/en/guides/advanced-features/rspack-start.mdx +2 -2
- package/en/guides/advanced-features/ssg.mdx +2 -2
- package/en/guides/advanced-features/ssr.mdx +1 -1
- package/en/guides/advanced-features/testing.mdx +3 -3
- package/en/guides/advanced-features/web-server.mdx +1 -1
- package/en/guides/basic-features/data-fetch.mdx +4 -4
- package/en/guides/basic-features/env-vars.mdx +5 -5
- package/en/guides/basic-features/html.mdx +15 -15
- package/en/guides/basic-features/proxy.mdx +1 -1
- package/en/guides/get-started/introduction.mdx +1 -1
- package/en/guides/topic-detail/framework-plugin/extend.mdx +1 -1
- package/en/guides/topic-detail/framework-plugin/hook-list.mdx +12 -14
- package/en/guides/topic-detail/framework-plugin/hook.mdx +4 -4
- package/en/guides/topic-detail/framework-plugin/implement.mdx +2 -2
- package/en/guides/topic-detail/framework-plugin/relationship.mdx +2 -2
- package/en/guides/topic-detail/generator/codesmith/api/npm.mdx +1 -1
- package/en/guides/topic-detail/generator/codesmith/develop.mdx +3 -3
- package/en/guides/topic-detail/generator/config/app.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/npm/install.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +15 -15
- package/en/guides/topic-detail/generator/project.mdx +3 -3
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +1 -1
- package/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +2 -2
- package/en/guides/topic-detail/model/computed-state.mdx +1 -1
- package/en/guides/troubleshooting/cli.mdx +1 -1
- package/en/tutorials/first-app/c03-css.mdx +1 -1
- package/package.json +3 -3
- package/zh/apis/monorepo/commands/new.mdx +4 -4
- package/zh/components/default-mwa-generate.mdx +3 -3
- package/zh/components/init-app.mdx +3 -3
- package/zh/components/init-rspack-app.mdx +4 -4
- package/zh/guides/get-started/introduction.mdx +1 -1
- package/zh/guides/topic-detail/changesets/changelog.mdx +8 -8
- package/zh/guides/topic-detail/changesets/commit.mdx +8 -8
- package/zh/guides/topic-detail/changesets/release-note.mdx +8 -8
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +16 -16
- package/zh/guides/topic-detail/monorepo/create-sub-project.mdx +5 -5
- package/zh/guides/topic-detail/monorepo/sub-project-interface.mdx +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -47,9 +47,9 @@ the `$BASENAME` can be configured in `modern.config.js`,the default value is `
|
|
|
47
47
|
By default, all files in the `api/` will be parsed as BFF function. but we also set a allow list, and these files will not be parsed:
|
|
48
48
|
|
|
49
49
|
- file name start with `_`, for example: `_utils.ts`.
|
|
50
|
-
- files in directory that name start with `_`, for example
|
|
51
|
-
- test files, for example
|
|
52
|
-
- TypeScript define files, for example
|
|
50
|
+
- files in directory that name start with `_`, for example: `_utils/index.ts`、`_utils/cp.ts`.
|
|
51
|
+
- test files, for example: `foo.test.ts`.
|
|
52
|
+
- TypeScript define files, for example: `hello.d.ts`.
|
|
53
53
|
- files in `node_module`.
|
|
54
54
|
|
|
55
55
|
## Define Function
|
|
@@ -47,9 +47,9 @@ the `$BASENAME` can be configured in `modern.config.js`,the default value is `
|
|
|
47
47
|
By default, all files in the `api/` will be parsed as BFF function. but we also set a allow list, and these files will not be parsed:
|
|
48
48
|
|
|
49
49
|
- file name start with `_`, for example: `_utils.ts`.
|
|
50
|
-
- files in directory that name start with `_`, for example
|
|
51
|
-
- test files, for example
|
|
52
|
-
- TypeScript define files, for example
|
|
50
|
+
- files in directory that name start with `_`, for example: `_utils/index.ts`、`_utils/cp.ts`.
|
|
51
|
+
- test files, for example: `foo.test.ts`.
|
|
52
|
+
- TypeScript define files, for example: `hello.d.ts`.
|
|
53
53
|
- files in `node_module`.
|
|
54
54
|
|
|
55
55
|
## Define Function
|
|
@@ -8,7 +8,7 @@ The entry identifier when the application uses file system-based routing.
|
|
|
8
8
|
|
|
9
9
|
When the project structure is of type `Routes directory entry`, the files in the `src/routes` directory are parsed to get the client-side routing configuration. See [Routing by convention](/guides/basic-features/routes) for more details on usage.
|
|
10
10
|
|
|
11
|
-
Any `layout.[tj]sx` and `page.[tj]sx` under `src/routes` will be used as a route to the application
|
|
11
|
+
Any `layout.[tj]sx` and `page.[tj]sx` under `src/routes` will be used as a route to the application:
|
|
12
12
|
|
|
13
13
|
```bash {3}
|
|
14
14
|
.
|
|
@@ -22,7 +22,7 @@ Any `layout.[tj]sx` and `page.[tj]sx` under `src/routes` will be used as a route
|
|
|
22
22
|
|
|
23
23
|
## basic example
|
|
24
24
|
|
|
25
|
-
The directory names in the `routes` directory will be used as a mapping of the route url, where `layout.tsx` is used as the layout component and `page.tsx` as the content component, which is a leaf node of the whole route, for example the following directory structure
|
|
25
|
+
The directory names in the `routes` directory will be used as a mapping of the route url, where `layout.tsx` is used as the layout component and `page.tsx` as the content component, which is a leaf node of the whole route, for example the following directory structure:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
.
|
|
@@ -4,7 +4,7 @@ sidebar_position: 8
|
|
|
4
4
|
---
|
|
5
5
|
# *.[server|node].[tj]sx
|
|
6
6
|
|
|
7
|
-
Used in application projects to place server side code, it generally has the following two functions
|
|
7
|
+
Used in application projects to place server side code, it generally has the following two functions:
|
|
8
8
|
|
|
9
9
|
1. When `*.tsx` and `*. [server|node].tsx` coexist, rendering on the server side will give preference to the `*. [server|node].tsx` file instead of the `*.tsx` file.
|
|
10
10
|
|
|
@@ -208,7 +208,7 @@ interface RouteObject {
|
|
|
208
208
|
|
|
209
209
|
`Route` represents the route information. A `Route` object couples URL segments to components, data loading and data mutations.
|
|
210
210
|
|
|
211
|
-
`Route` can be used as a plain object, passing to the router creation functions
|
|
211
|
+
`Route` can be used as a plain object, passing to the router creation functions:
|
|
212
212
|
|
|
213
213
|
```ts
|
|
214
214
|
const router = createBrowserRouter([
|
|
@@ -92,7 +92,7 @@ type AfterRenderContext = {
|
|
|
92
92
|
- `request`: provides a series of methods to get request info.
|
|
93
93
|
- `router`: provides methods on routing.
|
|
94
94
|
- `template`: provides methods on content.
|
|
95
|
-
- `next`: call next listener
|
|
95
|
+
- `next`: call next listener (not affect the server process, only current hook).
|
|
96
96
|
|
|
97
97
|
## Example
|
|
98
98
|
|
|
@@ -81,7 +81,7 @@ type MiddlewareContext = {
|
|
|
81
81
|
- `response`: provides a series of methods to process the response.
|
|
82
82
|
- `request`: provides a series of methods to get request info.
|
|
83
83
|
- `source`: provides Node.js native `req` and `res` object.
|
|
84
|
-
- `next`: call next listener
|
|
84
|
+
- `next`: call next listener (not affect the server process, only current hook).
|
|
85
85
|
|
|
86
86
|
:::warning
|
|
87
87
|
The execution of the `next` function does not affect built-in processes, only controls whether the next middleware executes. Rendering processes are interrupted only when the response is written.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
1. Execute `pnpm new` and select "Enable BFF"
|
|
2
|
-
2. Add the following code to `modern.config.[tj]s` according to the chosen runtime framework
|
|
2
|
+
2. Add the following code to `modern.config.[tj]s` according to the chosen runtime framework:
|
|
3
3
|
|
|
4
4
|
import { Tabs, Tab as TabItem } from "@theme";
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Modern.js generator will provide an interactive Q & A interface, initialization items according to the result, according to the default selection:
|
|
2
2
|
|
|
3
3
|
```bash
|
|
4
|
-
? Please select the solution you want to create: Web App
|
|
4
|
+
? Please select the solution you want to create: Web App
|
|
5
5
|
? Development Language: TS
|
|
6
|
-
? Package
|
|
6
|
+
? Package Manager: pnpm
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
After create the project, Modern.js automatically installs dependency and creates a git repository.
|
|
@@ -12,7 +12,7 @@ After create the project, Modern.js automatically installs dependency and create
|
|
|
12
12
|
[INFO] dependencies are automatically installed
|
|
13
13
|
[INFO] git repository has been automatically created
|
|
14
14
|
[INFO] Success!
|
|
15
|
-
You can run the following command in the directory of the new project
|
|
15
|
+
You can run the following command in the directory of the new project:
|
|
16
16
|
pnpm run dev # Run and debug the project according to the requirements of the development environment
|
|
17
17
|
pnpm run build # Build the project according to the requirements of the product environment
|
|
18
18
|
pnpm run serve # Run the project according to the requirements of the product environment
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
```bash
|
|
2
2
|
$ npx @modern-js/create myapp
|
|
3
|
-
? Please select the solution you want to create: Web App
|
|
3
|
+
? Please select the solution you want to create: Web App
|
|
4
4
|
? Development Language: TS
|
|
5
|
-
? Package
|
|
6
|
-
?
|
|
5
|
+
? Package Manager: pnpm
|
|
6
|
+
? Bundler: Rspack
|
|
7
7
|
```
|
|
@@ -61,7 +61,7 @@ Also using the above configuration, after executing `pnpm run build`, only the e
|
|
|
61
61
|
|
|
62
62
|
`output.ssg` can also be configured according to the entries, and the rules that the configuration takes effect are also determined by the entries routing method.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
For example the following directory structure:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
.
|
|
@@ -9,7 +9,7 @@ sidebar_label: publicRoutes
|
|
|
9
9
|
|
|
10
10
|
This configuration option only applies to server-level routing, and you can customize the access route of resources in `config/public/`.
|
|
11
11
|
|
|
12
|
-
The `key` of the object is the relative file path of the current application (not used
|
|
12
|
+
The `key` of the object is the relative file path of the current application (not used `./`), value can be `string`.
|
|
13
13
|
|
|
14
14
|
```ts title="modern.config.ts"
|
|
15
15
|
export default defineConfig({
|
|
@@ -25,8 +25,8 @@ export default defineConfig({
|
|
|
25
25
|
|
|
26
26
|
When the value type is `Object`, The following properties can be configured:
|
|
27
27
|
|
|
28
|
-
- `mode
|
|
29
|
-
- `forceCSR
|
|
28
|
+
- `mode`: `string = 'string'`, use `renderToString` rendering default. onfigure 'stream' to enable streaming rendering.
|
|
29
|
+
- `forceCSR`: `boolean = false`, forced CSR rendering is disable by default. When configured as `true`, add `?csr=true` in URL to force CSR.
|
|
30
30
|
|
|
31
31
|
```ts title="modern.config.ts"
|
|
32
32
|
export default defineConfig({
|
|
@@ -646,7 +646,7 @@ const designSystem = {
|
|
|
646
646
|
```
|
|
647
647
|
|
|
648
648
|
:::tip
|
|
649
|
-
More about
|
|
649
|
+
More about: <a href="https://tailwindcss.com/docs/configuration#theme" target="_blank">TailwindCSS configuration</a>.
|
|
650
650
|
|
|
651
651
|
:::
|
|
652
652
|
|
|
@@ -10,7 +10,7 @@ sidebar_label: disableEntryDirs
|
|
|
10
10
|
|
|
11
11
|
By default, application entries are identified based on the'src 'directory, you can disable some directories from being identified as application entries with this option.
|
|
12
12
|
|
|
13
|
-
For example, when the configuration and directory structure is as follows
|
|
13
|
+
For example, when the configuration and directory structure is as follows:
|
|
14
14
|
|
|
15
15
|
```ts title="modern.config.ts"
|
|
16
16
|
export default defineConfig({
|
|
@@ -60,8 +60,8 @@ export default defineConfig({
|
|
|
60
60
|
|
|
61
61
|
When the value is `Object`, the following properties can be configured:
|
|
62
62
|
|
|
63
|
-
- `entry
|
|
64
|
-
- `disableMount
|
|
63
|
+
- `entry`: `string`,entry file path.
|
|
64
|
+
- `disableMount`: `boolean = false`,turn off Modern.js generate entry code.
|
|
65
65
|
|
|
66
66
|
```ts title="modern.config.ts"
|
|
67
67
|
import { defineConfig } from '@modern-js/app-tools';
|
|
@@ -45,7 +45,7 @@ Modern.js also provides a runtime Polyfill solution based on browser [UA](https:
|
|
|
45
45
|
- It will not be inserted into the code, reducing the code .
|
|
46
46
|
- The same browser will share a Polyfill code. Therefore, with more and more projects, the UA-based Polyfill code will be delivered faster and faster.
|
|
47
47
|
|
|
48
|
-
exec `pnpm run new` to enable this features
|
|
48
|
+
exec `pnpm run new` to enable this features:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
? Action Enable features
|
|
@@ -4,7 +4,7 @@ sidebar_position: 8
|
|
|
4
4
|
---
|
|
5
5
|
# ESLint
|
|
6
6
|
|
|
7
|
-
**Modern.js ESLint Rules**
|
|
7
|
+
**Modern.js ESLint Rules** is the full set of **ESLint** rules,includes `@modern-js` (Lint rules for Node.js projects) and `@modern-js-app` (Lint rules for web projects).
|
|
8
8
|
|
|
9
9
|
More ESLint usage is described below with specific questions.
|
|
10
10
|
|
|
@@ -39,8 +39,8 @@ You can enable Rspack build by running `pnpm run new`:
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
$ pnpm run new
|
|
42
|
-
? Action
|
|
43
|
-
? Enable features
|
|
42
|
+
? Action: Enable features
|
|
43
|
+
? Enable features: Enable Rspack Build
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
After executing the command, enable the Rspack build in `modern.config.ts`:
|
|
@@ -58,7 +58,7 @@ If you don't know the rules for routing, you can first check [routes](/guides/ba
|
|
|
58
58
|
|
|
59
59
|
:::
|
|
60
60
|
|
|
61
|
-
add component to `src/routes/page.tsx
|
|
61
|
+
add component to `src/routes/page.tsx`:
|
|
62
62
|
|
|
63
63
|
```jsx title="src/routes/page.tsx"
|
|
64
64
|
export default () => {
|
|
@@ -66,7 +66,7 @@ export default () => {
|
|
|
66
66
|
};
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
SSG is also render in Node.js. So we can enable SSR in developmenet env, expose code problems in advance and verify SSG rendering effect
|
|
69
|
+
SSG is also render in Node.js. So we can enable SSR in developmenet env, expose code problems in advance and verify SSG rendering effect:
|
|
70
70
|
|
|
71
71
|
```ts title="modern.config.ts"
|
|
72
72
|
export default defineConfig({
|
|
@@ -307,7 +307,7 @@ The streaming SSR of Modern.js is implemented based on React Router, and the mai
|
|
|
307
307
|
|
|
308
308
|
- [`defer`](https://reactrouter.com/en/main/utils/defer): This utility allows you to defer values returned from loaders by passing promises instead of resolved values.
|
|
309
309
|
- [`Await`](https://reactrouter.com/en/main/components/await): Used to render deferred values with automatic error handling.
|
|
310
|
-
- [`useAsyncValue`](https://reactrouter.com/en/main/hooks/use-async-value)
|
|
310
|
+
- [`useAsyncValue`](https://reactrouter.com/en/main/hooks/use-async-value): Returns the resolved data from the nearest `<Await>` ancestor component.
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
### Return async data
|
|
@@ -6,11 +6,11 @@ title: Testing
|
|
|
6
6
|
|
|
7
7
|
Modern.js inherits the testing capabilities of [Jest](https://jestjs.io/) by default.
|
|
8
8
|
|
|
9
|
-
First need to execute `pnpm run new` enable [unit test/integration test] features
|
|
9
|
+
First need to execute `pnpm run new` enable [unit test/integration test] features:
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
? Action
|
|
13
|
-
? Enable features
|
|
12
|
+
? Action: Enable features
|
|
13
|
+
? Enable features: Enable Unit Test / Integration Test
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
After executing the above command, the `"test": "modern test"` command will be automatically generated in package.json.
|
|
@@ -68,7 +68,7 @@ Projects should have the following best practices when using Hook:
|
|
|
68
68
|
3. Do HTML content injection in afterRender.
|
|
69
69
|
|
|
70
70
|
:::note
|
|
71
|
-
For more detail, see [Hook](/apis/app/runtime/web-server/hook)
|
|
71
|
+
For more detail, see [Hook](/apis/app/runtime/web-server/hook).
|
|
72
72
|
:::
|
|
73
73
|
|
|
74
74
|
### Middleware
|
|
@@ -73,11 +73,11 @@ When navigating on the client side, all loader functions under `/user` and `/use
|
|
|
73
73
|
|
|
74
74
|
### `loader` function
|
|
75
75
|
|
|
76
|
-
The `loader` function has two input parameters
|
|
76
|
+
The `loader` function has two input parameters:
|
|
77
77
|
|
|
78
78
|
##### `Params`
|
|
79
79
|
|
|
80
|
-
When a routing file is passed through `[]`, it is passed as a [dynamic route](/guides/basic-features/routes#dynamic-route) and the dynamic route fragment is passed as an argument to the loader function
|
|
80
|
+
When a routing file is passed through `[]`, it is passed as a [dynamic route](/guides/basic-features/routes#dynamic-route) and the dynamic route fragment is passed as an argument to the loader function:
|
|
81
81
|
|
|
82
82
|
```tsx
|
|
83
83
|
// routes/user/[id]/page.loader.tsx
|
|
@@ -111,7 +111,7 @@ export default async ({ request }: LoaderFunctionArgs) => {
|
|
|
111
111
|
|
|
112
112
|
#### Return value
|
|
113
113
|
|
|
114
|
-
The return value of the `loader` function can be anything serializable, or it can be a [Fetch Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance
|
|
114
|
+
The return value of the `loader` function can be anything serializable, or it can be a [Fetch Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance:
|
|
115
115
|
|
|
116
116
|
```tsx
|
|
117
117
|
const loader = async (): Promise<ProfileData> => {
|
|
@@ -138,7 +138,7 @@ const loader = async (): Promise<ProfileData> => {
|
|
|
138
138
|
|
|
139
139
|
### Request API
|
|
140
140
|
|
|
141
|
-
Modern.js does a polyfill of the `fetch` API to initiate requests, which is consistent with the browser's `fetch` API, but can also be used on the server side to initiate requests, meaning that both CSRs and SSRs can use the unified `fetch` API for data fetching
|
|
141
|
+
Modern.js does a polyfill of the `fetch` API to initiate requests, which is consistent with the browser's `fetch` API, but can also be used on the server side to initiate requests, meaning that both CSRs and SSRs can use the unified `fetch` API for data fetching:
|
|
142
142
|
|
|
143
143
|
```tsx
|
|
144
144
|
function loader() {
|
|
@@ -16,9 +16,9 @@ The current path prefix of resource file, which is a **read-only** environment
|
|
|
16
16
|
|
|
17
17
|
The current execution environment and is a **read-only** environment variable whose have different values under different execution commands:
|
|
18
18
|
|
|
19
|
-
- `production
|
|
20
|
-
- `test
|
|
21
|
-
- `development
|
|
19
|
+
- `production`: the default value when exec `modern build` or `modern serve`.
|
|
20
|
+
- `test`: the default value when exec `modern test`.
|
|
21
|
+
- `development`: the default value when exec `modern dev`, alse the default value of other case.
|
|
22
22
|
|
|
23
23
|
### MODERN_ENV
|
|
24
24
|
|
|
@@ -88,8 +88,8 @@ BAR=456
|
|
|
88
88
|
|
|
89
89
|
The `.env` file follows the following loading rules:
|
|
90
90
|
|
|
91
|
-
- `.env
|
|
92
|
-
- `.env.{ MODERN_ENV | NODE_ENV }
|
|
91
|
+
- `.env`: default.
|
|
92
|
+
- `.env.{ MODERN_ENV | NODE_ENV }`: Setting environment variables for a specific environment overrides the same in `.env`.
|
|
93
93
|
|
|
94
94
|
When you need to use different config according to the environment, you can define environment variables in the `.env` file corresponding to the environment name, and manually set the execution environment when starting the project.
|
|
95
95
|
|
|
@@ -38,15 +38,15 @@ import { Html, Body, Root, Head, Scripts } from '@modern-js/runtime/document';
|
|
|
38
38
|
|
|
39
39
|
These components are rendered:
|
|
40
40
|
|
|
41
|
-
- `Html
|
|
41
|
+
- `Html`: Provide the ability of native HTML Elements, and render necessary components that the developer did not add by default. `<Head>` and `<Body>` must exist, and other components can be assembled by selecting appropriate components on demand.
|
|
42
42
|
|
|
43
|
-
- `Body
|
|
43
|
+
- `Body`: Provide the ability of native Body Element, which needs to contain the `<Root>` component internally, and also supports other elements as child elements at the same time, such as adding footers.
|
|
44
44
|
|
|
45
|
-
- `Root
|
|
45
|
+
- `Root`: React root element `<div id='root'></div>`. the default element id is `id = 'root'`, can set `props.rootId` to change the id.Child components can be added, and will also be rendered into HTML templates, which will be overwritten when React rendering is complete, generally used to implement global Loading.
|
|
46
46
|
|
|
47
|
-
- `Head
|
|
47
|
+
- `Head`: Provides native Head Element capabilities and automatically populates `<meta>`, as well as the `<Scripts>` component.
|
|
48
48
|
|
|
49
|
-
- `Scripts
|
|
49
|
+
- `Scripts`: The script content generated by the webpack, which can be used to adjust the position of the bundle result, is placed in the `<Head>` component by default.
|
|
50
50
|
|
|
51
51
|
### Template Params
|
|
52
52
|
|
|
@@ -54,10 +54,10 @@ Because it is in the form of JSX, in `Document.[jt]sx`, you can use various vari
|
|
|
54
54
|
|
|
55
55
|
At the same time, Modern.js provides `DocumentContext` to provide some configuration and environment parameters, The main parameters as follow:
|
|
56
56
|
|
|
57
|
-
- `processEnv
|
|
58
|
-
- `config
|
|
59
|
-
- `entryName
|
|
60
|
-
- `templateParams
|
|
57
|
+
- `processEnv`: Provide build-time env vars.
|
|
58
|
+
- `config`: The configuration of the project, only `output` are exposed.
|
|
59
|
+
- `entryName`: current entry name.
|
|
60
|
+
- `templateParams`: HTML template params(in order to be compatible with traditional templates, it is not recommended to use).
|
|
61
61
|
|
|
62
62
|
### Examples
|
|
63
63
|
|
|
@@ -87,9 +87,9 @@ export default function Document(): React.ReactElement {
|
|
|
87
87
|
</Head>
|
|
88
88
|
<Body>
|
|
89
89
|
<Root rootId="root">
|
|
90
|
-
<h1 style={{ color: 'red' }}>Some Params
|
|
91
|
-
<h2> entryName
|
|
92
|
-
<h2> title
|
|
90
|
+
<h1 style={{ color: 'red' }}>Some Params: </h1>
|
|
91
|
+
<h2> entryName: {entryName}</h2>
|
|
92
|
+
<h2> title: {htmlConfig.title}</h2>
|
|
93
93
|
<h2> rootId: {templateParams.mountId}</h2>
|
|
94
94
|
</Root>
|
|
95
95
|
<h1>bottom</h1>
|
|
@@ -137,9 +137,9 @@ The above JSX component will generate the following HTML template:
|
|
|
137
137
|
<body>
|
|
138
138
|
<div id="root">
|
|
139
139
|
{/* <?- html ?> */}
|
|
140
|
-
<h1 style="color:red">Some Params
|
|
141
|
-
<h2>entryName
|
|
142
|
-
<h2>title
|
|
140
|
+
<h1 style="color:red">Some Params: </h1>
|
|
141
|
+
<h2>entryName: sub</h2>
|
|
142
|
+
<h2>title: </h2>
|
|
143
143
|
<h2>rootId: root</h2>
|
|
144
144
|
</div>
|
|
145
145
|
<h1>bottom</h1>
|
|
@@ -52,7 +52,7 @@ export default defineConfig({
|
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
For example, when a BFF call is used in the code, the final request `http://localhost:8080/api/v1/topics` will auto proxy to `https://cnodejs.org/api/v1/topics
|
|
55
|
+
For example, when a BFF call is used in the code, the final request `http://localhost:8080/api/v1/topics` will auto proxy to `https://cnodejs.org/api/v1/topics`:
|
|
56
56
|
|
|
57
57
|
```js
|
|
58
58
|
import getTopics from '@api/v1/topics';
|
|
@@ -9,7 +9,7 @@ sidebar_position: 1
|
|
|
9
9
|
|
|
10
10
|
Currently, Modern.js includes three solutions, each targeting at different development scenarios: web application development, npm package development, and document site development:
|
|
11
11
|
|
|
12
|
-

|
|
13
13
|
|
|
14
14
|
As a part of the Modern.js engineering system, each of these solutions can be used separately and has its own independent documentation site. Developers can choose one or more solutions as needed.
|
|
15
15
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
title: Hook List
|
|
3
3
|
sidebar_position: 8
|
|
4
4
|
---
|
|
5
|
+
|
|
5
6
|
# Hook List
|
|
6
7
|
|
|
7
8
|
Modern.js exposes three types of plugins: CLI, Runtime, and Server.
|
|
@@ -91,7 +92,7 @@ export default defineConfig({
|
|
|
91
92
|
});
|
|
92
93
|
```
|
|
93
94
|
|
|
94
|
-
then throw error
|
|
95
|
+
then throw error:
|
|
95
96
|
|
|
96
97
|
```sh
|
|
97
98
|
$ modern dev
|
|
@@ -124,11 +125,11 @@ export default (): CliPlugin => ({
|
|
|
124
125
|
|
|
125
126
|
### `afterPrepare`
|
|
126
127
|
|
|
127
|
-
- function
|
|
128
|
-
- Execution Phase
|
|
129
|
-
- Hook model
|
|
130
|
-
- type
|
|
131
|
-
- Usage
|
|
128
|
+
- function: Running tasks after the prepare process
|
|
129
|
+
- Execution Phase: After the prepare process
|
|
130
|
+
- Hook model: AsyncWorkflow
|
|
131
|
+
- type: `AsyncWorkflow<void, void>`
|
|
132
|
+
- Usage:
|
|
132
133
|
|
|
133
134
|
```ts
|
|
134
135
|
import type { CliPlugin } from '@modern-js/core';
|
|
@@ -399,11 +400,11 @@ export default (): CliPlugin => ({
|
|
|
399
400
|
|
|
400
401
|
### `modifyEntryExport`
|
|
401
402
|
|
|
402
|
-
-
|
|
403
|
-
-
|
|
404
|
-
- Hook
|
|
405
|
-
-
|
|
406
|
-
-
|
|
403
|
+
- Function: used to modify the `export` statement in the generated entry file
|
|
404
|
+
- Execution Stage: Before the entry file is generated, the [`prepare`](#prepare) phase triggers
|
|
405
|
+
- Hook Model: AsyncWaterfall
|
|
406
|
+
- Type: `AsyncWaterfall<{ entrypoint: Entrypoint; exportStatement: string; }>`
|
|
407
|
+
- Example of use:
|
|
407
408
|
|
|
408
409
|
```ts
|
|
409
410
|
import type { CliPlugin } from '@modern-js/core';
|
|
@@ -622,7 +623,6 @@ Plugins are also supported in the Server section of the application project. The
|
|
|
622
623
|
- Type: `AsyncPipeline<ServerInitInput, InitExtension>`
|
|
623
624
|
- Usage Example:
|
|
624
625
|
|
|
625
|
-
|
|
626
626
|
```ts
|
|
627
627
|
import type { ServerPlugin } from '@modern-js/server-core';
|
|
628
628
|
|
|
@@ -783,7 +783,6 @@ export default (): Plugin => ({
|
|
|
783
783
|
- Type: `AsyncPipeline<{ App: React.ComponentType<any>; context?: RuntimeContext; rootElement: HTMLElement; }, void>`
|
|
784
784
|
- Usage Example:
|
|
785
785
|
|
|
786
|
-
|
|
787
786
|
```ts
|
|
788
787
|
import ReactDOM from 'react-dom';
|
|
789
788
|
import type { Plugin } from '@modern-js/runtime';
|
|
@@ -810,7 +809,6 @@ export default (): Plugin => ({
|
|
|
810
809
|
- Type: `AsyncPipeline<{ App: React.ComponentType<any>; context?: RuntimeContext; }, string>`
|
|
811
810
|
- Usage Example:
|
|
812
811
|
|
|
813
|
-
|
|
814
812
|
```ts
|
|
815
813
|
import ReactDomServer from 'react-dom/server';
|
|
816
814
|
import type { Plugin } from '@modern-js/runtime';
|
|
@@ -32,13 +32,13 @@ pipeline.run(1); // 4
|
|
|
32
32
|
pipeline.run(5); // 12
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
In this example, a `Pipeline<number, number>` is created on line 3. This means that when you run it, you need to pass in a `number`, and you will get a `number` as a result,the type is
|
|
35
|
+
In this example, a `Pipeline<number, number>` is created on line 3. This means that when you run it, you need to pass in a `number`, and you will get a `number` as a result,the type is:
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
38
|
(count: number, next: (nextCount: number) => number) => number;
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
The reason why there are only `number`s here is because we created a `Pipeline<number, number>`. If we had created a `Pipeline<number, string>`, then when we run it, we would pass in a `number` and get back a `string`. the type is
|
|
41
|
+
The reason why there are only `number`s here is because we created a `Pipeline<number, number>`. If we had created a `Pipeline<number, string>`, then when we run it, we would pass in a `number` and get back a `string`. the type is:
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
44
|
(count: number, next: (nextCount: number) => string) => string;
|
|
@@ -104,7 +104,7 @@ pipeline(
|
|
|
104
104
|
|
|
105
105
|
### Waterfall
|
|
106
106
|
|
|
107
|
-
This model, as the name suggests, is characterized by the sequential passing of parameters, where the return value of the previous function becomes the input parameter of the next function. Let's look at an example
|
|
107
|
+
This model, as the name suggests, is characterized by the sequential passing of parameters, where the return value of the previous function becomes the input parameter of the next function. Let's look at an example::
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
110
|
import { createWaterfall } from '@modern-js/plugin';
|
|
@@ -125,7 +125,7 @@ waterfall.run(1); // 4
|
|
|
125
125
|
waterfall.run(5); // 12
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
In this example, a `Waterfall<number>` type is created, which means that the input and output types of this model are the same. In this case, both the input and output types are `number`, the type is
|
|
128
|
+
In this example, a `Waterfall<number>` type is created, which means that the input and output types of this model are the same. In this case, both the input and output types are `number`, the type is:
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
131
|
(count: number) => number;
|
|
@@ -155,7 +155,7 @@ export default (): CliPlugin => ({
|
|
|
155
155
|
});
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
For more detail [Plugin API](/guides/topic-detail/framework-plugin/plugin-api)
|
|
158
|
+
For more detail [Plugin API](/guides/topic-detail/framework-plugin/plugin-api).
|
|
159
159
|
|
|
160
160
|
### Async setup
|
|
161
161
|
|
|
@@ -218,7 +218,7 @@ First, create an empty module project solution and adjust the package name:
|
|
|
218
218
|
}
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
create plugin main file
|
|
221
|
+
create plugin main file:
|
|
222
222
|
|
|
223
223
|
```ts title=src/index.ts
|
|
224
224
|
import type { CliPlugin } from '@modern-js/core';
|
|
@@ -63,7 +63,7 @@ If you use the `post` parameter in the `bar` plugin's configuration and set it t
|
|
|
63
63
|
|
|
64
64
|
The rivals field can be used to declare a mutual exclusion relationship between plugins.
|
|
65
65
|
|
|
66
|
-
there are two plugin
|
|
66
|
+
there are two plugin:
|
|
67
67
|
|
|
68
68
|
```ts title=foo.ts
|
|
69
69
|
const foo = {
|
|
@@ -84,7 +84,7 @@ The `bar` plugin has been configured with the `foo` plugin in the `rivals` field
|
|
|
84
84
|
|
|
85
85
|
The `required` field can be used to declare a dependency relationship between plugins.
|
|
86
86
|
|
|
87
|
-
there are two plugin
|
|
87
|
+
there are two plugin:
|
|
88
88
|
|
|
89
89
|
```ts title=foo.ts
|
|
90
90
|
const foo = {
|
|
@@ -4,7 +4,7 @@ sidebar_position: 7
|
|
|
4
4
|
|
|
5
5
|
# @modern-js/codesmith-api-npm
|
|
6
6
|
|
|
7
|
-
The NPM API encapsulation in the microgenerator provides a common method for installing dependencies of different NPM package
|
|
7
|
+
The NPM API encapsulation in the microgenerator provides a common method for installing dependencies of different NPM package managers.
|
|
8
8
|
|
|
9
9
|
## Use
|
|
10
10
|
|
|
@@ -12,9 +12,9 @@ Modern.js provides a microgenerator to create a microgenerator project, you can
|
|
|
12
12
|
$ mkdir <projectDir>
|
|
13
13
|
$ npx @modern-js/codesmith-cli @modern-js/generator-generator
|
|
14
14
|
|
|
15
|
-
? Package Name <generatorName>
|
|
16
|
-
? Package
|
|
17
|
-
? Development Language TS
|
|
15
|
+
? Package Name: <generatorName>
|
|
16
|
+
? Package Manager: pnpm
|
|
17
|
+
? Development Language: TS
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Add template file
|
|
@@ -6,7 +6,7 @@ sidebar_position: 1
|
|
|
6
6
|
|
|
7
7
|
Install dependency in the project root directory.
|
|
8
8
|
|
|
9
|
-
In the install function, the dependency will be installed using the corresponding package
|
|
9
|
+
In the install function, the dependency will be installed using the corresponding package manager based on the value of `packageManager`.
|
|
10
10
|
|
|
11
11
|
Its type is defined as:
|
|
12
12
|
|
|
@@ -17,25 +17,25 @@ Different plugin types will ask different questions. You can choose the plugin t
|
|
|
17
17
|
### Extension type
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
? Please select the solution you want to create Module
|
|
21
|
-
? Please select the scene you want to create
|
|
22
|
-
? Plugin Package Name plugin
|
|
23
|
-
? Development Language TS
|
|
24
|
-
? Package
|
|
25
|
-
? Plugin Type extend
|
|
26
|
-
? Plugin Base Type Web App
|
|
20
|
+
? Please select the solution you want to create: Npm Module
|
|
21
|
+
? Please select the scene you want to create: Generator Plugin
|
|
22
|
+
? Plugin Package Name: plugin
|
|
23
|
+
? Development Language: TS
|
|
24
|
+
? Package Manager: pnpm
|
|
25
|
+
? Plugin Type: extend
|
|
26
|
+
? Plugin Base Type: Web App
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### Customized type
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
? Plugin Package Name plugin
|
|
33
|
-
? Development Language TS
|
|
34
|
-
? Package
|
|
35
|
-
? Plugin Type custom
|
|
36
|
-
? Plugin Key mobile-app
|
|
37
|
-
? Plugin Show Name Mobile App
|
|
38
|
-
? Plugin Base Type Web App
|
|
32
|
+
? Plugin Package Name: plugin
|
|
33
|
+
? Development Language: TS
|
|
34
|
+
? Package Manager: pnpm
|
|
35
|
+
? Plugin Type: custom
|
|
36
|
+
? Plugin Key: mobile-app
|
|
37
|
+
? Plugin Show Name: Mobile App
|
|
38
|
+
? Plugin Base Type: Web App
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
After the execution of the create project command is completed, a project for developing the generator plugin will be generated accordingly, and the `meta` information will also be generated according to your selection in the `package.json`.
|
|
@@ -57,7 +57,7 @@ A brief introduction to the provided methods, the complete API list viewable [Ge
|
|
|
57
57
|
|
|
58
58
|
- addInputBefore
|
|
59
59
|
|
|
60
|
-
Add input before the default input, such as adding questions before the `Select package
|
|
60
|
+
Add input before the default input, such as adding questions before the `Select package manager` question.
|
|
61
61
|
|
|
62
62
|
Specific Modern.js configuration viewable for each problem [Project Solution Configuration](/guides/topic-detail/generator/config/common).
|
|
63
63
|
|
|
@@ -47,9 +47,9 @@ By default, `@modern-js/create` will automatically identify the user's system la
|
|
|
47
47
|
|
|
48
48
|
Specifies the project default configuration.
|
|
49
49
|
|
|
50
|
-
By default, `@modern-js/create` will have interaction problems such as language selection and package
|
|
50
|
+
By default, `@modern-js/create` will have interaction problems such as language selection and package managers during execution. When you need to specify these configuration contents in advance, you can pass in this field.
|
|
51
51
|
|
|
52
|
-
This field is a JSON character string, for example when running a package
|
|
52
|
+
This field is a JSON character string, for example when running a package manager:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
55
|
npx @modern-js/create --config '{"packageManager": "pnpm"}'
|
|
@@ -113,6 +113,6 @@ For custom microgenerators, please refer to [Develop Microgenerator](/guides/top
|
|
|
113
113
|
|
|
114
114
|
A project is created by specifying a specific package version dependency.
|
|
115
115
|
|
|
116
|
-
If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will lock the package version number in the `package.json` of the project root directory by configuration `pnpm.overrides` (package
|
|
116
|
+
If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will lock the package version number in the `package.json` of the project root directory by configuration `pnpm.overrides` (package manager selects pnpm) or `resolutions`.
|
|
117
117
|
|
|
118
118
|
The parameter value is a JSON character string.
|
|
@@ -148,7 +148,7 @@ Here, the activation route of **Table** is customized as **/table** through the
|
|
|
148
148
|
|
|
149
149
|
Use `useModuleApp` api in Main App, get `MApp` component and then render it
|
|
150
150
|
|
|
151
|
-
```tsx title=Main App
|
|
151
|
+
```tsx title=Main App: App.tsx
|
|
152
152
|
import { useModuleApp } from '@modern-js/plugin-garfish/runtime';
|
|
153
153
|
|
|
154
154
|
function App() {
|
|
@@ -8,7 +8,7 @@ title: Communicate
|
|
|
8
8
|
|
|
9
9
|
In Modern.js, the sub-application will be wrapped into a React component, and the purpose of communicating between the main application and the sub-application can be achieved directly by passing'props' to the React component.
|
|
10
10
|
|
|
11
|
-
```tsx title=Main
|
|
11
|
+
```tsx title=Main: App.tsx
|
|
12
12
|
function App() {
|
|
13
13
|
const { MApp } = useModuleApps();
|
|
14
14
|
|
|
@@ -20,7 +20,7 @@ function App() {
|
|
|
20
20
|
}
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
```tsx title=Main
|
|
23
|
+
```tsx title=Main: App.tsx
|
|
24
24
|
function App(props) {
|
|
25
25
|
console.log(props);
|
|
26
26
|
return ...
|
|
@@ -26,7 +26,7 @@ For example, the todo application has `items` and `filter` in its State, and `fi
|
|
|
26
26
|
const todoModel = model('todo').define({
|
|
27
27
|
state: {
|
|
28
28
|
items: [],
|
|
29
|
-
filter: 'ALL', // ALL: show all;COMPLETED
|
|
29
|
+
filter: 'ALL', // ALL: show all;COMPLETED: show completed;ACTIVE: show active
|
|
30
30
|
},
|
|
31
31
|
computed: {
|
|
32
32
|
visibleTodos: state => {
|
|
@@ -8,7 +8,7 @@ sidebar_position: 2
|
|
|
8
8
|
|
|
9
9
|
The pnpm v6 and pnpm v7 versions do not use the same posture when executing commands. The following should be noted:
|
|
10
10
|
|
|
11
|
-
pnpm v7
|
|
11
|
+
pnpm v7:
|
|
12
12
|
|
|
13
13
|
When using pnpm to invoke a command in `package.json`, if you need to pass arguments to pnpm, you need to put the arguments before the command.
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.0-next-
|
|
14
|
+
"version": "0.0.0-next-1678718202017",
|
|
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-
|
|
20
|
+
"@modern-js/builder-doc": "0.0.0-next-1678718202017"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"ts-node": "^10",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"fs-extra": "^10",
|
|
26
26
|
"@types/node": "^16",
|
|
27
27
|
"@types/fs-extra": "^9",
|
|
28
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
28
|
+
"@modern-js/builder-doc": "0.0.0-next-1678718202017"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "npx ts-node ./scripts/sync.ts"
|
|
@@ -21,10 +21,10 @@ Options:
|
|
|
21
21
|
```bash
|
|
22
22
|
$ modern new
|
|
23
23
|
? 请选择你想创建的工程类型 (Use arrow keys)
|
|
24
|
-
❯ 应用
|
|
25
|
-
应用(测试)
|
|
26
|
-
模块
|
|
27
|
-
模块(内部)
|
|
24
|
+
❯ Web 应用
|
|
25
|
+
Web 应用(测试)
|
|
26
|
+
Npm 模块
|
|
27
|
+
Npm 模块(内部)
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
应用工程默认会添加到 `apps` 目录, 测试应用会添加到 `examples` 目录,公共模块默认会添加到 `packages` 目录, 内部模块默认会添加到 `features` 目录。
|
|
@@ -9,7 +9,7 @@ sidebar_position: 1
|
|
|
9
9
|
|
|
10
10
|
目前 Modern.js 包含三个解决方案,分别面向 Web 应用开发场景、npm 包开发场景和文档站开发场景:
|
|
11
11
|
|
|
12
|
-

|
|
13
13
|
|
|
14
14
|
作为 Modern.js 工程体系的一部分,以上每个解决方案都可以被单独使用,并且各自部署了独立的文档站点。开发者可以按需选择其中的一个或多个解决方案来使用。
|
|
15
15
|
|
|
@@ -167,10 +167,10 @@ module.exports = {
|
|
|
167
167
|
#### 使用 `npx @modern-js/create` 创建模块工程方案。
|
|
168
168
|
|
|
169
169
|
```md
|
|
170
|
-
?
|
|
171
|
-
?
|
|
172
|
-
?
|
|
173
|
-
?
|
|
170
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
171
|
+
? 请填写项目名称:custom-changelog
|
|
172
|
+
? 请选择开发语言:TS
|
|
173
|
+
? 请选择包管理工具:pnpm
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
#### 实现自定义内容。
|
|
@@ -201,10 +201,10 @@ export async function getDependencyReleaseLine() {}
|
|
|
201
201
|
#### 执行 `pnpm run new` 创建模块子项目。
|
|
202
202
|
|
|
203
203
|
```md
|
|
204
|
-
?
|
|
205
|
-
?
|
|
206
|
-
?
|
|
207
|
-
?
|
|
204
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
205
|
+
? 请填写子项目名称:custom-changelog
|
|
206
|
+
? 请填写子项目目录名称:custom-changelog
|
|
207
|
+
? 请选择开发语言:TS
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
#### 实现自定义内容。
|
|
@@ -200,10 +200,10 @@ commit 配置为 ./my-commit-config.js 即可:
|
|
|
200
200
|
#### 使用 `npx @modern-js/create` 创建模块工程方案。
|
|
201
201
|
|
|
202
202
|
```md
|
|
203
|
-
?
|
|
204
|
-
?
|
|
205
|
-
?
|
|
206
|
-
?
|
|
203
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
204
|
+
? 请填写项目名称:custom-commit
|
|
205
|
+
? 请选择开发语言:TS
|
|
206
|
+
? 请选择包管理工具:pnpm
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
#### 实现自定义内容。
|
|
@@ -234,10 +234,10 @@ export async function getVersionMessage() {}
|
|
|
234
234
|
#### 执行 `pnpm run new` 创建模块子项目。
|
|
235
235
|
|
|
236
236
|
```md
|
|
237
|
-
?
|
|
238
|
-
?
|
|
239
|
-
?
|
|
240
|
-
?
|
|
237
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
238
|
+
? 请填写子项目名称:custom-commit
|
|
239
|
+
? 请填写子项目目录名称:custom-commit
|
|
240
|
+
? 请选择开发语言:TS
|
|
241
241
|
```
|
|
242
242
|
|
|
243
243
|
#### 实现自定义内容。
|
|
@@ -197,10 +197,10 @@ custom 参数值还可以使用模块工程方案进行管理,提供通用方
|
|
|
197
197
|
1. 使用 npx @modern-js/create 创建模块工程方案。
|
|
198
198
|
|
|
199
199
|
```md
|
|
200
|
-
?
|
|
201
|
-
?
|
|
202
|
-
?
|
|
203
|
-
?
|
|
200
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
201
|
+
? 请填写项目名称:custom-release-note
|
|
202
|
+
? 请选择开发语言:TS
|
|
203
|
+
? 请选择包管理工具:pnpm
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
2. 实现自定义内容。
|
|
@@ -226,10 +226,10 @@ pnpm run gen-release-note -- --custom custom-release-note
|
|
|
226
226
|
1. 执行 `pnpm run new` 创建模块子项目
|
|
227
227
|
|
|
228
228
|
```md
|
|
229
|
-
?
|
|
230
|
-
?
|
|
231
|
-
?
|
|
232
|
-
?
|
|
229
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
230
|
+
? 请填写子项目名称:custom-release-note
|
|
231
|
+
? 请填写子项目目录名称:custom-release-note
|
|
232
|
+
? 请选择开发语言:TS
|
|
233
233
|
```
|
|
234
234
|
|
|
235
235
|
2. 实现自定义内容。
|
|
@@ -17,27 +17,27 @@ npx @modern-js/create plugin --plugin @modern-js/generator-plugin-plugin
|
|
|
17
17
|
### 扩展工程方案
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
?
|
|
21
|
-
?
|
|
22
|
-
?
|
|
23
|
-
?
|
|
24
|
-
?
|
|
25
|
-
?
|
|
26
|
-
?
|
|
20
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
21
|
+
? 请选择项目场景:生成器插件
|
|
22
|
+
? 插件包名:plugin
|
|
23
|
+
? 请选择开发语言:TS
|
|
24
|
+
? 请选择包管理工具:pnpm
|
|
25
|
+
? 插件类型:扩展
|
|
26
|
+
? 插件基础类型:应用
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### 创建工程方案场景
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
?
|
|
33
|
-
?
|
|
34
|
-
?
|
|
35
|
-
?
|
|
36
|
-
?
|
|
37
|
-
?
|
|
38
|
-
?
|
|
39
|
-
?
|
|
40
|
-
?
|
|
32
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
33
|
+
? 请选择项目场景:生成器插件
|
|
34
|
+
? 插件包名:plugin
|
|
35
|
+
? 请选择开发语言:TS
|
|
36
|
+
? 请选择包管理工具:pnpm
|
|
37
|
+
? 插件类型:自定义
|
|
38
|
+
? 插件关键字:mobile-app
|
|
39
|
+
? 插件展示名称:移动应用
|
|
40
|
+
? 插件基础类型:应用
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
创建项目命令执行完成后,会对应的生成一个开发生成器插件的项目,`package.json` 中也会根据你的选择对应的生成 `meta` 信息。
|
|
@@ -28,10 +28,10 @@ pnpm run new
|
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
? 请选择你想创建的工程类型 (Use arrow keys)
|
|
31
|
-
❯ 应用
|
|
32
|
-
应用(测试)
|
|
33
|
-
模块
|
|
34
|
-
模块(内部)
|
|
31
|
+
❯ Web 应用
|
|
32
|
+
Web 应用(测试)
|
|
33
|
+
Npm 模块
|
|
34
|
+
Npm 模块(内部)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
:::info
|
|
@@ -49,7 +49,7 @@ pnpm run new
|
|
|
49
49
|
然后根据不同的需求选择对应的类型项目选项,选择之后便开始出现对应子项目类型的问题和选项。例如选择「应用」后会出现:
|
|
50
50
|
|
|
51
51
|
```
|
|
52
|
-
?
|
|
52
|
+
? 请选择你想创建的工程类型:Web应用
|
|
53
53
|
? 请填写子项目名称
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -19,28 +19,28 @@ sidebar_position: 3
|
|
|
19
19
|
**「应用」子项目:**
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
?
|
|
23
|
-
?
|
|
24
|
-
?
|
|
25
|
-
?
|
|
22
|
+
? 请选择你想创建的工程类型:Web 应用
|
|
23
|
+
? 请填写子项目名称:app
|
|
24
|
+
? 请填写子项目目录名称:app
|
|
25
|
+
? 请选择开发语言:TS
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
**「模块(内部)」子项目:**
|
|
29
29
|
|
|
30
30
|
```
|
|
31
|
-
?
|
|
32
|
-
?
|
|
33
|
-
?
|
|
34
|
-
?
|
|
31
|
+
? 请选择你想创建的工程类型:Npm 模块(内部)
|
|
32
|
+
? 请填写子项目名称:internal-lib
|
|
33
|
+
? 请填写子项目目录名称:internal-lib
|
|
34
|
+
? 请选择开发语言:TS
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
**「模块」子项目:**
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
?
|
|
41
|
-
?
|
|
42
|
-
?
|
|
43
|
-
?
|
|
40
|
+
? 请选择你想创建的工程类型:Npm 模块
|
|
41
|
+
? 请填写子项目名称:components
|
|
42
|
+
? 请填写子项目目录名称:components
|
|
43
|
+
? 请选择开发语言:TS
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
创建成功后,会得到以下项目:
|