@modern-js/main-doc 3.2.1 → 3.3.0
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.
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
title: tsChecker
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { PackageManagerTabs } from '@theme';
|
|
6
|
+
|
|
5
7
|
# tools.tsChecker
|
|
6
8
|
|
|
7
9
|
- **Type:** `Object | Function`
|
|
@@ -14,6 +16,8 @@ const defaultOptions = {
|
|
|
14
16
|
memoryLimit: 8192,
|
|
15
17
|
// use tsconfig of user project
|
|
16
18
|
configFile: tsconfigPath,
|
|
19
|
+
// use TypeScript checker by default
|
|
20
|
+
tsgo: false,
|
|
17
21
|
// use typescript of user project
|
|
18
22
|
typescriptPath: require.resolve('typescript'),
|
|
19
23
|
},
|
|
@@ -35,7 +39,7 @@ const defaultOptions = {
|
|
|
35
39
|
},
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
By default, the [@rsbuild/plugin-type-check](https://github.com/
|
|
42
|
+
By default, the [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) is enabled for type checking. You can use `output.disableTsChecker` config to disable it.
|
|
39
43
|
|
|
40
44
|
## Example
|
|
41
45
|
|
|
@@ -53,4 +57,30 @@ export default {
|
|
|
53
57
|
};
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
> Please refer to [@rsbuild/plugin-type-check](https://github.com/
|
|
60
|
+
> Please refer to [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) for more details.
|
|
61
|
+
|
|
62
|
+
## TypeScript Go Support
|
|
63
|
+
|
|
64
|
+
`tools.tsChecker` supports enabling [TypeScript Go](https://github.com/microsoft/typescript-go) for type checking. This experimental capability is provided by [`ts-checker-rspack-plugin`](https://github.com/rstackjs/ts-checker-rspack-plugin), which is integrated by [`@rsbuild/plugin-type-check`](https://github.com/rstackjs/rsbuild-plugin-type-check), and can reduce type-checking time by about 5-10x.
|
|
65
|
+
|
|
66
|
+
Before using it, install `@typescript/native-preview`:
|
|
67
|
+
|
|
68
|
+
<PackageManagerTabs command="install @typescript/native-preview -D" />
|
|
69
|
+
|
|
70
|
+
Then set `typescript.tsgo` to `true`:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
export default {
|
|
74
|
+
tools: {
|
|
75
|
+
tsChecker: {
|
|
76
|
+
typescript: {
|
|
77
|
+
tsgo: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `@typescript/native-preview/package.json`. If you manually set `typescript.typescriptPath`, it must be an absolute path to `@typescript/native-preview/package.json`.
|
|
85
|
+
|
|
86
|
+
For supported options and limitations, please refer to [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
|
|
@@ -48,6 +48,18 @@ export default defineServerConfig({
|
|
|
48
48
|
|
|
49
49
|
After creating the file, you can write custom logic in this file.
|
|
50
50
|
|
|
51
|
+
3. Include `server` directory in `tsconfig.json`
|
|
52
|
+
|
|
53
|
+
```json5
|
|
54
|
+
{
|
|
55
|
+
// ...
|
|
56
|
+
"include": [
|
|
57
|
+
// ...
|
|
58
|
+
"server"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
51
63
|
## Capabilities of the Custom Web Server
|
|
52
64
|
|
|
53
65
|
Modern.js's Web Server is based on Hono, and in the latest version of the Custom Web Server, we expose Hono's middleware capabilities, you can refer to [Hono API](https://hono.dev/docs/api/context) for more usage.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
title: tsChecker
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { PackageManagerTabs } from '@theme';
|
|
6
|
+
|
|
5
7
|
# tools.tsChecker
|
|
6
8
|
|
|
7
9
|
- **类型:** `Object | Function`
|
|
@@ -14,6 +16,8 @@ const defaultOptions = {
|
|
|
14
16
|
memoryLimit: 8192,
|
|
15
17
|
// use tsconfig of user project
|
|
16
18
|
configFile: tsconfigPath,
|
|
19
|
+
// use TypeScript checker by default
|
|
20
|
+
tsgo: false,
|
|
17
21
|
// use typescript of user project
|
|
18
22
|
typescriptPath: require.resolve('typescript'),
|
|
19
23
|
},
|
|
@@ -35,7 +39,7 @@ const defaultOptions = {
|
|
|
35
39
|
},
|
|
36
40
|
```
|
|
37
41
|
|
|
38
|
-
默认情况下,Modern.js 会开启 [@rsbuild/plugin-type-check](https://github.com/
|
|
42
|
+
默认情况下,Modern.js 会开启 [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) 进行类型检查。你可以通过 `output.disableTsChecker` 配置项来关闭类型检查。
|
|
39
43
|
|
|
40
44
|
## 示例
|
|
41
45
|
|
|
@@ -53,4 +57,30 @@ export default {
|
|
|
53
57
|
};
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
> 请参考 [@rsbuild/plugin-type-check](https://github.com/
|
|
60
|
+
> 请参考 [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) 了解更多用法。
|
|
61
|
+
|
|
62
|
+
## TypeScript Go 支持
|
|
63
|
+
|
|
64
|
+
`tools.tsChecker` 支持开启 [TypeScript Go](https://github.com/microsoft/typescript-go) 进行类型检查。该能力由 [`@rsbuild/plugin-type-check`](https://github.com/rstackjs/rsbuild-plugin-type-check) 底层集成的 [`ts-checker-rspack-plugin`](https://github.com/rstackjs/ts-checker-rspack-plugin) 提供,目前仍处于实验阶段,可以将类型检查耗时减少约 5-10 倍。
|
|
65
|
+
|
|
66
|
+
在使用前,需要安装 `@typescript/native-preview`:
|
|
67
|
+
|
|
68
|
+
<PackageManagerTabs command="install @typescript/native-preview -D" />
|
|
69
|
+
|
|
70
|
+
然后将 `typescript.tsgo` 设置为 `true`:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
export default {
|
|
74
|
+
tools: {
|
|
75
|
+
tsChecker: {
|
|
76
|
+
typescript: {
|
|
77
|
+
tsgo: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
开启 `tsgo` 后,默认的 `typescript.typescriptPath` 会解析到 `@typescript/native-preview/package.json`。如果你手动设置了 `typescript.typescriptPath`,它必须是指向 `@typescript/native-preview/package.json` 的绝对路径。
|
|
85
|
+
|
|
86
|
+
关于 `tsgo` 模式下生效的配置项和相关限制,请参考 [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support)。
|
|
@@ -48,6 +48,18 @@ export default defineServerConfig({
|
|
|
48
48
|
|
|
49
49
|
创建文件后,可以在这个文件中编写自定义逻辑。
|
|
50
50
|
|
|
51
|
+
3. 你可以将 `server` 目录包含在 `tsconfig.json` 中
|
|
52
|
+
|
|
53
|
+
```json5
|
|
54
|
+
{
|
|
55
|
+
// ...
|
|
56
|
+
"include": [
|
|
57
|
+
// ...
|
|
58
|
+
"server"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
51
63
|
## 自定义 Web Server 能力
|
|
52
64
|
|
|
53
65
|
Modern.js 的服务器基于 Hono 实现,在最新版本的自定义 Web Server 中,我们向用户暴露了 Hono 的中间件能力,你可以参考 [Hono 文档](https://hono.dev/docs/api/context) 了解更多用法。
|
package/package.json
CHANGED
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"modern",
|
|
17
17
|
"modern.js"
|
|
18
18
|
],
|
|
19
|
-
"version": "3.
|
|
19
|
+
"version": "3.3.0",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"registry": "https://registry.npmjs.org/",
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"mermaid": "^11.
|
|
26
|
-
"@modern-js/sandpack-react": "3.
|
|
25
|
+
"mermaid": "^11.15.0",
|
|
26
|
+
"@modern-js/sandpack-react": "3.3.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"rsbuild-plugin-open-graph": "1.1.
|
|
30
|
-
"@rsbuild/plugin-sass": "1.5.
|
|
31
|
-
"@rspress/core": "2.0.
|
|
29
|
+
"rsbuild-plugin-open-graph": "1.1.3",
|
|
30
|
+
"@rsbuild/plugin-sass": "1.5.3",
|
|
31
|
+
"@rspress/core": "2.0.13",
|
|
32
32
|
"@rspress/plugin-llms": "2.0.2",
|
|
33
33
|
"@rspress/shared": "2.0.2",
|
|
34
34
|
"@shikijs/transformers": "^3.23.0",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"classnames": "^2.5.1",
|
|
38
38
|
"clsx": "^1.2.1",
|
|
39
39
|
"fs-extra": "^10.1.0",
|
|
40
|
-
"react": "^19.2.
|
|
41
|
-
"react-dom": "^19.2.
|
|
40
|
+
"react": "^19.2.7",
|
|
41
|
+
"react-dom": "^19.2.7",
|
|
42
42
|
"ts-node": "^10.9.2",
|
|
43
43
|
"typescript": "^5"
|
|
44
44
|
},
|