@modern-js/main-doc 2.6.0 → 2.8.0
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/CHANGELOG.md +17 -0
- package/README.md +2 -2
- package/en/apis/app/commands.mdx +2 -0
- package/en/apis/app/hooks/config/upload.mdx +10 -0
- package/en/apis/app/runtime/model/connect.mdx +1 -1
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +2 -2
- package/en/apis/app/runtime/web-server/middleware.mdx +33 -9
- package/en/components/enable-bff.mdx +4 -4
- package/en/components/init-rspack-app.mdx +7 -0
- package/en/configure/app/bff/enable-handle-web.mdx +24 -0
- package/en/configure/app/server/enable-framework-ext.mdx +1 -1
- package/en/configure/app/server/ssr.mdx +18 -0
- package/en/guides/advanced-features/bff/_category_.json +1 -1
- package/en/guides/advanced-features/eslint.mdx +30 -32
- package/en/guides/advanced-features/low-level.mdx +1 -1
- package/en/guides/advanced-features/rspack-start.mdx +13 -17
- package/en/guides/advanced-features/ssr.mdx +210 -5
- package/en/guides/advanced-features/web-server.mdx +87 -20
- package/en/guides/{css/tailwindcss.mdx → basic-features/css.mdx} +60 -3
- package/en/guides/basic-features/env-vars.mdx +4 -0
- package/en/guides/concept/builder.mdx +1 -1
- package/en/guides/topic-detail/framework-plugin/extend.mdx +20 -19
- package/en/guides/topic-detail/framework-plugin/hook-list.mdx +156 -155
- package/en/guides/topic-detail/framework-plugin/hook.mdx +58 -43
- package/en/guides/topic-detail/framework-plugin/implement.mdx +47 -49
- package/en/guides/topic-detail/framework-plugin/introduction.mdx +22 -23
- package/en/guides/topic-detail/framework-plugin/plugin-api.mdx +13 -13
- package/en/guides/topic-detail/framework-plugin/relationship.mdx +30 -30
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +17 -17
- package/en/guides/topic-detail/micro-frontend/c02-development.mdx +76 -78
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +57 -51
- package/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +11 -11
- package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +13 -13
- package/en/guides/topic-detail/model/auto-actions.mdx +18 -21
- package/en/guides/topic-detail/model/computed-state.mdx +27 -25
- package/en/guides/topic-detail/model/define-model.mdx +14 -14
- package/en/guides/topic-detail/model/faq.mdx +12 -13
- package/en/guides/topic-detail/model/manage-effects.mdx +43 -52
- package/en/guides/topic-detail/model/model-communicate.mdx +47 -45
- package/en/guides/topic-detail/model/performance.mdx +22 -23
- package/en/guides/topic-detail/model/quick-start.mdx +29 -28
- package/en/guides/topic-detail/model/redux-integration.mdx +7 -7
- package/en/guides/topic-detail/model/test-model.mdx +11 -11
- package/en/guides/topic-detail/model/typescript-best-practice.mdx +16 -15
- package/en/guides/topic-detail/model/use-model.mdx +40 -45
- package/en/guides/topic-detail/model/use-out-of-modernjs.mdx +16 -16
- package/en/guides/troubleshooting/cli.mdx +2 -2
- package/en/tutorials/first-app/c03-css.mdx +1 -1
- package/package.json +5 -5
- package/zh/apis/app/commands.mdx +2 -0
- package/zh/apis/app/hooks/config/upload.mdx +12 -2
- package/zh/apis/app/runtime/model/connect.mdx +1 -1
- package/zh/apis/app/runtime/model/model_.mdx +1 -1
- package/zh/apis/app/runtime/model/use-model.mdx +1 -1
- package/zh/apis/app/runtime/web-server/hook.mdx +2 -4
- package/zh/apis/app/runtime/web-server/middleware.mdx +30 -10
- package/zh/apis/monorepo/commands/gen-release-note.mdx +3 -3
- package/zh/components/enable-bff.mdx +4 -4
- package/zh/components/init-rspack-app.mdx +7 -0
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/bff/enable-handle-web.mdx +24 -0
- package/zh/configure/app/server/enable-framework-ext.mdx +1 -1
- package/zh/configure/app/server/ssr.mdx +19 -1
- package/zh/guides/advanced-features/bff/_category_.json +1 -1
- package/zh/guides/advanced-features/rspack-start.mdx +13 -17
- package/zh/guides/advanced-features/ssr.mdx +210 -4
- package/zh/guides/advanced-features/web-server.mdx +81 -16
- package/zh/guides/{css/tailwindcss.mdx → basic-features/css.mdx} +60 -3
- package/zh/guides/basic-features/env-vars.mdx +4 -0
- package/zh/guides/concept/builder.mdx +1 -1
- package/zh/guides/topic-detail/changesets/github.mdx +2 -2
- package/zh/guides/topic-detail/changesets/release-note.mdx +1 -1
- package/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +2 -2
- package/zh/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/zh/guides/topic-detail/model/faq.mdx +1 -1
- package/zh/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/topic-detail/model/performance.mdx +1 -1
- package/zh/guides/topic-detail/model/quick-start.mdx +2 -2
- package/zh/guides/topic-detail/model/use-model.mdx +3 -3
- package/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/en/guides/css/_category_.json +0 -5
- package/en/guides/css/css-in-js.mdx +0 -40
- package/en/guides/css/css-modules.mdx +0 -87
- package/en/guides/css/less-sass.mdx +0 -17
- package/en/guides/css/postcss.mdx +0 -79
- package/zh/guides/css/_category_.json +0 -5
- package/zh/guides/css/css-in-js.mdx +0 -40
- package/zh/guides/css/css-modules.mdx +0 -87
- package/zh/guides/css/less-sass.mdx +0 -17
- package/zh/guides/css/postcss.mdx +0 -80
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# @modern-js/main-doc
|
2
|
+
|
3
|
+
## 2.8.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- ea7bb41e30: feat: add custom web server docs
|
8
|
+
feat: 添加自定义 Web Server 文档
|
9
|
+
- 1104a9f18b: feat: support start web service only
|
10
|
+
feat: 支持只启动 web 服务
|
11
|
+
- bd58566b32: Fix Typo
|
12
|
+
|
13
|
+
修复 Typo
|
14
|
+
|
15
|
+
- Updated dependencies [9736c6a43d]
|
16
|
+
- Updated dependencies [2c1151271d]
|
17
|
+
- @modern-js/builder-doc@2.8.0
|
package/README.md
CHANGED
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
|
|
19
19
|
|
20
20
|
## Contributing
|
21
21
|
|
22
|
-
Please read the [Contributing Guide](https://github.com/
|
22
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
23
23
|
|
24
24
|
## License
|
25
25
|
|
26
|
-
Modern.js is [MIT licensed](https://github.com/
|
26
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
package/en/apis/app/commands.mdx
CHANGED
@@ -20,6 +20,7 @@ Options:
|
|
20
20
|
-c --config <config> configuration file path, which can be a relative path or an absolute path
|
21
21
|
-h, --help show command help
|
22
22
|
--analyze analyze the bundle and view size of each module
|
23
|
+
--web-only only start web service
|
23
24
|
--api-only only start API service
|
24
25
|
```
|
25
26
|
|
@@ -161,6 +162,7 @@ Usage: modern serve [options]
|
|
161
162
|
Options:
|
162
163
|
-c --config <config> configuration file path, which can be a relative path or an absolute path
|
163
164
|
-h, --help show command help
|
165
|
+
--web-only only run web service
|
164
166
|
--api-only only run API service
|
165
167
|
```
|
166
168
|
|
@@ -26,6 +26,16 @@ If the file ends with `.min.js`, it will not compression.
|
|
26
26
|
|
27
27
|
## More Usage
|
28
28
|
|
29
|
+
In React components, this prefix can be added via [built-in environment variables](/guides/basic-features/env-vars.html#asset_prefix):
|
30
|
+
|
31
|
+
```tsx
|
32
|
+
export default () => {
|
33
|
+
return (
|
34
|
+
<img src={`${process.env.ASSET_PREFIX}/upload/banner.png`}></img>
|
35
|
+
);
|
36
|
+
};
|
37
|
+
```
|
38
|
+
|
29
39
|
Whether in [custom HTML](/guides/basic-features/html), or in any HTML file under ['config/public/'](/apis/app/hooks/config/public), you can directly use the HTML tag to refer to the resources in the `config/upload/`:
|
30
40
|
|
31
41
|
```html
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
9
9
|
<ReduckTip />
|
10
10
|
|
11
11
|
:::tip
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**connect**](https://github.com/
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**connect**](https://github.com/web-infra-dev/reduck/blob/main/packages/react/src/connect.ts).
|
13
13
|
|
14
14
|
:::
|
15
15
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
9
9
|
<ReduckTip />
|
10
10
|
|
11
11
|
:::tip
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/model.ts).
|
13
13
|
|
14
14
|
:::
|
15
15
|
|
@@ -9,7 +9,7 @@ import ReduckTip from "@site-docs-en/components/reduck-tip"
|
|
9
9
|
<ReduckTip />
|
10
10
|
|
11
11
|
:::tip
|
12
|
-
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/
|
12
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/web-infra-dev/reduck/blob/main/packages/store/src/model/model.ts).
|
13
13
|
|
14
14
|
:::
|
15
15
|
|
@@ -3,7 +3,7 @@ title: Hook
|
|
3
3
|
---
|
4
4
|
# Hook
|
5
5
|
|
6
|
-
Used to extend Modern.js built-in Web Server,
|
6
|
+
Used to extend Modern.js built-in Web Server, all page requests are handled by these hooks.
|
7
7
|
|
8
8
|
:::note
|
9
9
|
For more detail, see [Extend Web Server](/guides/advanced-features/web-server).
|
@@ -63,7 +63,7 @@ type HookContext = {
|
|
63
63
|
function Hook(context: HookContext, next: NextFunction): Promsie<void> | void;
|
64
64
|
```
|
65
65
|
|
66
|
-
different Hooks additionally provide different contexts. Currently Modern.js support `
|
66
|
+
different Hooks additionally provide different contexts. Currently Modern.js support `AfterMatch` and `AfterRender`.
|
67
67
|
|
68
68
|
```ts
|
69
69
|
type AfterMatchContext = HookContext & {
|
@@ -3,9 +3,7 @@ title: Middleware
|
|
3
3
|
---
|
4
4
|
# Middleware
|
5
5
|
|
6
|
-
Used to extend
|
7
|
-
|
8
|
-
Unlike [Hook](/apis/app/runtime/web-server/hook), middleware can be extended using the framework plugin.
|
6
|
+
Used to extend the built-in Web Server of Modern.js, unlike [Hook](/apis/app/runtime/web-server/hook), Middleware can directly operate Node's origin request and response, and can be extended using the framework plugin.
|
9
7
|
|
10
8
|
:::note
|
11
9
|
For more detail, see [Extend Web Server](/guides/advanced-features/web-server).
|
@@ -38,6 +36,11 @@ pnpm run new
|
|
38
36
|
## Function Signature
|
39
37
|
|
40
38
|
```ts
|
39
|
+
type Middleware = (
|
40
|
+
context: MiddlewareContext,
|
41
|
+
next: NextFunction,
|
42
|
+
) => Promise<void> | void;
|
43
|
+
|
41
44
|
type MiddlewareContext = {
|
42
45
|
response: {
|
43
46
|
set: (key: string, value: string) => void;
|
@@ -70,11 +73,6 @@ type MiddlewareContext = {
|
|
70
73
|
res: ServerResponse;
|
71
74
|
};
|
72
75
|
};
|
73
|
-
|
74
|
-
type RequestHandler = (
|
75
|
-
context: Context,
|
76
|
-
next: NextFunction,
|
77
|
-
) => Promise<void> | void;
|
78
76
|
```
|
79
77
|
|
80
78
|
### Input
|
@@ -85,6 +83,10 @@ type RequestHandler = (
|
|
85
83
|
- `source`: provides Node.js native `req` and `res` object.
|
86
84
|
- `next`: call next listener(not affect the server process, only current hook).
|
87
85
|
|
86
|
+
:::warning
|
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.
|
88
|
+
:::
|
89
|
+
|
88
90
|
## Example
|
89
91
|
|
90
92
|
### Tracking
|
@@ -106,5 +108,27 @@ Modern.js provides `res.locals` to store local variables for the current request
|
|
106
108
|
export const Middleware = () => async (ctx, next) => {
|
107
109
|
ctx.res.locals.id = 'Modern.js';
|
108
110
|
ctx.res.locals.rpc = createRpcInstance();
|
109
|
-
}
|
111
|
+
};
|
110
112
|
```
|
113
|
+
|
114
|
+
### Framework Extension
|
115
|
+
|
116
|
+
Middleware can also use runtime framework extensions like BFF.
|
117
|
+
|
118
|
+
When using framework runtime extensions, type information is exported from `@modern-js/runtime/{namespace}`. Middleware can use framework syntax, such as framework middleware writing, the following is pseudo-code:
|
119
|
+
|
120
|
+
```ts
|
121
|
+
import { SomeType } from '@modern-js/runtime/{namespace}';
|
122
|
+
|
123
|
+
export const middleware: SomeType = (ctx, next) => {
|
124
|
+
console.log(ctx.url);
|
125
|
+
next();
|
126
|
+
};
|
127
|
+
```
|
128
|
+
|
129
|
+
By default, the framework extension capability of Web Server is turned off after installing the framework extension plug-in. If you want to use the framework extension, you can turn it on through ['server.enableFrameworkExt'](/configure/app/server/enable-framework-ext.html).
|
130
|
+
|
131
|
+
|
132
|
+
:::info
|
133
|
+
The type name exported by the framework extension may not 'Middleware', but is named by the framework extension plugin.
|
134
|
+
:::
|
@@ -7,8 +7,8 @@ import { Tabs, Tab as TabItem } from "@theme";
|
|
7
7
|
<TabItem value="express" label="Express.js" default>
|
8
8
|
|
9
9
|
```ts title="edenx.config.ts"
|
10
|
-
import expressPlugin from '@
|
11
|
-
import bffPlugin from '@
|
10
|
+
import expressPlugin from '@modern-js/plugin-express';
|
11
|
+
import bffPlugin from '@modern-js/plugin-bff';
|
12
12
|
|
13
13
|
export default defineConfig({
|
14
14
|
plugins: [expressPlugin(), bffPlugin()],
|
@@ -19,8 +19,8 @@ export default defineConfig({
|
|
19
19
|
<TabItem value="koa" label="Koa.js">
|
20
20
|
|
21
21
|
```ts title="edenx.config.ts"
|
22
|
-
import koaPlugin from '@
|
23
|
-
import bffPlugin from '@
|
22
|
+
import koaPlugin from '@modern-js/plugin-koa';
|
23
|
+
import bffPlugin from '@modern-js/plugin-bff';
|
24
24
|
|
25
25
|
export default defineConfig({
|
26
26
|
plugins: [koaPlugin(), bffPlugin()],
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
title: enableHandleWeb
|
3
|
+
---
|
4
|
+
|
5
|
+
# bff.enableHandleWeb
|
6
|
+
|
7
|
+
- **Type:** `boolean`
|
8
|
+
- **Default:** `false`
|
9
|
+
|
10
|
+
:::caution
|
11
|
+
First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
|
12
|
+
:::
|
13
|
+
|
14
|
+
By default, the BFF service can only handle requests from the BFF API.
|
15
|
+
|
16
|
+
When this value is set to `true`, page request traffic also goes through the BFF, and the logic built into Modern.js for page rendering defaults to running as the last middleware for the BFF service.
|
17
|
+
|
18
|
+
```ts title="modern.config.ts"
|
19
|
+
export default defineConfig({
|
20
|
+
bff: {
|
21
|
+
enableHandleWeb: true,
|
22
|
+
},
|
23
|
+
});
|
24
|
+
```
|
@@ -35,7 +35,7 @@ export const middleware: Middleware = (ctx, next) => {
|
|
35
35
|
When enabled, Middleware types will be exported from other namespaces and can the syntax of framework extensions:
|
36
36
|
|
37
37
|
```ts title="server/index.ts"
|
38
|
-
import { SomeType } from '@modern-js/runtime/{
|
38
|
+
import { SomeType } from '@modern-js/runtime/{namespace}';
|
39
39
|
|
40
40
|
export const middleware: SomeType = (...args) => {
|
41
41
|
console.log(args[0].url);
|
@@ -9,6 +9,8 @@ sidebar_label: ssr
|
|
9
9
|
|
10
10
|
Enalbe SSR configuration.
|
11
11
|
|
12
|
+
### Boolean Type
|
13
|
+
|
12
14
|
When the value type is `boolean`, it indicates whether to enable SSR deployment mode, and `false` is not enabled by default.
|
13
15
|
|
14
16
|
```ts title="modern.config.ts"
|
@@ -18,3 +20,19 @@ export default defineConfig({
|
|
18
20
|
},
|
19
21
|
});
|
20
22
|
```
|
23
|
+
|
24
|
+
### Object Type
|
25
|
+
|
26
|
+
When the value type is `Object`, The following properties can be configured:
|
27
|
+
|
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
|
+
|
31
|
+
```ts title="modern.config.ts"
|
32
|
+
export default defineConfig({
|
33
|
+
server: {
|
34
|
+
forceCSR: true,
|
35
|
+
mode: 'stream',
|
36
|
+
},
|
37
|
+
});
|
38
|
+
```
|
@@ -16,12 +16,11 @@ Most problems will be solved by the automatic fix of ESLint rules or the code fo
|
|
16
16
|
|
17
17
|
:::info
|
18
18
|
This kind of automatic fix is mainly performed when the IDE saves the file, and a few will be automatically fix on submit.
|
19
|
-
|
20
19
|
:::
|
21
20
|
|
22
21
|
### Batch Automatic Fix
|
23
22
|
|
24
|
-
|
23
|
+
In rare cases, such as when an old project is migrated, the following commands can be executed to repair and inspect all files in bulk:
|
25
24
|
|
26
25
|
```bash
|
27
26
|
pnpm run lint:error
|
@@ -29,13 +28,13 @@ pnpm run lint:error
|
|
29
28
|
|
30
29
|
### Manual Fix
|
31
30
|
|
32
|
-
|
31
|
+
For problems that cannot be automatically fixed, you can click the rule link in the problem prompt box in the IDE to open the document of this rule to view the explanation and solution of the problem.
|
33
32
|
|
34
|
-
###
|
33
|
+
### Claim Exceptions
|
35
34
|
|
36
|
-
|
35
|
+
At this stage, some rules are not smart enough, and in most cases there will be great benefits, and in a few cases it may not apply. But if the entire rule is turned off or changed for these few cases, the gain is not worth the loss.
|
37
36
|
|
38
|
-
|
37
|
+
In this case, you can use the [eslint-disable](https://eslint.org/docs/user-guide/configuring/rules#disabling-rules) comment to mark the code blocks that meet the **rare case**, stating that this is an exception and should be ignored. For example:
|
39
38
|
|
40
39
|
```js
|
41
40
|
/* eslint-disable filenames/match-exported */
|
@@ -44,19 +43,19 @@ pnpm run lint:error
|
|
44
43
|
```
|
45
44
|
|
46
45
|
:::info
|
47
|
-
|
48
|
-
|
46
|
+
Enter eslint in the VS Code editor, a prompt box about `eslint-disable` will automatically appear, select the prompt option to generate the corresponding comment pair.
|
49
47
|
:::
|
50
48
|
|
51
|
-
|
49
|
+
[Modern.js ESLint Rule Set] requires that [eslint-disable](https://eslint.org/docs/user-guide/configuring/rules#disabling-rules) must be used in pairs, the scope to be affected must be clearly expressed, and what rules to disable within this scope must be clearly expressed, the purpose is to make **exceptions** Clear, minimized scope to avoid abuse of [eslint-disable](https://eslint.org/docs/user-guide/configuring/rules#disabling-rules), resulting in code that does not belong to the exception being disabled by the rule.
|
52
50
|
|
53
|
-
## Q:
|
51
|
+
## Q: How to customize ESLint rules
|
54
52
|
|
55
|
-
###
|
53
|
+
### The `eslintConfig` field in `package.json` in the root directory
|
56
54
|
|
57
|
-
|
55
|
+
This place is the default ESLint configuration for the entire repository and is designed for pure Node.js code (which can only run in Node.js).
|
56
|
+
|
57
|
+
If the project does have special requirements or inevitable compatibility issues with some rules (not exceptions), you can add rule configuration here. This configuration will take precedence over the default [Modern.js ESLint ruleset], such as:
|
58
58
|
|
59
|
-
如果项目在某些规则上确实有特殊要求或不可避免的兼容问题(不是例外),可以在这里增加规则配置。该配置会优先于默认的【Modern.js ESLint 规则集】,比如:
|
60
59
|
|
61
60
|
```json
|
62
61
|
"eslintConfig": {
|
@@ -70,16 +69,15 @@ pnpm run lint:error
|
|
70
69
|
|
71
70
|
```
|
72
71
|
|
73
|
-
### `src/.eslintrc.js`
|
72
|
+
### `src/.eslintrc.js`
|
74
73
|
|
75
|
-
Modern.js
|
74
|
+
The application project and module project of Modern.js will have this configuration file by default in the source code directory, which is designed for Universal JS code.
|
76
75
|
|
77
76
|
:::info
|
78
|
-
Universal JS
|
79
|
-
|
77
|
+
Universal JS code is code that can run on both the browser side and the server side.
|
80
78
|
:::
|
81
79
|
|
82
|
-
|
80
|
+
If the project does have special requirements or inevitable compatibility issues with some rules (not exceptions), you can add a rule configuration here, which will take precedence over the default [Modern.js ESLint ruleset], such as:
|
83
81
|
|
84
82
|
```js
|
85
83
|
// eslint-disable-next-line import/no-commonjs
|
@@ -96,7 +94,7 @@ module.exports = {
|
|
96
94
|
};
|
97
95
|
```
|
98
96
|
|
99
|
-
|
97
|
+
If necessary, you can continue to add the `.eslintrc.js` file in different subdirectories, and make special configuration for the code in this subdirectory:
|
100
98
|
|
101
99
|
```js
|
102
100
|
module.exports = {
|
@@ -107,13 +105,13 @@ module.exports = {
|
|
107
105
|
```
|
108
106
|
|
109
107
|
:::tip
|
110
|
-
|
108
|
+
Note: It is not necessary to use the `extends` field, it will automatically inherit the configuration of the parent directory.
|
111
109
|
|
112
110
|
:::
|
113
111
|
|
114
|
-
### package.json
|
112
|
+
### `eslintIgnore` field in `package.json`
|
115
113
|
|
116
|
-
|
114
|
+
Adding directories that contain `.js`, `.jsx`, `.ts`, `.tsx` files, but do not require code inspection and automatic repair, to `eslintIgnore` can optimize the speed of ESLint inspection, such as:
|
117
115
|
|
118
116
|
```json
|
119
117
|
"eslintIgnore": [
|
@@ -123,25 +121,25 @@ module.exports = {
|
|
123
121
|
],
|
124
122
|
```
|
125
123
|
|
126
|
-
## Q:
|
124
|
+
## Q: How to upgrade the version of the ESLint plugin
|
127
125
|
|
128
|
-
|
126
|
+
As long as it is not a change in the Major version (the "^" symbol that does not comply with the [Semver](https://semver.org/) rule), you can specify this dependency directly in the `package.json` of the business project, delete the Lock file (or try to manually delete the Lock file). the contents of this package name in the file), execute `pnpm install` to reinstall the dependency and generate a new Lock file.
|
129
127
|
|
130
|
-
|
128
|
+
After doing this, the plugin should only exist in the `./node_modules` directory of the business project and be upgraded to the version you specified.
|
131
129
|
|
132
130
|
:::tip
|
133
|
-
- Major
|
134
|
-
-
|
135
|
-
- Modern.js
|
136
|
-
- Major
|
131
|
+
- Major version is the major version number. For more information, please read [[Semantic Versioning](https://semver.org/#summary) ].
|
132
|
+
- All upstream projects encapsulated by Modern.js (such as ESLint, [ESLint plugin](https://eslint.org/docs/user-guide/configuring/plugins#plugins), [React Router](https://reactrouter.com/), etc.) can also be upgraded in this way.
|
133
|
+
- Modern.js will also try to upgrade these upstream dependencies as timely as possible in each release.
|
134
|
+
- Major version upgrades need to be published by Modern.js.
|
137
135
|
|
138
136
|
:::
|
139
137
|
|
140
|
-
## Q: WebStorm
|
138
|
+
## Q: WebStorm sometimes reports ESLint errors
|
141
139
|
|
142
|
-
|
140
|
+
Since WebStorm believes that the ESLint execution directory is determined based on the `.eslintrc'` file. Therefore, the placement of the `src/.eslintrc` file location will cause the location specified by the `tsconfig.json` file (in the project root directory) to not be found in the'src/'directory.
|
143
141
|
|
144
|
-
|
142
|
+
you need to configure it manually:
|
145
143
|
|
146
144
|
```json
|
147
145
|
--parser-options=project:../tsconfig.json
|
@@ -6,7 +6,7 @@ sidebar_position: 11
|
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
Modern.js internally integrates tools such as [Babel](https://babeljs.io/), [TypeScript](https://www.typescriptlang.org/), [Webpack](https://webpack.js.org/), [PostCSS](https://postcss.org/), [Tailwind CSS]
|
9
|
+
Modern.js internally integrates tools such as [Babel](https://babeljs.io/), [TypeScript](https://www.typescriptlang.org/), [Webpack](https://webpack.js.org/), [PostCSS](https://postcss.org/), [Tailwind CSS](https://tailwindcss.com/) by default.
|
10
10
|
|
11
11
|
Usually, the default configuration can meet most development needs. When there are special needs, it can be achieved through the underlying configuration.
|
12
12
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
---
|
2
2
|
title: Rspack Start
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 1
|
4
4
|
---
|
5
5
|
|
6
6
|
# Rspack Start
|
7
7
|
|
8
|
-
[Rspack](https://www.rspack.
|
8
|
+
[Rspack](https://www.rspack.dev/) is a Rust-based web bundler developed by the ByteDance Web Infra team. The core architecture of Rspack is aligned with the implementation of webpack, and provides out-of-the-box support for commonly used build features.
|
9
9
|
|
10
10
|
Rspack optimizes compilation performance by:
|
11
11
|
|
@@ -13,22 +13,18 @@ Rspack optimizes compilation performance by:
|
|
13
13
|
- Take full advantage of multi-core, and the entire compilation process is fully optimized for multi-threading.
|
14
14
|
- On-demand compilation based on request (Lazy Compilation), reducing the number of modules per compilation to improve the speed of cold start.
|
15
15
|
|
16
|
-
## Initializing an
|
16
|
+
## Initializing an Rspack project
|
17
17
|
|
18
|
-
The Modern.js generator provides an interactive question-and-answer interface to initialize a project. To create an
|
18
|
+
The Modern.js generator provides an interactive question-and-answer interface to initialize a project. To create an Rspack project, simply select the **Rspack** build tool by running:
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
? Development Language: TS
|
24
|
-
? Package Management Tool: pnpm
|
25
|
-
? Build Tools: rspack
|
26
|
-
```
|
20
|
+
import InitRspackApp from "@site-docs-en/components/init-rspack-app"
|
21
|
+
|
22
|
+
<InitRspackApp />
|
27
23
|
|
28
24
|
After the project is created, you can experience the project by running `pnpm run dev`. For more project information, please refer to [Quick Start](/guides/get-started/quick-start.html).
|
29
25
|
|
30
26
|
:::tip
|
31
|
-
When using
|
27
|
+
When using Rspack as the bundler, the following features are currently not supported:
|
32
28
|
|
33
29
|
- Server-side rendering (SSR)
|
34
30
|
- Static Site Generation (SSG)
|
@@ -37,17 +33,17 @@ When using rspack as the bundler, the following features are currently not suppo
|
|
37
33
|
|
38
34
|
:::
|
39
35
|
|
40
|
-
## Migrating from webpack to
|
36
|
+
## Migrating from webpack to Rspack
|
41
37
|
|
42
|
-
You can enable
|
38
|
+
You can enable Rspack build by running `pnpm run new`:
|
43
39
|
|
44
40
|
```bash
|
45
41
|
$ pnpm run new
|
46
42
|
? Action: Enable features
|
47
|
-
? Enable features: Enable
|
43
|
+
? Enable features: Enable Rspack Build
|
48
44
|
```
|
49
45
|
|
50
|
-
After executing the command, enable the
|
46
|
+
After executing the command, enable the Rspack build in `modern.config.ts`:
|
51
47
|
|
52
48
|
```ts title=modern.config.ts
|
53
49
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
@@ -65,5 +61,5 @@ export default defineConfig<'rspack'>({
|
|
65
61
|
```
|
66
62
|
|
67
63
|
:::tip
|
68
|
-
Migrating from webpack to
|
64
|
+
Migrating from webpack to Rspack may have some differences in build and configuration capabilities. For more details, please refer to [Configuration Differences](https://modernjs.dev/builder/en/guide/advanced/rspack-start.html#migrating-from-webpack-to-rspack).
|
69
65
|
:::
|