@modern-js/main-doc 3.0.0-alpha.0 → 3.0.0-alpha.1
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/docs/en/apis/app/commands.mdx +6 -30
- package/docs/en/components/bff-upload.mdx +3 -5
- package/docs/en/components/bundler.mdx +1 -1
- package/docs/en/components/enable-bff.mdx +6 -2
- package/docs/en/components/enable-ssg.mdx +1 -0
- package/docs/en/components/esbuild.mdx +2 -2
- package/docs/en/components/extend-bff-function.mdx +2 -4
- package/docs/en/components/hono.mdx +119 -0
- package/docs/en/components/international/custom-instance-code.mdx +16 -0
- package/docs/en/components/international/init-options-desc.mdx +1 -0
- package/docs/en/components/international/install-command.mdx +15 -1
- package/docs/en/components/international/instance-code.mdx +26 -0
- package/docs/en/configure/app/builder-plugins.mdx +1 -2
- package/docs/en/configure/app/dev/server.mdx +108 -0
- package/docs/en/configure/app/experiments/source-build.mdx +0 -1
- package/docs/en/configure/app/output/assets-retry.mdx +1 -1
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/en/configure/app/output/filename.mdx +2 -4
- package/docs/en/configure/app/output/temp-dir.mdx +3 -3
- package/docs/en/configure/app/performance/build-cache.mdx +1 -1
- package/docs/en/configure/app/performance/profile.mdx +1 -1
- package/docs/en/configure/app/plugins.mdx +1 -3
- package/docs/en/configure/app/runtime/router.mdx +0 -4
- package/docs/en/configure/app/security/sri.mdx +0 -1
- package/docs/en/configure/app/source/alias.mdx +1 -1
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/include.mdx +2 -14
- package/docs/en/configure/app/tools/dev-server.mdx +8 -8
- package/docs/en/configure/app/usage.mdx +0 -12
- package/docs/en/guides/_meta.json +5 -0
- package/docs/en/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -1
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -15
- package/docs/en/guides/advanced-features/bff/function.mdx +4 -4
- package/docs/en/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/en/guides/advanced-features/bff/sdk.mdx +17 -9
- package/docs/en/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/en/guides/advanced-features/international/configuration.mdx +7 -16
- package/docs/en/guides/advanced-features/international/quick-start.mdx +4 -32
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
- package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +18 -4
- package/docs/en/guides/advanced-features/rspack-start.mdx +1 -1
- package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -5
- package/docs/en/guides/basic-features/data/data-cache.mdx +60 -76
- package/docs/en/guides/basic-features/data/data-fetch.mdx +15 -14
- package/docs/en/guides/basic-features/debug/proxy.mdx +6 -9
- package/docs/en/guides/basic-features/render/rsc.mdx +24 -19
- package/docs/en/guides/basic-features/render/ssg.mdx +4 -9
- package/docs/en/guides/basic-features/render/ssr-cache.mdx +0 -4
- package/docs/en/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/en/guides/get-started/tech-stack.mdx +1 -1
- package/docs/en/guides/upgrade/_meta.json +1 -0
- package/docs/en/guides/upgrade/config.mdx +936 -0
- package/docs/en/guides/upgrade/entry.mdx +463 -0
- package/docs/en/guides/upgrade/other.mdx +83 -0
- package/docs/en/guides/upgrade/overview.mdx +33 -0
- package/docs/en/guides/upgrade/tailwindcss.mdx +130 -0
- package/docs/en/guides/upgrade/web-server.mdx +91 -0
- package/docs/en/plugin/_meta.json +5 -0
- package/docs/en/plugin/cli-plugins/_meta.json +1 -1
- package/docs/en/plugin/cli-plugins/api.mdx +13 -63
- package/docs/en/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/en/plugin/introduction.mdx +8 -20
- package/docs/en/plugin/plugin-system.mdx +3 -3
- package/docs/en/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/en/plugin/runtime-plugins/api.mdx +1 -1
- package/docs/en/plugin/server-plugins/_meta.json +1 -0
- package/docs/en/plugin/server-plugins/api.mdx +210 -1
- package/docs/en/plugin/server-plugins/life-cycle.mdx +41 -1
- package/docs/zh/apis/app/commands.mdx +6 -30
- package/docs/zh/components/bff-operator-code.mdx +5 -0
- package/docs/zh/components/bff-upload.mdx +0 -2
- package/docs/zh/components/bundler.mdx +1 -1
- package/docs/zh/components/enable-bff.mdx +6 -2
- package/docs/zh/components/enable-ssg.mdx +3 -1
- package/docs/zh/components/esbuild.mdx +2 -2
- package/docs/zh/components/extend-bff-function.mdx +2 -4
- package/docs/zh/components/hono.mdx +119 -0
- package/docs/zh/components/international/custom-instance-code.mdx +16 -0
- package/docs/zh/components/international/init-options-desc.mdx +1 -0
- package/docs/zh/components/international/install-command.mdx +15 -0
- package/docs/zh/components/international/instance-code.mdx +26 -0
- package/docs/zh/configure/app/builder-plugins.mdx +1 -2
- package/docs/zh/configure/app/dev/server.mdx +109 -2
- package/docs/zh/configure/app/experiments/source-build.mdx +0 -1
- package/docs/zh/configure/app/output/assets-retry.mdx +1 -1
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +2 -2
- package/docs/zh/configure/app/output/filename.mdx +2 -4
- package/docs/zh/configure/app/output/temp-dir.mdx +3 -3
- package/docs/zh/configure/app/performance/build-cache.mdx +1 -1
- package/docs/zh/configure/app/performance/profile.mdx +1 -1
- package/docs/zh/configure/app/plugins.mdx +1 -2
- package/docs/zh/configure/app/runtime/router.mdx +0 -4
- package/docs/zh/configure/app/security/sri.mdx +0 -1
- package/docs/zh/configure/app/source/alias.mdx +1 -1
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/configure/app/source/include.mdx +2 -16
- package/docs/zh/configure/app/tools/dev-server.mdx +5 -5
- package/docs/zh/configure/app/usage.mdx +0 -12
- package/docs/zh/guides/advanced-features/bff/_meta.json +9 -1
- package/docs/zh/guides/advanced-features/bff/frameworks.mdx +2 -16
- package/docs/zh/guides/advanced-features/bff/operators.mdx +628 -0
- package/docs/zh/guides/advanced-features/bff/sdk.mdx +19 -12
- package/docs/zh/guides/advanced-features/bff/upload.mdx +3 -1
- package/docs/zh/guides/advanced-features/international/configuration.mdx +7 -16
- package/docs/zh/guides/advanced-features/international/quick-start.mdx +2 -25
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
- package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +18 -4
- package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +60 -5
- package/docs/zh/guides/basic-features/data/data-cache.mdx +47 -54
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +9 -12
- package/docs/zh/guides/basic-features/debug/proxy.mdx +4 -7
- package/docs/zh/guides/basic-features/render/rsc.mdx +23 -37
- package/docs/zh/guides/basic-features/render/ssr-cache.mdx +0 -4
- package/docs/zh/guides/basic-features/static-assets/svg-assets.mdx +0 -4
- package/docs/zh/guides/get-started/tech-stack.mdx +1 -1
- package/docs/zh/guides/troubleshooting/builder.mdx +1 -1
- package/docs/zh/guides/upgrade/config.mdx +132 -1
- package/docs/zh/plugin/_meta.json +5 -0
- package/docs/zh/plugin/cli-plugins/_meta.json +1 -1
- package/docs/zh/plugin/cli-plugins/api.mdx +15 -65
- package/docs/zh/plugin/cli-plugins/life-cycle.mdx +0 -4
- package/docs/zh/plugin/introduction.mdx +4 -16
- package/docs/zh/plugin/plugin-system.mdx +3 -14
- package/docs/zh/plugin/runtime-plugins/_meta.json +1 -1
- package/docs/zh/plugin/runtime-plugins/api.mdx +1 -1
- package/docs/zh/plugin/server-plugins/_meta.json +1 -0
- package/docs/zh/plugin/server-plugins/api.mdx +210 -1
- package/docs/zh/plugin/server-plugins/life-cycle.mdx +41 -1
- package/package.json +2 -2
- package/src/components/FrameworkCode/index.tsx +605 -0
- package/docs/en/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/en/configure/app/tools/babel.mdx +0 -225
- package/docs/en/plugin/cli-plugins/migration.mdx +0 -83
- package/docs/en/plugin/runtime-plugins/migration.mdx +0 -110
- package/docs/zh/components/default-mwa-generate.mdx +0 -4
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +0 -24
- package/docs/zh/configure/app/tools/babel.mdx +0 -224
- package/docs/zh/plugin/cli-plugins/migration.mdx +0 -83
- package/docs/zh/plugin/runtime-plugins/migration.mdx +0 -110
- /package/docs/en/components/{router-legacy-tip.mdx → upgrade-config-deploy.mdx} +0 -0
- /package/docs/zh/components/{router-legacy-tip.mdx → upgrade-config-deploy.mdx} +0 -0
|
@@ -68,7 +68,6 @@ export default {
|
|
|
68
68
|
};
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
|
|
72
71
|
更多配置选项请参考 [Rsbuild - server.historyApiFallback](https://rsbuild.rs/zh/config/server/history-api-fallback) 文档。
|
|
73
72
|
|
|
74
73
|
### watch
|
|
@@ -97,8 +96,116 @@ const defaultOptions = {
|
|
|
97
96
|
// - localhost
|
|
98
97
|
// - 127.0.0.1
|
|
99
98
|
// - [::1]
|
|
100
|
-
origin: defaultAllowedOrigins
|
|
99
|
+
origin: defaultAllowedOrigins,
|
|
101
100
|
};
|
|
102
101
|
```
|
|
103
102
|
|
|
104
103
|
更多配置选项和详细用法请参考 [Rsbuild - server.cors](https://rsbuild.rs/zh/config/server/cors) 文档。
|
|
104
|
+
|
|
105
|
+
### proxy
|
|
106
|
+
|
|
107
|
+
- **类型:** `Record<string, string> | Record<string, ProxyDetail>`
|
|
108
|
+
- **默认值:** `undefined`
|
|
109
|
+
|
|
110
|
+
代理请求到指定的服务上。
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
export default {
|
|
114
|
+
dev: {
|
|
115
|
+
server: {
|
|
116
|
+
proxy: {
|
|
117
|
+
'/api': 'http://localhost:3000',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
此时,/api/users 请求将会代理到 http://localhost:3000/api/users。
|
|
125
|
+
|
|
126
|
+
如果你不想传递 /api,可以通过 `pathRewrite` 重写请求路径:
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
export default {
|
|
130
|
+
dev: {
|
|
131
|
+
server: {
|
|
132
|
+
proxy: {
|
|
133
|
+
'/api': {
|
|
134
|
+
target: 'http://localhost:3000',
|
|
135
|
+
pathRewrite: { '^/api': '' },
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
DevServer Proxy 基于 [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware/tree/2.x) 实现。你可以使用 http-proxy-middleware 的所有配置项,具体可以查看文档。
|
|
144
|
+
|
|
145
|
+
DevServer Proxy 完整类型定义为:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import type { Options as HttpProxyOptions } from 'http-proxy-middleware';
|
|
149
|
+
|
|
150
|
+
type Filter = string | string[] | ((pathname: string, req: Request) => boolean);
|
|
151
|
+
|
|
152
|
+
type ProxyDetail = HttpProxyOptions & {
|
|
153
|
+
bypass?: (
|
|
154
|
+
req: IncomingMessage,
|
|
155
|
+
res: ServerResponse,
|
|
156
|
+
proxyOptions: ProxyOptions,
|
|
157
|
+
) => string | undefined | null | false;
|
|
158
|
+
context?: Filter;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
type ProxyOptions =
|
|
162
|
+
| Record<string, string>
|
|
163
|
+
| Record<string, ProxyDetail>
|
|
164
|
+
| ProxyDetail[]
|
|
165
|
+
| ProxyDetail;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
除了 http-proxy-middleware 的选项外,还支持 bypass 和 context 两个配置项:
|
|
169
|
+
|
|
170
|
+
- bypass:根据函数的返回值绕过代理。
|
|
171
|
+
- 返回 `null` 或 `undefined` 会继续用代理处理请求。
|
|
172
|
+
- 返回 `false` 会返回 404 错误。
|
|
173
|
+
- 返回一个具体的服务路径,将会使用此路径替代原请求路径。
|
|
174
|
+
- context:如果你想代理多个特定的路径到同一个目标,你可以使用 context 配置项。
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
// 自定义 bypass 方法
|
|
178
|
+
export default {
|
|
179
|
+
dev: {
|
|
180
|
+
server: {
|
|
181
|
+
proxy: {
|
|
182
|
+
'/api': {
|
|
183
|
+
target: 'http://localhost:3000',
|
|
184
|
+
bypass: function (req, res, proxyOptions) {
|
|
185
|
+
if (req.headers.accept.indexOf('html') !== -1) {
|
|
186
|
+
console.log('Skipping proxy for browser request.');
|
|
187
|
+
return '/index.html';
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
// 代理多个路径到同一个目标
|
|
199
|
+
export default {
|
|
200
|
+
dev: {
|
|
201
|
+
server: {
|
|
202
|
+
proxy: [
|
|
203
|
+
{
|
|
204
|
+
context: ['/auth', '/api'],
|
|
205
|
+
target: 'http://localhost:3000',
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
```
|
|
@@ -31,7 +31,7 @@ export type AssetsRetryOptions = {
|
|
|
31
31
|
|
|
32
32
|
- **默认值:** `undefined`
|
|
33
33
|
|
|
34
|
-
由于该能力会往 HTML 中和 [
|
|
34
|
+
由于该能力会往 HTML 中和 [Rspack Runtime](https://rspack.rs/api/runtime-api/module-variables) 注入额外的一些运行时代码,因此我们默认关闭了该能力,如果需要开启该能力,你可以添加以下配置:
|
|
35
35
|
|
|
36
36
|
```js
|
|
37
37
|
export default {
|
|
@@ -10,9 +10,9 @@ title: disableInlineRuntimeChunk
|
|
|
10
10
|
用于控制是否将打包工具的 runtime 代码内联到 HTML 中。
|
|
11
11
|
|
|
12
12
|
:::tip 什么是 runtimeChunk
|
|
13
|
-
当构建完成后,会在 dist 目录生成 `builder-runtime.js` 文件,该文件为
|
|
13
|
+
当构建完成后,会在 dist 目录生成 `builder-runtime.js` 文件,该文件为 Rspack 的 runtime 代码,即 runtimeChunk。
|
|
14
14
|
|
|
15
|
-
runtimeChunk 是一段运行时代码,它由
|
|
15
|
+
runtimeChunk 是一段运行时代码,它由 Rspack 提供,包含必要的模块处理逻辑,比如模块加载、模块解析等,具体可参考 [Runtime Chunk](https://rspack.rs/config/optimization#optimizationruntimechunk)。
|
|
16
16
|
|
|
17
17
|
:::
|
|
18
18
|
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
title: filename
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
# output.filename
|
|
6
|
+
|
|
5
7
|
:::warning
|
|
6
8
|
|
|
7
9
|
在 Modern.js 开发阶段,或是使用 Modern.js 服务器部署应用时,应避免使用该配置修改 html 产物文件名,会导致页面 404。
|
|
8
10
|
|
|
9
|
-
通常情况下,无需修改 html 产物文件名。常见的需求是将 `main.html` 修改为 `index.html`,请使用 [source.mainEntryName](/configure/app/source/main-entry-name)。
|
|
10
|
-
|
|
11
11
|
:::
|
|
12
12
|
|
|
13
|
-
# output.filename
|
|
14
|
-
|
|
15
13
|
- **类型:**
|
|
16
14
|
|
|
17
15
|
```ts
|
|
@@ -7,7 +7,7 @@ title: tempDir
|
|
|
7
7
|
- **类型:** `string`
|
|
8
8
|
- **默认值:** `''`
|
|
9
9
|
|
|
10
|
-
项目开发或构建时,Modern.js 会生成真实的
|
|
10
|
+
项目开发或构建时,Modern.js 会生成真实的 Rspack 入口和 HTML 模板,并放在临时目录下。
|
|
11
11
|
|
|
12
12
|
如果希望由多个配置同时启动某项目,可以通过该配置,将文件生成到不同的临时目录下,避免相互干扰。配置可以是相对路径或绝对路径,但应避免项目外的路径。
|
|
13
13
|
|
|
@@ -17,6 +17,6 @@ title: tempDir
|
|
|
17
17
|
export default {
|
|
18
18
|
output: {
|
|
19
19
|
tempDir: path.join('node_modules', '.temp-dir'),
|
|
20
|
-
}
|
|
21
|
-
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
22
|
```
|
|
@@ -7,7 +7,7 @@ title: profile
|
|
|
7
7
|
- **类型:** `boolean`
|
|
8
8
|
- **默认值:** `false`
|
|
9
9
|
|
|
10
|
-
是否捕获每个模块的耗时信息,对应 Rspack 的 [profile](https://
|
|
10
|
+
是否捕获每个模块的耗时信息,对应 Rspack 的 [profile](https://rspack.rs/zh/config/other-options#profile) 配置。
|
|
11
11
|
|
|
12
12
|
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
13
13
|
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
该选项**用于配置框架 CLI 插件**,如果你需要配置其他类型的插件,请选择对应的配置方式:
|
|
11
11
|
|
|
12
12
|
- 配置 Rsbuild 插件,请使用 [builderPlugins](/configure/app/builder-plugins) 配置项。
|
|
13
|
-
- 配置 Rspack
|
|
14
|
-
- 配置 Babel 插件,请使用 [tools.babel](/configure/app/tools/babel) 配置项。
|
|
13
|
+
- 配置 Rspack 插件,请使用 [tools.bundlerChain](/configure/app/tools/bundler-chain) 配置项。
|
|
15
14
|
- 配置框架 Runtime 插件,请使用 [runtime 配置文件 plugins](/configure/app/runtime/plugins) 配置项。
|
|
16
15
|
|
|
17
16
|
## 示例
|
|
@@ -12,7 +12,7 @@ type Alias = Record<string, string | false | (string | false)[]> | Function;
|
|
|
12
12
|
|
|
13
13
|
- **默认值:** `undefined`
|
|
14
14
|
|
|
15
|
-
设置文件引用的别名,对应 Rspack 的 [resolve.alias](https://
|
|
15
|
+
设置文件引用的别名,对应 Rspack 的 [resolve.alias](https://rspack.rs/config/resolve#resolvealias) 配置。
|
|
16
16
|
|
|
17
17
|
:::tip
|
|
18
18
|
对于 TypeScript 项目,你只需要在 `tsconfig.json` 中配置 [compilerOptions.paths](https://www.typescriptlang.org/tsconfig#paths) 即可,Rsbuild 会自动识别它,不需要额外配置 `source.alias` 字段,详见 [「路径别名」](https://modernjs.dev/guides/basic-features/alias.html)。
|
|
@@ -9,10 +9,7 @@ title: include
|
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
const defaultInclude = [
|
|
12
|
-
[
|
|
13
|
-
{ not: /[\\/]node_modules[\\/]/ },
|
|
14
|
-
/\.(?:ts|tsx|jsx|mts|cts)$/,
|
|
15
|
-
],
|
|
12
|
+
[{ not: /[\\/]node_modules[\\/]/ }, /\.(?:ts|tsx|jsx|mts|cts)$/],
|
|
16
13
|
];
|
|
17
14
|
```
|
|
18
15
|
|
|
@@ -28,10 +25,7 @@ const defaultInclude = [
|
|
|
28
25
|
const defaultInclude = [
|
|
29
26
|
[
|
|
30
27
|
{
|
|
31
|
-
and: [
|
|
32
|
-
APP_ROOT,
|
|
33
|
-
{ not: /[\\/]node_modules[\\/]/ }
|
|
34
|
-
]
|
|
28
|
+
and: [APP_ROOT, { not: /[\\/]node_modules[\\/]/ }],
|
|
35
29
|
},
|
|
36
30
|
/\.(?:ts|tsx|jsx|mts|cts)$/,
|
|
37
31
|
],
|
|
@@ -41,14 +35,6 @@ const defaultInclude = [
|
|
|
41
35
|
与新版本的差异是,非当前项目目录的 `.js`、`.mjs`、`.cjs` 文件不会被编译。
|
|
42
36
|
:::
|
|
43
37
|
|
|
44
|
-
## Rspack
|
|
45
|
-
|
|
46
38
|
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
47
39
|
|
|
48
40
|
<RsbuildConfig configName="source.include" />
|
|
49
|
-
|
|
50
|
-
## Webpack
|
|
51
|
-
|
|
52
|
-
为了保证历史项目可以正常运行,Webpack 编译时,`source.include` 与 Rsbuild 1.4 版本前的默认值一致。
|
|
53
|
-
|
|
54
|
-
|
|
@@ -18,7 +18,7 @@ Modern.js 中并没有直接使用 [webpack-dev-server](https://webpack.js.org/a
|
|
|
18
18
|
#### compress
|
|
19
19
|
|
|
20
20
|
:::warning
|
|
21
|
-
**Deprecated**:该配置已废弃,请使用 [dev.server.compress](
|
|
21
|
+
**Deprecated**:该配置已废弃,请使用 [dev.server.compress](/configure/app/dev/server) 代替。
|
|
22
22
|
:::
|
|
23
23
|
|
|
24
24
|
- **类型:** `boolean`
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
#### headers
|
|
42
42
|
|
|
43
43
|
:::warning
|
|
44
|
-
**Deprecated**:该配置已废弃,请使用 [dev.server.headers](
|
|
44
|
+
**Deprecated**:该配置已废弃,请使用 [dev.server.headers](/configure/app/dev/server) 代替。
|
|
45
45
|
:::
|
|
46
46
|
|
|
47
47
|
- **类型:** `Record<string, string>`
|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
64
64
|
#### historyApiFallback
|
|
65
65
|
|
|
66
66
|
:::warning
|
|
67
|
-
**Deprecated**:该配置已废弃,请使用 [dev.server.historyApiFallback](
|
|
67
|
+
**Deprecated**:该配置已废弃,请使用 [dev.server.historyApiFallback](/configure/app/dev/server) 代替。
|
|
68
68
|
:::
|
|
69
69
|
|
|
70
70
|
- **类型:** `boolean | ConnectHistoryApiFallbackOptions`
|
|
@@ -87,7 +87,7 @@ export default {
|
|
|
87
87
|
#### proxy
|
|
88
88
|
|
|
89
89
|
:::warning
|
|
90
|
-
**Deprecated**:该配置已废弃,请使用 [dev.server.proxy](
|
|
90
|
+
**Deprecated**:该配置已废弃,请使用 [dev.server.proxy](/configure/app/dev/server) 代替。
|
|
91
91
|
:::
|
|
92
92
|
|
|
93
93
|
- **类型:** `Record<string, string> | Record<string, ProxyDetail>`
|
|
@@ -199,7 +199,7 @@ export default {
|
|
|
199
199
|
#### watch
|
|
200
200
|
|
|
201
201
|
:::warning
|
|
202
|
-
**Deprecated**:该配置已废弃,请使用 [dev.server.watch](
|
|
202
|
+
**Deprecated**:该配置已废弃,请使用 [dev.server.watch](/configure/app/dev/server) 代替。
|
|
203
203
|
:::
|
|
204
204
|
|
|
205
205
|
- **类型:** `boolean`
|
|
@@ -246,18 +246,6 @@ Modern.js 导出了 `AppUserConfig` 类型,对应 Modern.js 配置对象的类
|
|
|
246
246
|
```ts title="modern.config.ts"
|
|
247
247
|
import type { AppUserConfig } from '@modern-js/app-tools';
|
|
248
248
|
|
|
249
|
-
const config: AppUserConfig = {
|
|
250
|
-
tools: {
|
|
251
|
-
webpack: {},
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
当你使用 Rspack 作为打包工具时,由于 webpack 和 Rspack 的配置类型存在一些差异,需要为 `AppUserConfig` 指定 `` 泛型:
|
|
257
|
-
|
|
258
|
-
```ts title="modern.config.ts"
|
|
259
|
-
import type { AppUserConfig } from '@modern-js/app-tools';
|
|
260
|
-
|
|
261
249
|
const config: AppUserConfig = {
|
|
262
250
|
tools: {
|
|
263
251
|
rspack: {},
|
|
@@ -7,20 +7,6 @@ title: 运行时框架
|
|
|
7
7
|
|
|
8
8
|
Modern.js 以 [Hono.js](https://hono.dev/) 作为 BFF 和 Server 运行时框架,因此可以基于 Hono.js 生态[扩展 BFF Server](/guides/advanced-features/bff/extend-server.html)。
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
在 BFF 函数中,有时需要获取请求上下文,来处理更多逻辑。此时,你可以通过 `useHonoContext` 来获取:
|
|
13
|
-
|
|
14
|
-
```ts title="api/lambda/hello.ts"
|
|
15
|
-
import { useHonoContext } from '@modern-js/plugin-bff/server'
|
|
16
|
-
export const get = async () => {
|
|
17
|
-
const c = useHonoContext();
|
|
18
|
-
console.info(`access url: ${c.req.url}`);
|
|
19
|
-
return 'Hello Modern.js'
|
|
20
|
-
};
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
:::info
|
|
24
|
-
详细内容可以参考 [useHonoContext](/apis/app/runtime/bff/use-hono-context)。
|
|
25
|
-
:::
|
|
10
|
+
import Hono from '@site-docs/components/hono';
|
|
26
11
|
|
|
12
|
+
<Hono />
|