@modern-js/main-doc 0.0.0-nightly-20240917170642 → 0.0.0-nightly-20240919170638
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 +4 -0
- package/docs/en/components/deploy-command.mdx +14 -0
- package/docs/en/configure/app/runtime/router.mdx +11 -3
- package/docs/en/configure/app/runtime/state.mdx +0 -2
- package/docs/en/guides/concept/_meta.json +1 -1
- package/docs/en/guides/concept/server.mdx +35 -0
- package/docs/en/guides/topic-detail/_meta.json +0 -6
- package/docs/en/guides/topic-detail/model/quick-start.mdx +5 -0
- package/docs/zh/apis/app/commands.mdx +4 -0
- package/docs/zh/components/deploy-command.mdx +14 -0
- package/docs/zh/configure/app/runtime/router.mdx +10 -4
- package/docs/zh/configure/app/runtime/state.mdx +0 -2
- package/docs/zh/guides/concept/_meta.json +1 -1
- package/docs/zh/guides/concept/server.mdx +35 -0
- package/docs/zh/guides/topic-detail/_meta.json +0 -6
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +5 -0
- package/package.json +2 -2
@@ -249,3 +249,7 @@ Inspect config succeed, open following files to view the content:
|
|
249
249
|
- Webpack Config (web): /root/my-project/dist/webpack.config.web.mjs
|
250
250
|
- Webpack Config (node): /root/my-project/dist/webpack.config.node.mjs
|
251
251
|
```
|
252
|
+
|
253
|
+
import DeployCommand from "@site-docs-en/components/deploy-command";
|
254
|
+
|
255
|
+
<DeployCommand />
|
@@ -0,0 +1,14 @@
|
|
1
|
+
## modern deploy
|
2
|
+
|
3
|
+
The `modern deploy` command is used to generate artifacts required for the deployment platform.
|
4
|
+
|
5
|
+
```bash
|
6
|
+
Usage: modern deploy [options]
|
7
|
+
|
8
|
+
Options:
|
9
|
+
-c --config <config> Specify configuration file path, either relative or absolute
|
10
|
+
-s --skip-build Skip the build stage
|
11
|
+
-h, --help Display command help
|
12
|
+
```
|
13
|
+
|
14
|
+
For more details, refer to [Deploy Application](/guides/basic-features/deploy).
|
@@ -8,12 +8,16 @@ import RouterLegacyTip from "@site-docs-en/components/router-legacy-tip"
|
|
8
8
|
|
9
9
|
<RouterLegacyTip />
|
10
10
|
|
11
|
-
# runtime.router
|
12
|
-
|
13
11
|
- **Type:** `boolean | Object`
|
14
12
|
- **Default:** `false`
|
15
13
|
|
16
|
-
|
14
|
+
This value is set to `true` when the project is created, supporting the use of [conventional routing](/guides/concept/entries.html#约定式路由) provided by Modern.js for routing management.
|
15
|
+
|
16
|
+
If you wish to use [controlled routing](/guides/concept/entries.html#自控式路由), please remove this value or set it to `false`.
|
17
|
+
|
18
|
+
:::note
|
19
|
+
All sub-configurations of `router` will only take effect when using conventional routing.
|
20
|
+
:::
|
17
21
|
|
18
22
|
## basename
|
19
23
|
|
@@ -22,6 +26,10 @@ When enabled, the router option provides routing management for Modern.js conven
|
|
22
26
|
|
23
27
|
The basename option specifies the subpath where the app is deployed, for situations where it cannot be deployed to the root domain.
|
24
28
|
|
29
|
+
:::tip
|
30
|
+
推荐使用 [`server.baseUrl`](/configure/app/server/base-url) 进行配置。
|
31
|
+
:::
|
32
|
+
|
25
33
|
## supportHtml5History
|
26
34
|
|
27
35
|
- **Type:** `boolean`
|
@@ -1 +1 @@
|
|
1
|
-
["entries", "builder"]
|
1
|
+
["entries", "builder", "server"]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Web Server
|
2
|
+
|
3
|
+
Modern.js provides an integrated Web server for applications that can run in any container environment with Node.js. Whether executing the `dev` command in a local development environment, running the `build && serve` commands in a production environment, or using the official deployment solution, it all runs through this Web server to host the application.
|
4
|
+
|
5
|
+
## Underlying Dependencies
|
6
|
+
|
7
|
+
Modern.js builds its Web server based on the [Hono framework](https://hono.dev/). Hono is a small, simple, and ultra-fast web standard-based framework that can run on any JavaScript runtime.
|
8
|
+
|
9
|
+
## Development & Production
|
10
|
+
|
11
|
+
The Web server flow in both Modern.js development and production environments is entirely isomorphic, so you don't need to worry about differences between them.
|
12
|
+
|
13
|
+
As mentioned in the [Build Tools](/guides/concept/builder) section, Modern.js' underlying build capability is provided by Rsbuild, and some server-side capabilities in the development environment are coupled with the build tools, such as HMR. Modern.js needs to reuse these capabilities of the Rsbuild Dev Server.
|
14
|
+
|
15
|
+
In the development environment, Modern.js directly uses the middlewares provided by Rsbuild, which includes capabilities needed during the development stage such as HMR and Proxy. Additionally, Modern.js provides capabilities such as Mock, routing, and rendering on top of this:
|
16
|
+
|
17
|
+

|
18
|
+
|
19
|
+
Therefore, in Modern.js, the development environment merely adds middleware to the production environment. All capabilities of the production environment are also applicable in the development environment, ensuring no fragmentation between the two.
|
20
|
+
|
21
|
+
:::tip
|
22
|
+
Static asset files can be directly hosted by Modern.js' server, but it is highly recommended to upload these files to a CDN in a production environment.
|
23
|
+
:::
|
24
|
+
|
25
|
+
## Running in CI Environments
|
26
|
+
|
27
|
+
Modern.js supports running built artifacts in any Node.js environment. Typically, the CI environment has already installed all application dependencies.
|
28
|
+
|
29
|
+
You can run the [`modern build`](/apis/app/commands#modern-build) command to build the application and the [`modern serve`](/apis/app/commands#modern-serve) command to run the Web server, starting the Modern.js application.
|
30
|
+
|
31
|
+
## Running in Production Environments
|
32
|
+
|
33
|
+
When deploying to production, the artifact size should be as small as possible. The aforementioned method for running in CI environments keeps all artifacts from the original project. Therefore, it is not recommended to run the application using the above commands in a production environment.
|
34
|
+
|
35
|
+
Modern.js offers a standalone deployment solution. When running the [`modern deploy`](/apis/app/commands#modern-deploy) command, the artifacts will include an entry file for running the Web server.
|
@@ -2,6 +2,11 @@
|
|
2
2
|
sidebar_position: 1
|
3
3
|
title: Quick Start
|
4
4
|
---
|
5
|
+
|
6
|
+
:::caution
|
7
|
+
New projects are no longer recommended to use Reduck. You can use state management tools from the community, such as [Jotai](https://jotai.org/), [zustand](https://zustand.docs.pmnd.rs/getting-started/introduction), [valtio](https://valtio.dev/docs/introduction/getting-started), etc.
|
8
|
+
:::
|
9
|
+
|
5
10
|
# Quick Start
|
6
11
|
|
7
12
|
import ReduckMigration from "@site-docs-en/components/reduck-migration"
|
@@ -249,3 +249,7 @@ Inspect config succeed, open following files to view the content:
|
|
249
249
|
- Webpack Config (web): /root/my-project/dist/webpack.config.web.mjs
|
250
250
|
- Webpack Config (node): /root/my-project/dist/webpack.config.node.mjs
|
251
251
|
```
|
252
|
+
|
253
|
+
import DeployCommand from "@site-docs/components/deploy-command";
|
254
|
+
|
255
|
+
<DeployCommand />
|
@@ -0,0 +1,14 @@
|
|
1
|
+
## modern deploy
|
2
|
+
|
3
|
+
`modern deploy` 命令,用于生成部署平台需要的产物。
|
4
|
+
|
5
|
+
```bash
|
6
|
+
Usage: modern deploy [options]
|
7
|
+
|
8
|
+
Options:
|
9
|
+
-c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
|
10
|
+
-s --skip-build 跳过构建阶段
|
11
|
+
-h, --help 显示命令帮助
|
12
|
+
```
|
13
|
+
|
14
|
+
详细内容可以参考 [部署应用](/guides/basic-features/deploy)。
|
@@ -8,14 +8,16 @@ import RouterLegacyTip from "@site-docs/components/router-legacy-tip"
|
|
8
8
|
|
9
9
|
<RouterLegacyTip />
|
10
10
|
|
11
|
-
# runtime.router
|
12
|
-
|
13
11
|
- **类型:** `boolean | Object`
|
14
12
|
- **默认值:** `false`
|
15
13
|
|
16
|
-
|
14
|
+
该值在项目创建时被设置为 `true`,支持使用 Modern.js 默认提供的[约定式路由](/guides/concept/entries.html#约定式路由)进行路由管理。
|
15
|
+
|
16
|
+
如果希望使用[自控式路由](/guides/concept/entries.html#自控式路由),请移除该值,或将该值设置为 `false`。
|
17
17
|
|
18
|
-
|
18
|
+
:::note
|
19
|
+
`router` 的所有子配置都只会在使用约定式路由时生效。
|
20
|
+
:::
|
19
21
|
|
20
22
|
## basename
|
21
23
|
|
@@ -24,6 +26,10 @@ import RouterLegacyTip from "@site-docs/components/router-legacy-tip"
|
|
24
26
|
|
25
27
|
设置客户端路由的 `basename`,通常用于应用需要部署在域名非根路径下的场景。
|
26
28
|
|
29
|
+
:::tip
|
30
|
+
推荐使用 [`server.baseUrl`](/configure/app/server/base-url) 进行配置。
|
31
|
+
:::
|
32
|
+
|
27
33
|
## supportHtml5History
|
28
34
|
|
29
35
|
- **类型:** `boolean`
|
@@ -1 +1 @@
|
|
1
|
-
["entries", "builder"]
|
1
|
+
["entries", "builder", "server"]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Web 服务器
|
2
|
+
|
3
|
+
Modern.js 为应用提供了内置的 Web 服务器,可以被运行在任何拥有 Node.js 的容器环境中。无论是在本地开发环境中执行 `dev` 命令,或是执行 `build && serve` 命令运行生成环境产物,或是官方的部署方案,都是通过这个 Web 服务器来托管应用。
|
4
|
+
|
5
|
+
## 底层依赖
|
6
|
+
|
7
|
+
Modern.js 基于 [Hono 框架](https://hono.dev/) 搭建了自己的 Web 服务器。Hono 是一个小型、简单且超快速的基于 Web 标准的框架,它能在任何 JavaScript 运行时上运行。
|
8
|
+
|
9
|
+
## 开发 & 生产
|
10
|
+
|
11
|
+
Modern.js 开发环境和生产环境的 Web 服务器流程是完全同构的,你无需担心开发环境和生产环境的差异。
|
12
|
+
|
13
|
+
在 [构建工具](/guides/concept/builder) 一节我们提到,Modern.js 底层构建能力由 Rsbuild 提供,而部分开发环境的服务端能力是与构建工具耦合的,例如 HMR。Modern.js 需要复用 Rsbuild Dev Server 的能力。
|
14
|
+
|
15
|
+
在开发环境,Modern.js 直接使用了 Rsbuild 提供的中间件,包含 HMR、Proxy 等开发阶段需要的能力。同时,Modern.js 在这之上提供了 Mock、路由、渲染等能力:
|
16
|
+
|
17
|
+

|
18
|
+
|
19
|
+
因此,在 Modern.js 中开发环境只是在生产环境上增加了中间件。生产环境的所有能力,在开发环境中也同样适用,两者不会产生割裂。
|
20
|
+
|
21
|
+
:::tip
|
22
|
+
静态资源文件能够直接被 Modern.js 的服务器托管,但在生产环境中,强烈推荐将这些内容上传到 CDN。
|
23
|
+
:::
|
24
|
+
|
25
|
+
## 在 CI 环境中运行
|
26
|
+
|
27
|
+
Modern.js 支持在任何 Node.js 环境运行构建产物。在 CI 环境中,通常情况下已经安装了应用全部的依赖。
|
28
|
+
|
29
|
+
你可以执行 [`modern build`](/apis/app/commands#modern-build) 来构建应用,执行 [`modern serve`](/apis/app/commands#modern-serve) 命令来运行 Web 服务器,启动 Modern.js 应用。
|
30
|
+
|
31
|
+
## 在生产环境中运行
|
32
|
+
|
33
|
+
在部署到生产环境时,产物体积应该尽可能小,而上述在 CI 中运行的方案,会保留原项目的所有产物。因此在生产环境,不推荐通过上述命令运行应用。
|
34
|
+
|
35
|
+
Modern.js 提供了独立的部署方案,当运行 [`modern deploy`](/apis/app/commands#modern-deploy) 命令时,产物中会包含可运行 Web 服务器的入口文件。
|
@@ -2,6 +2,11 @@
|
|
2
2
|
sidebar_position: 1
|
3
3
|
title: 快速上手
|
4
4
|
---
|
5
|
+
|
6
|
+
:::caution
|
7
|
+
新项目不再推荐使用 Reduck,可以使用社区中的状态管理工具,例如 [Jotai](https://jotai.org/)、[zustand](https://zustand.docs.pmnd.rs/getting-started/introduction)、[valtio](https://valtio.dev/docs/introduction/getting-started) 等。
|
8
|
+
:::
|
9
|
+
|
5
10
|
# 快速上手
|
6
11
|
|
7
12
|
import ReduckMigration from "@site-docs/components/reduck-migration"
|
package/package.json
CHANGED
@@ -15,14 +15,14 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "0.0.0-nightly-
|
18
|
+
"version": "0.0.0-nightly-20240919170638",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public",
|
22
22
|
"provenance": true
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/sandpack-react": "0.0.0-nightly-
|
25
|
+
"@modern-js/sandpack-react": "0.0.0-nightly-20240919170638"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@rspress/shared": "1.31.0",
|