@modern-js/main-doc 2.39.2 → 2.41.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -178,6 +178,16 @@ pnpm run lint
178
178
 
179
179
  ---
180
180
 
181
+ ## Benchmarking
182
+
183
+ You can input `!bench-framework` or `!bench-module` in the comment area of ​​the PR to do benchmarking on `@modern-js/app-tools` and `@modern-js/module-tools` respectively (you need to have Collaborator and above permissions).
184
+
185
+ You can focus on metrics related to build time and bundle size based on the comparison table output by comments to assist you in making relevant performance judgments and decisions.
186
+
187
+ Dependencies installation-related metrics base on publishing process, so the data is relatively lagging and is for reference only.
188
+
189
+ ---
190
+
181
191
  ## Documentation
182
192
 
183
193
  Currently Modern.js provides documentation in English and Chinese. If you can use Chinese, please update both documents at the same time. Otherwise, just update the English documentation.
@@ -7,7 +7,7 @@ sidebar_position: 1
7
7
 
8
8
  **Modern.js is an open source web engineering system from ByteDance**, which provides multiple solutions to help developers solve problems in different development scenarios.
9
9
 
10
- Currently, Modern.js includes three solutions, targeting web application development, npm package development, and web application building:
10
+ Currently, Modern.js includes two solutions, targeting web application development and npm package development:
11
11
 
12
12
  import { SolutionCards } from '@site/src/components/SolutionCards';
13
13
 
@@ -23,11 +23,6 @@ import { SolutionCards } from '@site/src/components/SolutionCards';
23
23
  description: 'For npm package development',
24
24
  link: 'http://modernjs.dev/module-tools/en/',
25
25
  },
26
- {
27
- title: 'Modern.js Builder',
28
- description: 'For web application building',
29
- link: 'http://modernjs.dev/builder/en/',
30
- },
31
26
  ]}
32
27
  />
33
28
 
@@ -37,18 +32,14 @@ As part of the Modern.js engineering system, each of the above solutions can be
37
32
 
38
33
  **The current documentation site corresponds to the Modern.js framework**, which is used to developing web applications.
39
34
 
40
- - If you need to develop an npm package, please refer to the [Modern.js Module](https://modernjs.dev/module-tools) documentation.
41
- - If you need to implement a web development framework based on the Modern.js build tool, please refer to the [Modern.js Builder](https://modernjs.dev/builder) documentation.
35
+ - If you need to develop an npm package, please refer to the [Modern.js Module documentation](https://modernjs.dev/module-tools).
36
+ - If you need a build tool to bundle web applications, [Rsbuild](https://rsbuild.dev/) is recommended.
37
+ - If you need to develop a documentation site, [Rspress](https://rspress.dev/) is recommended.
42
38
 
43
39
  :::tip
44
40
  Since the Modern.js framework is the most widely used, in this documentation site, we will omit "framework" and directly refer to it as Modern.js.
45
41
  :::
46
42
 
47
- Modern.js can also be combined with the following solutions:
48
-
49
- - If you need to develop a documentation site, [Rspress](https://rspress.dev/) is recommended.
50
- - If you need to introduce micro-frontend architecture, [Garfish](https://garfishjs.org/) is recommended.
51
-
52
43
  ## Modern.js Framework
53
44
 
54
45
  **The Modern.js framework is a progressive web framework based on React**. At ByteDance, we use Modern.js to build upper-level frameworks that have supported the development of thousands of web applications.
@@ -86,6 +77,10 @@ Umi is a popular React framework in the Chinese community and serves as the unde
86
77
 
87
78
  In addition, Modern.js provides richer server-side features, including comprehensive SSR capabilities, integrated BFF development capabilities, and support for custom web servers. These capabilities have been extensively validated by ByteDance in numerous online applications and can be directly used in production environments.
88
79
 
80
+ ### Remix
81
+
82
+ Pelease refer to [Modern.js vs Remix](https://github.com/web-infra-dev/modern.js/discussions/4872).
83
+
89
84
  ## Next Step
90
85
 
91
86
  If you want to learn how to use the Modern.js framework, you can try to [create your first application](/tutorials/first-app/c01-start), or read the [Quick Start](/guides/get-started/quick-start) guide.
@@ -84,72 +84,6 @@ The configuration returned by the `config` hook will be collected and merged by
84
84
  2. Configuration defined by the plugin through the `config` hook.
85
85
  3. Default configuration of Modern.js.
86
86
 
87
- ### `validateSchema`
88
-
89
- - Functionality: Collect the JSON schema used to validate user configurations in various plugins.
90
- - Execution phase: After the `config` Hook has run.
91
- - Hook model: `ParallelWorkflow`
92
- - Type: `ParallelWorkflow<void, unknown>`
93
- - Example:
94
-
95
- ```ts
96
- import type { CliPlugin } from '@modern-js/core';
97
-
98
- export const myPlugin = (): CliPlugin => ({
99
- setup(api) {
100
- return {
101
- validateSchema: () => {
102
- return {
103
- // target is field
104
- target: 'foo',
105
- schema: {
106
- type: 'string',
107
- },
108
- };
109
- },
110
- };
111
- },
112
- });
113
- ```
114
-
115
- The returned JSON Schema here is used to validate the configuration information in `modern.config.js`.
116
-
117
- For example, the following JSON Schema is returned:
118
-
119
- ```json
120
- {
121
- "target": "foo",
122
- "schema": {
123
- "type": "string"
124
- }
125
- }
126
- ```
127
-
128
- You can configure it in `modern.config.ts` like this:
129
-
130
- ```ts title="modern.config.ts"
131
- export const myPlugin = defineConfig({
132
- foo: 'test',
133
- });
134
- ```
135
-
136
- If it is another type, validation will fail and an error will be reported. For example:
137
-
138
- ```ts title="modern.config.ts"
139
- export const myPlugin = defineConfig({
140
- foo: {},
141
- });
142
- ```
143
-
144
- then throw error:
145
-
146
- ```
147
- $ modern dev
148
- 1 | {
149
- > 2 | "foo": {},
150
- | ^^^^^ Property foo is not expected to be here
151
- ```
152
-
153
87
  ### `prepare`
154
88
 
155
89
  - Functionality: Preparatory process for running the main process.
@@ -177,6 +177,16 @@ pnpm run lint
177
177
 
178
178
  ---
179
179
 
180
+ ## Benchmarking
181
+
182
+ 你可以在 PR 的评论区中输入 `!bench-framework` 或 `!bench-module` 分别对 `@modern-js/app-tools` 和 `@modern-js/module-tools` 做性能测试(这需要你具有 Collaborator 及以上的权限)。
183
+
184
+ 你可以根据评论输出的对比表格,重点关注构建时间和产物体积相关的指标,辅助进行相关性能判断与决策。
185
+
186
+ 依赖安装相关指标由于需要前置的发包流程,因此数据相对有滞后性,仅供参考。
187
+
188
+ ---
189
+
180
190
  ## 文档
181
191
 
182
192
  目前 Modern.js 提供英文和中文文档。如果你熟悉中文,请同时更新中英文文档。否则,只需更新英文文档即可。
@@ -7,7 +7,7 @@ sidebar_position: 1
7
7
 
8
8
  **Modern.js 是字节跳动 Web 工程体系的开源版本**,它提供多个解决方案,来帮助开发者解决不同研发场景下的问题。
9
9
 
10
- 目前 Modern.js 包含三个解决方案,分别面向 Web 应用开发场景、npm 包开发场景和 Web 应用构建场景:
10
+ 目前 Modern.js 包含两个解决方案,分别面向 Web 应用开发场景 npm 包开发场景:
11
11
 
12
12
  import { SolutionCards } from '@site/src/components/SolutionCards';
13
13
 
@@ -23,32 +23,21 @@ import { SolutionCards } from '@site/src/components/SolutionCards';
23
23
  description: '易用、高性能的 npm 包开发方案',
24
24
  link: 'http://modernjs.dev/module-tools/',
25
25
  },
26
- {
27
- title: 'Modern.js Builder',
28
- description: '基于 Rspack 的 Web 构建工具',
29
- link: 'http://modernjs.dev/builder/',
30
- },
31
26
  ]}
32
27
  />
33
28
 
34
- 作为 Modern.js 工程体系的一部分,以上每个解决方案都可以被单独使用,并且各自部署了独立的文档站点。开发者可以按需选择其中的一个或多个解决方案来使用。
35
-
36
29
  ## 关于文档
37
30
 
38
31
  **当前文档站对应的是 Modern.js 框架**,适用于开发 Web 应用。
39
32
 
40
- - 如果你需要开发一个 npm 包,请移步 [Modern.js Module](https://modernjs.dev/module-tools) 文档。
41
- - 如果你需要基于 Modern.js 的构建工具来实现一个 Web 开发框架,请移步 [Modern.js Builder](https://modernjs.dev/builder) 文档。
33
+ - 如果你需要开发一个 npm 包,请移步 [Modern.js Module 文档](https://modernjs.dev/module-tools)
34
+ - 如果你需要一个构建工具来打包 Web 应用,请移步 [Rsbuild 文档](https://rsbuild.dev/)
35
+ - 如果你需要开发一个文档站点,推荐使用 [Rspress 文档](https://rspress.dev/)。
42
36
 
43
37
  :::tip
44
38
  由于 Modern.js 框架的使用最为广泛,在本文档站中,我们会省略「框架」,直接称其为 Modern.js。
45
39
  :::
46
40
 
47
- Modern.js 也可以与以下解决方案结合使用:
48
-
49
- - 如果你需要开发一个文档站点,推荐使用 [Rspress](https://rspress.dev/) 文档。
50
- - 如果你需要引入微前端架构,推荐使用 [Garfish](https://garfishjs.org/)。
51
-
52
41
  ## Modern.js 框架
53
42
 
54
43
  **Modern.js 框架是一个基于 React 的渐进式 Web 开发框架**。在字节跳动内部,我们将 Modern.js 封装为上层框架,并支撑了数千个 Web 应用的研发。
@@ -86,6 +75,10 @@ Umi 是中文社区中非常流行的 React 框架,也是蚂蚁集团的底层
86
75
 
87
76
  此外,Modern.js 的服务端能力更加丰富,包括完备的 SSR 能力、一体化 BFF 开发能力和自定义 Web Server 支持。这些能力经过了字节跳动大量线上应用的验证,可以直接用于生产环境。
88
77
 
78
+ ### Remix
79
+
80
+ 请参考 [Modern.js vs Remix](https://github.com/web-infra-dev/modern.js/discussions/4872)。
81
+
89
82
  ## 下一步
90
83
 
91
84
  如果你希望了解如何使用 Modern.js 框架,可以尝试 [创建第一个应用](/tutorials/first-app/c01-start),或是阅读 [快速上手](/guides/get-started/quick-start)。
@@ -84,72 +84,6 @@ export const myPlugin = (): CliPlugin => ({
84
84
  2. 插件通过 `config` hook 定义的配置
85
85
  3. Modern.js 默认配置。
86
86
 
87
- ### `validateSchema`
88
-
89
- - 功能:收集各个插件中配置的用来校验用户配置的 [JSON Schema](https://json-schema.org/)
90
- - 执行阶段:`config` Hook 运行完成之后。
91
- - Hook 模型:`ParallelWorkflow`
92
- - 类型:`ParallelWorkflow<void, unknown>`
93
- - 使用示例:
94
-
95
- ```ts
96
- import type { CliPlugin } from '@modern-js/core';
97
-
98
- export const myPlugin = (): CliPlugin => ({
99
- setup(api) {
100
- return {
101
- validateSchema: () => {
102
- return {
103
- // target is field
104
- target: 'foo',
105
- schema: {
106
- type: 'string',
107
- },
108
- };
109
- },
110
- };
111
- },
112
- });
113
- ```
114
-
115
- 这里返回的 JSON Schema 会用来校验 `modern.config.js` 中的配置信息。
116
-
117
- 比如这里返回:
118
-
119
- ```json
120
- {
121
- "target": "foo",
122
- "schema": {
123
- "type": "string"
124
- }
125
- }
126
- ```
127
-
128
- 就可以在 `modern.config.ts` 中这样配置:
129
-
130
- ```ts title="modern.config.ts"
131
- export const myPlugin = defineConfig({
132
- foo: 'test',
133
- });
134
- ```
135
-
136
- 如果是别的类型,校验就不通过会报错,比如这样:
137
-
138
- ```ts title="modern.config.ts"
139
- export const myPlugin = defineConfig({
140
- foo: {},
141
- });
142
- ```
143
-
144
- 就会报错:
145
-
146
- ```
147
- $ modern dev
148
- 1 | {
149
- > 2 | "foo": {},
150
- | ^^^^^ Property foo is not expected to be here
151
- ```
152
-
153
87
  ### `prepare`
154
88
 
155
89
  - 功能:运行主流程的前置准备流程
package/package.json CHANGED
@@ -15,17 +15,17 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.39.2",
18
+ "version": "2.41.0",
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": "2.39.2"
25
+ "@modern-js/sandpack-react": "2.41.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "@modern-js/builder-doc": "^2.39.2"
28
+ "@modern-js/builder-doc": "^2.41.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "classnames": "^2",
@@ -35,12 +35,12 @@
35
35
  "ts-node": "^10.9.1",
36
36
  "typescript": "^5",
37
37
  "fs-extra": "^10",
38
- "rspress": "1.4.0",
39
- "@rspress/shared": "1.4.0",
38
+ "rspress": "1.7.1",
39
+ "@rspress/shared": "1.7.1",
40
40
  "@types/node": "^16",
41
- "@types/fs-extra": "^9",
42
- "@modern-js/doc-plugin-auto-sidebar": "2.39.2",
43
- "@modern-js/builder-doc": "2.39.2"
41
+ "@types/fs-extra": "9.0.13",
42
+ "@modern-js/builder-doc": "2.41.0",
43
+ "@modern-js/doc-plugin-auto-sidebar": "2.41.0"
44
44
  },
45
45
  "scripts": {
46
46
  "dev": "rspress dev",
package/rspress.config.ts CHANGED
@@ -50,12 +50,16 @@ const getNavbar = (lang: string): NavItem[] => {
50
50
  text: `v${version}`,
51
51
  items: [
52
52
  {
53
- text: 'Modern.js Module',
54
- link: 'https://modernjs.dev/module-tools/en/',
53
+ text: 'Rsbuild',
54
+ link: 'https://github.com/web-infra-dev/rsbuild',
55
+ },
56
+ {
57
+ text: 'Rspress',
58
+ link: 'https://github.com/web-infra-dev/rspress',
55
59
  },
56
60
  {
57
- text: 'Modern.js Builder',
58
- link: 'https://modernjs.dev/builder/en/',
61
+ text: 'Modern.js Module',
62
+ link: 'https://modernjs.dev/module-tools/en/',
59
63
  },
60
64
  {
61
65
  text: 'Modern.js v1',
@@ -42,6 +42,10 @@
42
42
  }
43
43
  }
44
44
 
45
+ .twoCards {
46
+ flex: 0 1 48%;
47
+ }
48
+
45
49
  @media (max-width: 480px) {
46
50
  .card {
47
51
  flex: 0 1 100%;
@@ -14,7 +14,11 @@ export const SolutionCards = ({ cards }: { cards: Card[] }) => {
14
14
  <a
15
15
  key={card.title}
16
16
  href={card.link}
17
- className={clsx([styles.card, classNames[index]])}
17
+ className={clsx([
18
+ styles.card,
19
+ classNames[index],
20
+ cards.length === 2 ? styles.twoCards : '',
21
+ ])}
18
22
  target="_blank"
19
23
  >
20
24
  <div className={styles.title}>{card.title}</div>
@@ -99,16 +99,6 @@ export default function Home() {
99
99
  href: `https://modernjs.dev/module-tools${lang === 'en' ? '/en' : ''}`,
100
100
  desc: t('solutionsDesc2'),
101
101
  },
102
- {
103
- title: 'Modern.js Builder',
104
- href: `https://modernjs.dev/builder${lang === 'en' ? '/en' : ''}`,
105
- desc: t('solutionsDesc3'),
106
- },
107
- {
108
- title: 'Rspress',
109
- href: `https://rspress.dev${lang === 'en' ? '' : '/zh'}`,
110
- desc: t('solutionsDesc4'),
111
- },
112
102
  ];
113
103
 
114
104
  return (