@modern-js/main-doc 0.0.0-next-1686537702987 → 0.0.0-next-1686556197370
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 +22 -2
- package/docs/en/components/bff-proxy-other-config.mdx +0 -0
- package/docs/en/components/enable-bff-caution.mdx +3 -0
- package/docs/en/configure/app/bff/enable-handle-web.mdx +5 -5
- package/docs/en/configure/app/bff/prefix.mdx +6 -6
- package/docs/en/configure/app/bff/proxy.mdx +19 -15
- package/docs/en/configure/app/plugins.mdx +19 -19
- package/docs/en/guides/basic-features/alias.mdx +11 -9
- package/docs/en/guides/basic-features/html.mdx +41 -43
- package/docs/en/guides/topic-detail/framework-plugin/implement.mdx +4 -4
- package/docs/en/guides/topic-detail/framework-plugin/introduction.mdx +1 -1
- package/docs/en/guides/troubleshooting/cli.mdx +13 -13
- package/docs/en/guides/troubleshooting/dependencies.mdx +25 -25
- package/docs/zh/components/bff-proxy-other-config.mdx +0 -0
- package/docs/zh/components/enable-bff-caution.mdx +4 -0
- package/docs/zh/configure/app/bff/enable-handle-web.mdx +3 -3
- package/docs/zh/configure/app/bff/prefix.mdx +2 -3
- package/docs/zh/configure/app/bff/proxy.mdx +10 -6
- package/docs/zh/guides/basic-features/alias.mdx +5 -3
- package/docs/zh/guides/basic-features/html.mdx +9 -9
- package/docs/zh/guides/troubleshooting/cli.mdx +1 -1
- package/docs/zh/guides/troubleshooting/dependencies.mdx +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
# @modern-js/main-doc
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-1686556197370
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 8a932767f: docs(main): update basic features alias doc
|
|
8
|
+
|
|
9
|
+
docs(main): 更新基础功能 -- 别名文档
|
|
10
|
+
|
|
7
11
|
- 7e6fb5fc1: chore: publishConfig add provenance config
|
|
8
12
|
|
|
9
13
|
chore: publishConfig 增加 provenance 配置
|
|
10
14
|
|
|
15
|
+
- 372b950c1: docs(main): update plugin config doc
|
|
16
|
+
|
|
17
|
+
docs(main): 更新插件配置文档
|
|
18
|
+
|
|
19
|
+
- f28b4855c: docs(main): update faq doc
|
|
20
|
+
|
|
21
|
+
docs(main): 更新 faq 文档
|
|
22
|
+
|
|
23
|
+
- f264c4a7f: docs(main): update html template doc
|
|
24
|
+
|
|
25
|
+
docs(main): 更新 HTML 模板文档
|
|
26
|
+
|
|
27
|
+
- d6625cb47: docs(main): update bff config doc
|
|
28
|
+
|
|
29
|
+
docs(main): 更新 BFF 配置文档
|
|
30
|
+
|
|
11
31
|
- Updated dependencies [7e6fb5fc1]
|
|
12
|
-
- @modern-js/builder-doc@0.0.0-next-
|
|
32
|
+
- @modern-js/builder-doc@0.0.0-next-1686556197370
|
|
13
33
|
|
|
14
34
|
## 2.22.1
|
|
15
35
|
|
|
File without changes
|
|
@@ -7,13 +7,13 @@ title: enableHandleWeb
|
|
|
7
7
|
- **Type:** `boolean`
|
|
8
8
|
- **Default:** `false`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
|
|
12
|
-
:::
|
|
10
|
+
import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
<EnableBFFCaution />
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
By default, the BFF service can only handle requests for BFF APIs.
|
|
15
|
+
|
|
16
|
+
When this value is set to `true`, page request will also pass through BFF, and the default logic for page rendering built into Modern.js will run as the last middleware of the BFF service.
|
|
17
17
|
|
|
18
18
|
```ts title="modern.config.ts"
|
|
19
19
|
export default defineConfig({
|
|
@@ -7,18 +7,18 @@ sidebar_label: prefix
|
|
|
7
7
|
- **Type:** `string`
|
|
8
8
|
- **Default:** `/api`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
|
|
12
|
-
:::
|
|
10
|
+
import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
<EnableBFFCaution />
|
|
13
|
+
|
|
14
|
+
By default, the prefix for accessing routes in the BFF API directory is `/api`, as shown in the following directory structure:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
api
|
|
18
18
|
└── hello.ts
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
The corresponding
|
|
21
|
+
The route corresponding to `api/hello.ts` when accessed is `localhost:8080/api/hello`.
|
|
22
22
|
|
|
23
23
|
This configuration option can modify the default route prefix:
|
|
24
24
|
|
|
@@ -30,4 +30,4 @@ export default defineConfig({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The corresponding `api/hello.ts`
|
|
33
|
+
The corresponding route for `api/hello.ts` when accessed is `localhost:8080/api-demo/hello`.
|
|
@@ -7,16 +7,15 @@ sidebar_label: proxy
|
|
|
7
7
|
- **Type:** `Record<string, string>`
|
|
8
8
|
- **Default:** `{}`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
|
|
10
|
+
import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
<EnableBFFCaution />
|
|
14
13
|
|
|
15
|
-
With simple configuration,
|
|
14
|
+
With simple configuration, Modern.js can automatically proxy requests sent to the BFF server to the specified service.
|
|
16
15
|
|
|
17
|
-
BFF Proxy uses the powerful [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
|
|
16
|
+
BFF Proxy uses the powerful [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware). For more advanced usage, please refer to its [documentation](https://github.com/chimurai/http-proxy-middleware#options).
|
|
18
17
|
|
|
19
|
-
Add the following configuration to `modern.server-runtime.config.
|
|
18
|
+
Add the following configuration to `modern.server-runtime.config.js` to enable proxy:
|
|
20
19
|
|
|
21
20
|
```ts title="modern.server-runtime.config.ts"
|
|
22
21
|
import { defineConfig } from '@modern-js/app-tools/server';
|
|
@@ -29,9 +28,9 @@ export default defineConfig({
|
|
|
29
28
|
});
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
Assuming
|
|
31
|
+
Assuming the address of Modern.js BFF server is `localhost:8080`, all requests starting with `api` will be proxied to `https://cnodejs.org`, for example, the request to `localhost:8080/api/v1/topics` will be proxied to `https://cnodejs.org/api/v1/topics`.
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
Path rewriting can also be performed here, such as proxying the request sent to `localhost:8080/api/topics` to `https://cnodejs.org/api/v1/topics`.
|
|
35
34
|
|
|
36
35
|
```js title="modern.server-runtime.config.js"
|
|
37
36
|
import { defineConfig } from '@modern-js/app-tools/server';
|
|
@@ -48,22 +47,25 @@ export default defineConfig({
|
|
|
48
47
|
});
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
Unlike [dev.proxy](/configure/app/dev/proxy), the proxy
|
|
50
|
+
Unlike [dev.proxy](/configure/app/dev/proxy), the proxy here only applies to requests entering the BFF/API service; at the same time, this configuration can not only be used in the development environment, but also proxies corresponding requests in the production environment.
|
|
51
|
+
|
|
52
|
+
import BFFProxyOtherConfig from "@site-docs-en/components/bff-proxy-other-config";
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
<BFFProxyOtherConfig />
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
## Common Usage
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
### Solving Cross-Domain Issues for APIs
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
During project development, cross-domain issues are often encountered because web pages and API services are not deployed under the same domain name.
|
|
61
|
+
There are many ways to solve cross-domain issues, and here we can easily solve them using `bff.proxy`.
|
|
60
62
|
|
|
61
63
|
:::info
|
|
62
|
-
|
|
64
|
+
Under BFF proxy mode, if you don't need to write BFF code, the API directory can be deleted; BFF proxy will still be enabled.
|
|
63
65
|
|
|
64
66
|
:::
|
|
65
67
|
|
|
66
|
-
As shown below, in
|
|
68
|
+
As shown below, the following configuration in `modern.server-runtime.config.ts` will proxy all web page requests starting with `/api` to a service on another domain with the same domain.
|
|
67
69
|
|
|
68
70
|
```ts title="modern.server-runtime.config.ts"
|
|
69
71
|
export default defineServerConfig({
|
|
@@ -74,3 +76,5 @@ export default defineServerConfig({
|
|
|
74
76
|
},
|
|
75
77
|
};
|
|
76
78
|
```
|
|
79
|
+
|
|
80
|
+
|
|
@@ -9,39 +9,39 @@ sidebar_position: 9
|
|
|
9
9
|
|
|
10
10
|
Used to configure custom Modern.js framework plugins.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Refer to [How to Develop Plugins](/guides/topic-detail/framework-plugin/implement) for how to write custom plugins.
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Note
|
|
15
15
|
|
|
16
|
-
This
|
|
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
|
-
-
|
|
18
|
+
- To configure Modern.js Builder plugins, use the [builderPlugins](/configure/app/builder-plugins) option.
|
|
19
|
+
- To configure webpack plugins, use the [tools.webpack](/configure/app/tools/webpack) or [tools.webpackChain](/configure/app/tools/webpack-chain) options.
|
|
20
|
+
- To configure Babel plugins, use the [tools.babel](/configure/app/tools/babel) option.
|
|
21
21
|
|
|
22
|
-
## Plugin
|
|
22
|
+
## Plugin types
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Modern.js has three types of plugins:
|
|
25
25
|
|
|
26
|
-
- `CLI
|
|
27
|
-
- `Server
|
|
28
|
-
- `Runtime
|
|
26
|
+
- `CLI plugins`, applicable to local development, compilation and construction stages, can extend various capabilities in the command line and compilation stages.
|
|
27
|
+
- `Server plugins`, applicable to the server.
|
|
28
|
+
- `Runtime plugins`, applicable to the front-end runtime.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Currently, Modern.js has opened up the ability to customize CLI plugins, and Server plugins and Runtime plugins will be opened up later.
|
|
31
31
|
|
|
32
32
|
## Plugin execution order
|
|
33
33
|
|
|
34
|
-
By default, custom plugins are executed
|
|
34
|
+
By default, custom plugins are executed in the order of the `plugins` array, and the execution time of built-in Modern.js plugins is earlier than that of custom plugins.
|
|
35
35
|
|
|
36
|
-
When the plugin
|
|
36
|
+
When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [Relationship between plugins](/guides/topic-detail/framework-plugin/relationship) for more information.
|
|
37
37
|
|
|
38
38
|
## Example
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
The following is an example of using CLI plugins.
|
|
41
41
|
|
|
42
|
-
###
|
|
42
|
+
### Use plugins on npm
|
|
43
43
|
|
|
44
|
-
To use
|
|
44
|
+
To use plugins from npm registry, you need to first install the plugins , and import them in `modern.config.ts`.
|
|
45
45
|
|
|
46
46
|
```ts title="modern.config.ts"
|
|
47
47
|
import myPlugin from 'my-plugin';
|
|
@@ -53,7 +53,7 @@ export default defineConfig({
|
|
|
53
53
|
|
|
54
54
|
### Use local plugins
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
To use local plugins, import them directly using a relative path.
|
|
57
57
|
|
|
58
58
|
```ts title="modern.config.ts"
|
|
59
59
|
import myPlugin from './config/plugin/myPlugin';
|
|
@@ -65,7 +65,7 @@ export default defineConfig({
|
|
|
65
65
|
|
|
66
66
|
### Plugin configuration
|
|
67
67
|
|
|
68
|
-
If the plugin provides some custom configuration options,
|
|
68
|
+
If the plugin provides some custom configuration options, they can be passed in as parameters to the plugin function.
|
|
69
69
|
|
|
70
70
|
```ts title="modern.config.ts"
|
|
71
71
|
import myPlugin from 'my-plugin';
|
|
@@ -4,7 +4,7 @@ sidebar_position: 8
|
|
|
4
4
|
---
|
|
5
5
|
# Alias
|
|
6
6
|
|
|
7
|
-
Modern.js
|
|
7
|
+
Modern.js allows you to use alias to import modules from custom directories in JS and CSS, and comes with the following built-in alias:
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
10
|
{
|
|
@@ -14,11 +14,11 @@ Modern.js allow aliases in JS and CSS, and the following aliases are built in:
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
:::info
|
|
17
|
-
When
|
|
17
|
+
When enabling optional features, the `new` command will also dynamically add built-in alias specific to the features. For example, when enabling BFF, the `@api` alias is added by default.
|
|
18
18
|
|
|
19
19
|
:::
|
|
20
20
|
|
|
21
|
-
For example,
|
|
21
|
+
For example, importing modules from the `src/common` directory in the `src/App.tsx` file:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
.
|
|
@@ -27,17 +27,19 @@ For example, import the modules from the `src/common/` directory in the `src/App
|
|
|
27
27
|
│ │ └── base.css
|
|
28
28
|
│ └── utils
|
|
29
29
|
│ └── index.ts
|
|
30
|
-
|
|
30
|
+
└── App.tsx
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The code in `src/App.tsx` is as follows:
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
import utils from '@/src/common/utils';
|
|
37
37
|
import '@/src/common/styles/base.css';
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Modern.js also provides a way to
|
|
40
|
+
Modern.js also provides a way to customize alias. For example, adding the `@common` alias is as follows:
|
|
41
|
+
|
|
42
|
+
For TypeScript projects, just set `compilerOptions.paths` in the project's `tsconfig.json`:
|
|
41
43
|
|
|
42
44
|
```json
|
|
43
45
|
{
|
|
@@ -50,9 +52,9 @@ Modern.js also provides a way to config aliases. Adding the `@common` alias as a
|
|
|
50
52
|
}
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
JavaScript
|
|
55
|
+
For JavaScript projects, set `source.alias` in `modern.config.js`:
|
|
54
56
|
|
|
55
|
-
```ts title="modern.config.
|
|
57
|
+
```ts title="modern.config.js"
|
|
56
58
|
export default defineConfig({
|
|
57
59
|
source: {
|
|
58
60
|
alias: {
|
|
@@ -62,4 +64,4 @@ export default defineConfig({
|
|
|
62
64
|
});
|
|
63
65
|
```
|
|
64
66
|
|
|
65
|
-
For
|
|
67
|
+
For the specific usage of alias configuration, please refer to the [source.alias documentation](/configure/app/source/alias).
|
|
@@ -4,13 +4,13 @@ sidebar_position: 9
|
|
|
4
4
|
---
|
|
5
5
|
# HTML Template
|
|
6
6
|
|
|
7
|
-
Modern.js provides **JSX syntax** and **HTML(EJS) syntax**
|
|
7
|
+
Modern.js provides **JSX syntax** and **HTML(EJS) syntax** to customize the HTML template.
|
|
8
8
|
|
|
9
|
-
## JSX
|
|
9
|
+
## JSX Syntax
|
|
10
10
|
|
|
11
|
-
Modern.js
|
|
11
|
+
According to Modern.js conventions, you can create a `Document.[jt]sx` file under `src/` or the entry directory and default export a component". The rendering result of this component can be used as the HTML template of the entry.
|
|
12
12
|
|
|
13
|
-
For example the following directory structure:
|
|
13
|
+
For example, consider the following directory structure:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
.
|
|
@@ -24,44 +24,42 @@ For example the following directory structure:
|
|
|
24
24
|
└── modern-app-env.d.ts
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
`entry-a` will
|
|
27
|
+
`entry-a` will use the `Docoument.[jt]sx` file under the current entry as the template. If there is no `Document.[jt]sx` file under the current entry, like `entry-b`, it will look for the `Document.[jt]sx` file under the root directory.
|
|
28
28
|
|
|
29
|
-
If not,
|
|
29
|
+
If not found, default template will be used.
|
|
30
30
|
|
|
31
|
-
### HTML
|
|
31
|
+
### HTML Components
|
|
32
32
|
|
|
33
|
-
Modern.js provides
|
|
33
|
+
Modern.js provides some components for rendering pages to help developers generate templates. These components can be used from `@modern-js/runtime/document`:
|
|
34
34
|
|
|
35
35
|
```tsx
|
|
36
36
|
import { Html, Body, Root, Head, Scripts } from '@modern-js/runtime/document';
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
- `Html`: provide the ability of native HTML Element and and render necessary components that the developer did not add by default. `<Head>` and `<Body>` must exist, and other components can be assembled as needed.
|
|
40
40
|
|
|
41
|
-
- `
|
|
41
|
+
- `Body`: provide the ability of native Body Element and needs to contain the `<Root>` component internally. It also supports other elements as child elements at the same time, such as adding footers.
|
|
42
42
|
|
|
43
|
-
- `
|
|
43
|
+
- `Root`: the root node `<div id='root'></div>` to be rendered. The default id of the root node is `id = 'root'`. You can set `props.rootId` to change the id attribute. Child components can be added and will be rendered in the HTML template. After React rendering is complete, it will be overwritten and is generally used to implement global Loading.
|
|
44
44
|
|
|
45
|
-
- `
|
|
45
|
+
- `Head`: provide the ability of native Head Element and automatically fills in `<meta>` and `<Scripts>` components.
|
|
46
46
|
|
|
47
|
-
- `
|
|
47
|
+
- `Scripts`: provide the ability to adjust the position of script tags injected into the HTML during the build process. By default, it is placed in the `<Head>` component.
|
|
48
48
|
|
|
49
|
-
- `
|
|
49
|
+
- `Comment`: retain user-written comments like `<!-- gateway -->` and outputs them to the rendered HTML.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
### Template Parameters
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Because it is in JSX format, various variables can be used freely in the component to assign values to various custom components in `Document.[jt]sx`.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Modern.js also provides `DocumentContext` to provide some configuration and environment parameters for easy access. The main parameters are:
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
- `processEnv`: provides the `process.env` during the build.
|
|
58
|
+
- `config`: the configuration of the Modern.js project. Currently, only the output configuration is exposed.
|
|
59
|
+
- `entryName`: the current entry name.
|
|
60
|
+
- `templateParams`: parameters of HTML template (compatible with traditional templates, so it's not recommended for use).
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
- `config`: The configuration of the project, only `output` are exposed.
|
|
61
|
-
- `entryName`: current entry name.
|
|
62
|
-
- `templateParams`: HTML template params(in order to be compatible with traditional templates, it is not recommended to use).
|
|
63
|
-
|
|
64
|
-
### Examples
|
|
62
|
+
### Example
|
|
65
63
|
|
|
66
64
|
```tsx
|
|
67
65
|
import React, { useContext } from 'react';
|
|
@@ -102,7 +100,7 @@ export default function Document(): React.ReactElement {
|
|
|
102
100
|
}
|
|
103
101
|
```
|
|
104
102
|
|
|
105
|
-
The above JSX
|
|
103
|
+
The above JSX components will generate the following HTML template:
|
|
106
104
|
|
|
107
105
|
```html
|
|
108
106
|
<!DOCTYPE html>
|
|
@@ -149,22 +147,22 @@ The above JSX component will generate the following HTML template:
|
|
|
149
147
|
|
|
150
148
|
```
|
|
151
149
|
|
|
152
|
-
##
|
|
150
|
+
## HTML Syntax
|
|
153
151
|
|
|
154
|
-
Modern.js also supports HTML syntax. By default,
|
|
152
|
+
Modern.js also supports HTML syntax. By default, Modern.js application projects will include a built-in HTML template for generating HTML code.
|
|
155
153
|
|
|
156
|
-
Based on HTML syntax
|
|
154
|
+
Based on the HTML syntax template, Modern.js provides two ways to customize the template: **custom HTML fragments** and **custom the whole HTML**.
|
|
157
155
|
|
|
158
156
|
### Custom HTML Fragments
|
|
159
157
|
|
|
160
|
-
|
|
158
|
+
Under the application root directory, create the `config/html/` directory, which supports the creation of four types of HTML fragments:
|
|
161
159
|
|
|
162
160
|
- `top.html`
|
|
163
161
|
- `head.html`
|
|
164
162
|
- `body.html`
|
|
165
163
|
- `bottom.html`
|
|
166
164
|
|
|
167
|
-
**These fragments will be injected into the default HTML template.**
|
|
165
|
+
**These fragments will be injected into the default HTML template according to their positions.**
|
|
168
166
|
|
|
169
167
|
```html
|
|
170
168
|
<!DOCTYPE html>
|
|
@@ -189,44 +187,44 @@ In the application root directory, create the `config/html/` directory, which su
|
|
|
189
187
|
</html>
|
|
190
188
|
```
|
|
191
189
|
|
|
192
|
-
HTML
|
|
190
|
+
HTML fragments support the use of [Lodash template](https://lodash.com/docs/4.17.15#template).
|
|
193
191
|
|
|
194
|
-
For example, insert
|
|
192
|
+
For example, to insert an external script in `body.html`:
|
|
195
193
|
|
|
196
194
|
```html title="config/html/body.html"
|
|
197
195
|
<script src="//example.com/assets/a.js"></script>
|
|
198
196
|
```
|
|
199
197
|
|
|
200
198
|
:::info
|
|
201
|
-
The implementation of
|
|
199
|
+
The implementation of custom HTML fragments is to merge the fragments with the built-in template. Since the `<title>` already exists in the default template, the title tag in the custom HTML template will not take effect. Please use [html.title](/configure/app/html/title) to modify the page title.
|
|
202
200
|
|
|
203
201
|
:::
|
|
204
202
|
|
|
205
|
-
###
|
|
203
|
+
### Custom the entire HTML Template
|
|
206
204
|
|
|
207
|
-
In some cases, HTML
|
|
205
|
+
In some cases, HTML fragments may be is not better meet the customization requirements. Modern.js provides a fully customized way.
|
|
208
206
|
|
|
209
|
-
:::caution
|
|
210
|
-
It is not recommended to override the default HTML template
|
|
207
|
+
:::caution Note
|
|
208
|
+
It is generally not recommended to directly override the default HTML template, as some functional options may be lost. If it is truly necessary to customize the entire HTML template, it is recommended to modify based on the built-in template as needed.
|
|
211
209
|
|
|
212
210
|
:::
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
Under the `config/html/` directory, create an `index.html` file that will replace the default HTML template.
|
|
215
213
|
|
|
216
214
|
:::info
|
|
217
|
-
The
|
|
215
|
+
The default HTML template can be viewed in `node_modules/.modern-js/${entryName}/index.html`.
|
|
218
216
|
|
|
219
217
|
:::
|
|
220
218
|
|
|
221
|
-
### Template
|
|
219
|
+
### Template Parameters
|
|
222
220
|
|
|
223
|
-
The parameters used in the template can be defined by the [html.templateParameters](/configure/app/html/template-parameters).
|
|
221
|
+
The parameters used in the template can be defined by the [html.templateParameters](/configure/app/html/template-parameters) configuration.
|
|
224
222
|
|
|
225
223
|
### Config By Entry
|
|
226
224
|
|
|
227
|
-
The
|
|
225
|
+
The HTML fragments in the `config/html/` directory take effect for all entries in the application. If you want to customize HTML fragments by entry, you can create a directory named after the **entry name** under the `config/html/` directory, and then customize the HTML fragments in this directory.
|
|
228
226
|
|
|
229
|
-
For example, the following HTML
|
|
227
|
+
For example, the following HTML fragments are only effective for the `entry1` entry:
|
|
230
228
|
|
|
231
229
|
```bash
|
|
232
230
|
.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
2
|
+
title: Develop Plugins
|
|
3
3
|
sidebar_position: 3
|
|
4
4
|
---
|
|
5
|
-
# How to
|
|
5
|
+
# How to Develop Plugins
|
|
6
6
|
|
|
7
|
-
The previous section introduced the Hook models used by Modern.js plugins, while this section describes how to
|
|
7
|
+
The previous section introduced the Hook models used by Modern.js plugins, while this section describes how to develop plugins.
|
|
8
8
|
|
|
9
9
|
## Implementing a Plugin
|
|
10
10
|
|
|
@@ -115,7 +115,7 @@ Please refer to [Extending Hooks](/guides/topic-detail/framework-plugin/extend)
|
|
|
115
115
|
|
|
116
116
|
### Plugin Configuration
|
|
117
117
|
|
|
118
|
-
**It is recommended to
|
|
118
|
+
**It is recommended to develop plugins in the form of functions**, so that plugins can receive configuration options through function parameters:
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
121
|
import type { CliPlugin } from '@modern-js/core';
|
|
@@ -33,7 +33,7 @@ Among them, the CLI plugin is the main running flow control model in Modern.js,
|
|
|
33
33
|
|
|
34
34
|
## What Plugins Can Do
|
|
35
35
|
|
|
36
|
-
All of Modern.js's features are implemented through this set of plugins, which means that all of Modern.js's capabilities are open to developers. Developers can
|
|
36
|
+
All of Modern.js's features are implemented through this set of plugins, which means that all of Modern.js's capabilities are open to developers. Developers can develop plugins to extend more functionality and adapt to complex scenarios, including but not limited to:
|
|
37
37
|
|
|
38
38
|
- Registering commands
|
|
39
39
|
- Modifying Modern.js configuration and validation schema
|
|
@@ -4,21 +4,21 @@ sidebar_position: 2
|
|
|
4
4
|
|
|
5
5
|
# CLI FAQ
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Unable to pass command line arguments correctly when using pnpm?
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
There are some differences between pnpm v6 and pnpm v7 in how they execute commands, and the following should be noted:
|
|
10
10
|
|
|
11
11
|
pnpm v7:
|
|
12
12
|
|
|
13
|
-
When using pnpm to
|
|
13
|
+
When using pnpm to call the commands in `package.json`, if you need to pass parameters to pnpm, you need to put the parameters before the command.
|
|
14
14
|
|
|
15
|
-
For example,
|
|
15
|
+
For example, using the pnpm `--filter` parameter to run the prepare command:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
pnpm run --filter "./packages/**" prepare
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
If you need to pass parameters to
|
|
21
|
+
If you need to pass parameters to the command, you need to put the parameters after the command.
|
|
22
22
|
|
|
23
23
|
For example, in the following `package.json` configuration:
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ For example, in the following `package.json` configuration:
|
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The way to
|
|
33
|
+
The way to pass parameters when running the command is:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
pnpm run command --options
|
|
@@ -48,16 +48,16 @@ In the following `package.json` configuration:
|
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
If you need to
|
|
51
|
+
If you need to run `modern command --option`:
|
|
52
52
|
|
|
53
|
-
When using pnpm, you need to
|
|
53
|
+
When using pnpm, you need to run `pnpm run command -- --option`.
|
|
54
54
|
|
|
55
|
-
This is because pnpm
|
|
55
|
+
This is because pnpm's handling of command parameters is different from that of Yarn, but similar to that of npm: when the `--` string is not added, the parameters passed are for pnpm; when the `--` string is used, the parameters passed are for running the script.
|
|
56
56
|
|
|
57
|
-
In the above example the
|
|
57
|
+
In the above example, the `--option` parameter is passed to `modern command`. If you run `pnpm run command --option`, the `--option` parameter will be passed to pnpm.
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
In summary:
|
|
60
60
|
|
|
61
|
-
**When using pnpm v7, if
|
|
61
|
+
**When using pnpm v7, if passing parameters to pnpm, the parameters need to be placed before the command.**
|
|
62
62
|
|
|
63
|
-
**When using pnpm v6, if the
|
|
63
|
+
**When using pnpm v6, if the parameters are passed to pnpm, `--` is not required; if the parameters are passed to the script, the `--` string needs to be added.**
|
|
@@ -6,15 +6,15 @@ sidebar_position: 1
|
|
|
6
6
|
|
|
7
7
|
### How to check the actual installed version of a dependency in the project?
|
|
8
8
|
|
|
9
|
-
You can use the `ls` command
|
|
9
|
+
You can use the `ls` command provided by the package manager to view the version of the dependency in the project.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Here are some basic examples. For detailed usage, please refer to the documentation of each package manager.
|
|
12
12
|
|
|
13
13
|
**npm / yarn**
|
|
14
14
|
|
|
15
|
-
For projects using npm or yarn, the `npm ls` command
|
|
15
|
+
For projects using npm or yarn, you can use the `npm ls` command.
|
|
16
16
|
|
|
17
|
-
For example,
|
|
17
|
+
For example, running `npm ls @modern-js/core` will show the following result:
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
project
|
|
@@ -24,9 +24,9 @@ project
|
|
|
24
24
|
|
|
25
25
|
**pnpm**
|
|
26
26
|
|
|
27
|
-
For projects using pnpm, you can use `pnpm ls` command.
|
|
27
|
+
For projects using pnpm, you can use the `pnpm ls` command.
|
|
28
28
|
|
|
29
|
-
For example,
|
|
29
|
+
For example, running `pnpm ls @modern-js/core --depth Infinity` will show the following result:
|
|
30
30
|
|
|
31
31
|
```
|
|
32
32
|
devDependencies:
|
|
@@ -36,9 +36,9 @@ devDependencies:
|
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
39
|
-
### The engine "node" is incompatible
|
|
39
|
+
### Getting "The engine "node" is incompatible" error during dependency installation?
|
|
40
40
|
|
|
41
|
-
If the following error message
|
|
41
|
+
If you encounter the following error message during dependency installation, it means that the current environment is using a Node.js version that is too low, and you need to upgrade Node.js to a higher version.
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
The engine "node" is incompatible with this module.
|
|
@@ -46,11 +46,11 @@ The engine "node" is incompatible with this module.
|
|
|
46
46
|
Expected version ">=14.17.6". Got "12.20.1"
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
When using Modern.js, it is recommended to use [Node.js 14.x](https://nodejs.org/download/release/latest-v14.x/) or [Node.js 16.x](https://nodejs.org/download/release/latest-v16.x/).
|
|
49
|
+
When using Modern.js, it is recommended to use the latest version of [Node.js 14.x](https://nodejs.org/download/release/latest-v14.x/) or [Node.js 16.x](https://nodejs.org/download/release/latest-v16.x/).
|
|
50
50
|
|
|
51
|
-
If the Node.js version
|
|
51
|
+
If the Node.js version of the current environment is lower than the above requirement, you can use tools such as [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to switch versions.
|
|
52
52
|
|
|
53
|
-
Here
|
|
53
|
+
Here is an example of using nvm:
|
|
54
54
|
|
|
55
55
|
```
|
|
56
56
|
# Install Node.js v14
|
|
@@ -63,13 +63,13 @@ nvm use 14
|
|
|
63
63
|
nvm default 14
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
For local development environments, it is recommended to use [fnm](https://github.com/Schniz/fnm), which has better performance than nvm and has similar usage.
|
|
67
67
|
|
|
68
68
|
---
|
|
69
69
|
|
|
70
|
-
### ReactNode type error after upgrading dependencies?
|
|
70
|
+
### Getting a ReactNode type error after upgrading dependencies?
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
After upgrading the dependencies of the project, if the following type error occurs, it means that the wrong version of `@types/react` is installed in the project.
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
The types returned by 'render()' are incompatible between these types.
|
|
@@ -77,9 +77,9 @@ Type 'React.ReactNode' is not assignable to type 'import("/node_modules/@types/r
|
|
|
77
77
|
Type '{}' is not assignable to type 'ReactNode'.
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
The reason for this problem is that the ReactNode type
|
|
80
|
+
The reason for this problem is that the ReactNode type definition in React 18 is different from that in React 16/17. If there are multiple different versions of `@types/react` in the project, a ReactNode type conflict will occur, resulting in the above error.
|
|
81
81
|
|
|
82
|
-
The solution is to lock `@types/react` and `@types/react-dom` in the project to a unified version, such as `v17`.
|
|
82
|
+
The solution is to lock the `@types/react` and `@types/react-dom` in the project to a unified version, such as `v17`.
|
|
83
83
|
|
|
84
84
|
```json
|
|
85
85
|
{
|
|
@@ -88,23 +88,23 @@ The solution is to lock `@types/react` and `@types/react-dom` in the project to
|
|
|
88
88
|
}
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
For
|
|
91
|
+
For methods of locking dependency versions, please refer to [Lock nested dependency](/guides/get-started/upgrade.html#lock-nested-dependency).
|
|
92
92
|
|
|
93
93
|
---
|
|
94
94
|
|
|
95
|
-
###
|
|
95
|
+
### Getting peer dependencies warnings in the console after running `pnpm install`?
|
|
96
96
|
|
|
97
|
-
The reason for this warning is that the version range of peer dependencies declared by some third-party npm packages
|
|
97
|
+
The reason for this warning is that the version range of peer dependencies declared by some third-party npm packages is inconsistent with the version range installed in Modern.js.
|
|
98
98
|
|
|
99
|
-
In most cases,
|
|
99
|
+
In most cases, peer dependencies warnings will not affect the project operation and do not need to be processed separately. Please ignore the relevant warnings.
|
|
100
100
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
|
-
### What is the minimum
|
|
103
|
+
### What is the minimum supported version of React for the Modern.js framework?
|
|
104
104
|
|
|
105
|
-
The recommended React version for
|
|
105
|
+
**The recommended React version for the Modern.js framework is >= 18.0.0**, and different functions have different requirements for the React version.
|
|
106
106
|
|
|
107
|
-
- If you are using React 17, some framework
|
|
108
|
-
- If you
|
|
107
|
+
- If you are using React 17, some framework functions will not be available, such as Steaming SSR, because it relies on new features provided by React 18.
|
|
108
|
+
- If you are still using React 16, you will not be able to use Modern.js's runtime or server-side capabilities. You can consider using the build mode of Modern.js, that is, only using Modern.js's build capabilities. In this case, React 16 can still be used.
|
|
109
109
|
|
|
110
|
-
In
|
|
110
|
+
In future major versions of Modern.js, we will gradually remove support for React 16 and React 17. Therefore, please upgrade to React 18 or higher as soon as possible.
|
|
File without changes
|
|
@@ -7,9 +7,9 @@ title: enableHandleWeb
|
|
|
7
7
|
- **类型:** `boolean`
|
|
8
8
|
- **默认值:** `false`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import EnableBFFCaution from "@site-docs/components/enable-bff-caution";
|
|
11
|
+
|
|
12
|
+
<EnableBFFCaution />
|
|
13
13
|
|
|
14
14
|
默认情况下,BFF 服务只能处理 BFF API 的请求。
|
|
15
15
|
|
|
@@ -7,10 +7,9 @@ sidebar_label: prefix
|
|
|
7
7
|
- **类型:** `string`
|
|
8
8
|
- **默认值:** `/api`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
请先在当前应用项目根目录使用【[new](/apis/app/commands#modern-new)】 启用 BFF 功能。
|
|
10
|
+
import EnableBFFCaution from "@site-docs/components/enable-bff-caution";
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
<EnableBFFCaution />
|
|
14
13
|
|
|
15
14
|
默认情况下,BFF API 目录下的路由访问前缀是 `/api`, 如下目录结构:
|
|
16
15
|
|
|
@@ -7,12 +7,11 @@ sidebar_label: proxy
|
|
|
7
7
|
- **类型:** `Record<string, string>`
|
|
8
8
|
- **默认值:** `{}`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
请先在当前应用项目根目录使用【[new](/apis/app/commands#modern-new)】 启用 BFF 功能。
|
|
10
|
+
import EnableBFFCaution from "@site-docs/components/enable-bff-caution";
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
<EnableBFFCaution />
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
通过简单配置,Modern.js 可以将发送给 BFF server 的请求,自动代理到指定的服务上。
|
|
16
15
|
BFF Proxy 使用了强大的 [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware),如果需要更多高级的用法, 可以查看它的[文档](https://github.com/chimurai/http-proxy-middleware#options)。
|
|
17
16
|
|
|
18
17
|
在 `modern.server-runtime.config.js` 中加入以下配置;即可开启代理:
|
|
@@ -28,9 +27,9 @@ export default defineConfig({
|
|
|
28
27
|
});
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
假设 Modern.js BFF server 的地址是 `localhost:8080`,所有以 `api` 开头的请求都会被代理到 `https://cnodejs.org`,如 `localhost:8080/api/v1/topics` 的请求会被代理到 `https://cnodejs.org/api/v1/topics`。
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
这里还可以进行路径重写,如将发送到 `localhost:8080/api/topics` 的请求代理到 `https://cnodejs.org/api/v1/topics`。
|
|
34
33
|
|
|
35
34
|
```ts title="modern.server-runtime.config.ts"
|
|
36
35
|
import { defineConfig } from '@modern-js/app-tools/server';
|
|
@@ -49,6 +48,10 @@ export default defineConfig({
|
|
|
49
48
|
|
|
50
49
|
与 [dev.proxy](/configure/app/dev/proxy) 不同,本节所介绍的代理只作用于进入 BFF/API 服务的请求;同时,这一配置不但可以在开发环境中使用,在生产环境中也会代理相应的请求。
|
|
51
50
|
|
|
51
|
+
import BFFProxyOtherConfig from "@site-docs/components/bff-proxy-other-config";
|
|
52
|
+
|
|
53
|
+
<BFFProxyOtherConfig />
|
|
54
|
+
|
|
52
55
|
## 常见用法
|
|
53
56
|
|
|
54
57
|
### 解决接口跨域问题
|
|
@@ -72,3 +75,4 @@ export default defineServerConfig({
|
|
|
72
75
|
},
|
|
73
76
|
};
|
|
74
77
|
```
|
|
78
|
+
|
|
@@ -14,7 +14,7 @@ Modern.js 允许在 JS 和 CSS 中使用别名导入自定义目录下的模块
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
:::info
|
|
17
|
-
|
|
17
|
+
在开启可选功能时,new 命令也会动态的添加内置别名,例如启用 BFF 时默认会添加 `@api` 别名。
|
|
18
18
|
|
|
19
19
|
:::
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ Modern.js 允许在 JS 和 CSS 中使用别名导入自定义目录下的模块
|
|
|
27
27
|
│ │ └── base.css
|
|
28
28
|
│ └── utils
|
|
29
29
|
│ └── index.ts
|
|
30
|
-
|
|
30
|
+
└── App.tsx
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
`src/App.tsx` 中写法如下:
|
|
@@ -37,7 +37,9 @@ import utils from '@/src/common/utils';
|
|
|
37
37
|
import '@/src/common/styles/base.css';
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Modern.js 也提供了自定义别名的方式,以添加 `@common`
|
|
40
|
+
Modern.js 也提供了自定义别名的方式,以添加 `@common` 别名为例:
|
|
41
|
+
|
|
42
|
+
对于 TypeScript 项目,只需要在项目根目录 `tsconfig.json` 下配置 `compilerOptions.paths`:
|
|
41
43
|
|
|
42
44
|
```json
|
|
43
45
|
{
|
|
@@ -9,7 +9,7 @@ Modern.js 提供了 **JSX 语法**和 **HTML(EJS) 语法**两种方式用于自
|
|
|
9
9
|
|
|
10
10
|
## JSX 语法
|
|
11
11
|
|
|
12
|
-
Modern.js 约定,在 `src/`
|
|
12
|
+
Modern.js 约定,在 `src/` 或入口目录下,可以创建 `Document.[jt]sx` 文件并默认导出组件,该组件的渲染结果可以作为入口的 HTML 模板。
|
|
13
13
|
|
|
14
14
|
例如以下目录结构:
|
|
15
15
|
|
|
@@ -27,17 +27,17 @@ Modern.js 约定,在 `src/` 目录下,或在入口目录下,可以创建 `
|
|
|
27
27
|
|
|
28
28
|
`entry-a` 会优先使用当前入口下的 `Docoument.[jt]sx` 文件。如果当前入口没有 `Document.[jt]sx` 文件,例如 `entry-b`,则会查找根目录下的 `Document.[jt]sx` 文件。
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
如果未找到,将会使用 Modern.js 的默认模板。
|
|
31
31
|
|
|
32
32
|
### HTML 组件
|
|
33
33
|
|
|
34
|
-
Modern.js 提供了一些列渲染页面的组件,用来帮助开发者生成模板,可以从 `@modern-js/runtime/document`
|
|
34
|
+
Modern.js 提供了一些列渲染页面的组件,用来帮助开发者生成模板,可以从 `@modern-js/runtime/document` 中使用这些组件:
|
|
35
35
|
|
|
36
36
|
```tsx
|
|
37
37
|
import { Html, Body, Root, Head, Scripts } from '@modern-js/runtime/document';
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
这些组件分别用于渲染:
|
|
41
41
|
|
|
42
42
|
- `Html`:提供原生 HTML Element 的能力,并能默认渲染开发者未添加的必须的组件。`<Head>` 和 `<Body>` 是必须要存在的,其它组件可以按需选择合适的组件进行组装。
|
|
43
43
|
|
|
@@ -57,10 +57,10 @@ import { Html, Body, Root, Head, Scripts } from '@modern-js/runtime/document';
|
|
|
57
57
|
|
|
58
58
|
Modern.js 也提供了 `DocumentContext` 来提供一些配置、环境参数,方便直接获取。主要以下参数:
|
|
59
59
|
|
|
60
|
-
- `processEnv`:提供构建时的 `process.env
|
|
61
|
-
- `config`:Modern.js 项目的配置。目前只暴露出 output
|
|
62
|
-
- `entryName
|
|
63
|
-
- `templateParams`:HTML
|
|
60
|
+
- `processEnv`:提供构建时的 `process.env`。
|
|
61
|
+
- `config`:Modern.js 项目的配置。目前只暴露出 output 相关的配置。
|
|
62
|
+
- `entryName`:当前的入口名。
|
|
63
|
+
- `templateParams`:HTML 模板的参数(为了兼容传统模板,不推荐使用)。
|
|
64
64
|
|
|
65
65
|
### 示例
|
|
66
66
|
|
|
@@ -151,7 +151,7 @@ export default function Document(): React.ReactElement {
|
|
|
151
151
|
|
|
152
152
|
Modern.js 也支持 HTML 语法。默认情况下,Modern.js 的应用工程中会内置一份 HTML 模板,用于生成 HTML 代码。
|
|
153
153
|
|
|
154
|
-
基于 HTML 语法的模板,Modern.js
|
|
154
|
+
基于 HTML 语法的模板,Modern.js 提供了**自定义 HTML 片段**和**完全自定义 HTML 模板**两种方式来自定义模板。
|
|
155
155
|
|
|
156
156
|
### 自定义 HTML 片段
|
|
157
157
|
|
|
@@ -105,6 +105,6 @@ Type '{}' is not assignable to type 'ReactNode'.
|
|
|
105
105
|
**Modern.js 框架推荐使用的 React 版本为 >= 18.0.0**,并且不同功能对 React 版本的要求有所不同。
|
|
106
106
|
|
|
107
107
|
- 如果你在使用 React 17,那么部分框架功能将无法使用,比如 Steaming SSR,因为它依赖 React 18 提供的新特性。
|
|
108
|
-
- 如果你仍然在使用 React 16,那么将无法使用 Modern.js 的运行时或服务端能力。你可以考虑使用 Modern.js 的构建模式,即只使用 Modern.js
|
|
108
|
+
- 如果你仍然在使用 React 16,那么将无法使用 Modern.js 的运行时或服务端能力。你可以考虑使用 Modern.js 的构建模式,即只使用 Modern.js 的构建能力,这种情况可以继续使用 React 16。
|
|
109
109
|
|
|
110
110
|
在 Modern.js 未来的 major 版本中,我们会逐步移除对 React 16 和 React 17 的支持。因此,请尽快升级到 React 18 以上版本。
|
package/package.json
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-next-
|
|
18
|
+
"version": "0.0.0-next-1686556197370",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public",
|
|
22
22
|
"provenance": true
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
25
|
+
"@modern-js/builder-doc": "0.0.0-next-1686556197370"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"classnames": "^2",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"fs-extra": "^10",
|
|
35
35
|
"@types/node": "^16",
|
|
36
36
|
"@types/fs-extra": "^9",
|
|
37
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
38
|
-
"@modern-js/doc-tools": "0.0.0-next-
|
|
39
|
-
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-
|
|
37
|
+
"@modern-js/builder-doc": "0.0.0-next-1686556197370",
|
|
38
|
+
"@modern-js/doc-tools": "0.0.0-next-1686556197370",
|
|
39
|
+
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686556197370"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "modern dev",
|