@modern-js/main-doc 0.0.0-next-1682468392848 → 0.0.0-next-1682520086226

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/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-1682468392848
3
+ ## 0.0.0-next-1682520086226
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 63b35384ea: fix: dev server crashed when prepare api handler failed
7
+ - 63b35384e: fix: dev server crashed when prepare api handler failed
8
8
 
9
9
  fix: 修复更新 api server 报错导致 dev server 退出的问题
10
10
 
11
- - fe92de6a5f: fix(builder): browserslist config should not affect node bundles
11
+ - fe92de6a5: fix(builder): browserslist config should not affect node bundles
12
12
 
13
13
  fix(builder): 修复 browserslist 配置会对 node 产物生效的问题
14
14
 
15
- - Updated dependencies [fe92de6a5f]
16
- - @modern-js/builder-doc@0.0.0-next-1682468392848
15
+ - Updated dependencies [fe92de6a5]
16
+ - @modern-js/builder-doc@0.0.0-next-1682520086226
17
17
 
18
18
  ## 2.15.0
19
19
 
@@ -0,0 +1,268 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # Contributing Guide
6
+
7
+ Thanks for that you are interested in contributing to Modern.js. Before starting your contribution, please take a moment to read the following guidelines.
8
+
9
+ ---
10
+
11
+ ## Setup the Dev Environment
12
+
13
+ ### Fork the Repo
14
+
15
+ [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your
16
+ own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local.
17
+
18
+ ### Install Node.js
19
+
20
+ We recommend using Node.js 16 or 18. You can check your currently used Node.js version with the following command:
21
+
22
+ ```bash
23
+ node -v
24
+ #v16.18.0
25
+ ```
26
+
27
+ If you do not have Node.js installed in your current environment, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install it.
28
+
29
+ Here is an example of how to install the Node.js 16 LTS version via nvm:
30
+
31
+ ```bash
32
+ # Install the LTS version of Node.js 16
33
+ nvm install 16 --lts
34
+
35
+ # Make the newly installed Node.js 16 as the default version
36
+ nvm alias default 16
37
+
38
+ # Switch to the newly installed Node.js 16
39
+ nvm use 16
40
+ ```
41
+
42
+ ### Install pnpm
43
+
44
+ ```sh
45
+ # Enable pnpm with corepack, only available on Node.js >= `v14.19.0`
46
+ corepack enable
47
+ ```
48
+
49
+ ### Install Dependencies
50
+
51
+ ```sh
52
+ pnpm install
53
+ ```
54
+
55
+ What this will do:
56
+
57
+ - Install all dependencies
58
+ - Create symlinks between packages in the monorepo
59
+ - Run the `prepare` script to build all packages (this will take some time, but is necessary to make ensure all packages are built)
60
+
61
+ > A full rebuild of all packages is generally not required after this. If a new feature you are developing requires an updated version of another package, it is usually sufficient to build the changed dependencies.
62
+
63
+ ### Set Git Email
64
+
65
+ Please make sure you have your email set up in `<https://github.com/settings/emails>`. This will be needed later when you want to submit a pull request.
66
+
67
+ Check that your git client is already configured the email:
68
+
69
+ ```sh
70
+ git config --list | grep email
71
+ ```
72
+
73
+ Set the email to global config:
74
+
75
+ ```sh
76
+ git config --global user.email "SOME_EMAIL@example.com"
77
+ ```
78
+
79
+ Set the email for local repo:
80
+
81
+ ```sh
82
+ git config user.email "SOME_EMAIL@example.com"
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Making Changes and Building
88
+
89
+ Once you have set up the local development environment in your forked repo, we can start development.
90
+
91
+ ### Checkout A New Branch
92
+
93
+ It is recommended to develop on a new branch, as it will make things easier later when you submit a pull request:
94
+
95
+ ```sh
96
+ git checkout -b MY_BRANCH_NAME
97
+ ```
98
+
99
+ ### Build the Package
100
+
101
+ To build the package you want to change, first open the package directory, then run the `build` command:
102
+
103
+ ```sh
104
+ # Replace some-path with the path of the package you want to work on
105
+ cd ./packages/some-path
106
+ pnpm run build
107
+ ```
108
+
109
+ Alternatively, you can build the package from the root directory of the repository using the `--filter` option:
110
+
111
+ ```sh
112
+ pnpm run --filter @modern-js/some-package build
113
+ ```
114
+
115
+ Build all packages:
116
+
117
+ ```sh
118
+ pnpm run prepare
119
+ ```
120
+
121
+ If you need to clean all `node_modules/*` in the project, run the `reset` command:
122
+
123
+ ```sh
124
+ pnpm run reset
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Testing
130
+
131
+ ### Add New Tests
132
+
133
+ If you've fixed a bug or added code that should be tested, then add some tests.
134
+
135
+ You can add unit test cases in the `<PACKAGE_DIR>/tests` folder. The test syntax is based on [Jest](https://jestjs.io/) and [Vitest](https://vitest.dev/).
136
+
137
+ ### Run Unit Tests
138
+
139
+ Before submitting a pull request, it's important to make sure that the changes haven't introduced any regressions or bugs. You can run the unit tests for the project by executing the following command:
140
+
141
+ ```sh
142
+ pnpm run test
143
+ ```
144
+
145
+ Alternatively, you can run the unit tests of single package using the `--filter` option:
146
+
147
+ ```sh
148
+ pnpm run --filter @modern-js/some-package test
149
+ ```
150
+
151
+ ### Run E2E Tests
152
+
153
+ In addition to the unit tests, the Modern.js also includes end-to-end (E2E) tests, which checks the functionality of the application as a whole.
154
+
155
+ You can run the `test:e2e` command to run the E2E tests:
156
+
157
+ ```sh
158
+ pnpm run test:e2e
159
+ ```
160
+
161
+ If you need to run a specified test, you can add keywords to filter:
162
+
163
+ ```sh
164
+ # Only run test cases with the copy-assets keyword
165
+ npx jest copy-assets
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Linting
171
+
172
+ To help maintain consistency and readability of the codebase, we use a ESLint to lint the codes.
173
+
174
+ You can run the Linter by executing the following command:
175
+
176
+ ```sh
177
+ pnpm run lint
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Documentation
183
+
184
+ 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.
185
+
186
+ You can find all the documentation in the `packages/document` folder:
187
+
188
+ ```bash
189
+ root
190
+ └─ packages
191
+ └─ document
192
+ ├─ builder-doc # Documentation for Modern.js Builder
193
+ ├─ doc-tools-doc # Documentation for Modern.js Doc
194
+ ├─ main-doc # Documentation for Modern.js Framework
195
+ └─ module-doc # Documentation for Modern.js Module
196
+ ```
197
+
198
+ This website is built with [Modern.js Doc](https://modernjs.dev/doc-tools), the document content can be written using markdown or mdx syntax. You can refer to the [Modern.js Doc Website](https://modernjs.dev/doc-tools) for detailed usage.
199
+
200
+ The source code of Modern.js Doc can be found in [this folder](https://github.com/web-infra-dev/modern.js/tree/main/packages/solutions/doc-tools).
201
+
202
+ ---
203
+
204
+ ## Submitting Changes
205
+
206
+ ### Add a Changeset
207
+
208
+ Modern.js is using [Changesets](https://github.com/changesets/changesets) to manage the versioning and changelogs.
209
+
210
+ If you've changed some packages, you need add a new changeset for the changes. Please run `change` command to select the changed packages and add the changeset info.
211
+
212
+ ```sh
213
+ pnpm run change
214
+ ```
215
+
216
+ ### Committing your Changes
217
+
218
+ Commit your changes to your forked repo, and [create a pull request](https://help.github.com/articles/creating-a-pull-request/).
219
+
220
+ ### Format of PR titles
221
+
222
+ The format of PR titles follow Conventional Commits.
223
+
224
+ An example:
225
+
226
+ ```
227
+ feat(plugin-swc): Add `xxx` config
228
+ ^ ^ ^
229
+ | | |__ Subject
230
+ | |_______ Scope
231
+ |____________ Type
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Publishing
237
+
238
+ We use **Modern.js Monorepo Solution** to manage version and changelog.
239
+
240
+ Repository maintainers can publish a new version of all packages to npm.
241
+
242
+ Here are the steps to publish (we generally use CI for releases and avoid publishing npm packages locally):
243
+
244
+ 1. Pull latest code from the `main` branch.
245
+ 2. Install:
246
+
247
+ ```sh
248
+ pnpm i
249
+ ```
250
+
251
+ 3. Build packages:
252
+
253
+ ```sh
254
+ pnpm run prepare
255
+ ```
256
+
257
+ 4. Bump version:
258
+
259
+ ```sh
260
+ pnpm run bump
261
+ ```
262
+
263
+ 5. Commit the version change.
264
+
265
+ ```sh
266
+ git add .
267
+ git commit -m "Release va.b.c"
268
+ ```
@@ -8,6 +8,22 @@ The development of Modern.js is driven by ByteDance's Modern.js team and communi
8
8
 
9
9
  ## Core Team Members
10
10
 
11
+ The Modern.js core team members:
12
+
11
13
  import { RandomMemberList } from '@site/src/components/RandomMemberList';
12
14
 
13
15
  <RandomMemberList />
16
+
17
+ ## All Contributors
18
+
19
+ Thanks to the following friends for their contributions to Modern.js:
20
+
21
+ <a
22
+ href="https://github.com/web-infra-dev/modern.js/graphs/contributors"
23
+ style={{ display: 'block', marginTop: 24 }}
24
+ >
25
+ <img
26
+ src="https://opencollective.com/modernjs/contributors.svg?width=890&button=false"
27
+ alt="contributors"
28
+ />
29
+ </a>
@@ -33,7 +33,7 @@ Then execute the `dev` or `build` command, and you can see Modern.js automatical
33
33
  node_modules
34
34
  └─ .modern-js
35
35
  └─ main
36
- ├─ bootstrap.jsx # real entry code
36
+ ├─ bootstrap.js # real entry code
37
37
  ├─ index.js # asynchronous entry file
38
38
  └─ index.html
39
39
  ```
@@ -41,7 +41,7 @@ node_modules
41
41
  The `index.js` reads as follows:
42
42
 
43
43
  ```js
44
- import('./bootstrap.jsx');
44
+ import('./bootstrap.js');
45
45
  ```
46
46
 
47
47
  At this point, you can consume any remote modules in the current page.
@@ -25,6 +25,7 @@ After the project is created, you can experience the project by running `pnpm ru
25
25
  :::tip
26
26
  When using Rspack as the bundler, the following Features are temporarily unavailable as some of the capabilities are still under development and we will provide support in the future.
27
27
 
28
+ - Micro Frontend
28
29
  - Storybook Devtool
29
30
  - Server Side Rendering + Conventional Routing
30
31
  - Static Site Generation + Conventional Routing
@@ -0,0 +1,267 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # 贡献指南
6
+
7
+ 感谢你有兴趣为 Modern.js 做贡献!在开始你的贡献之前,请花几分钟时间阅读以下指南。
8
+
9
+ ---
10
+
11
+ ## 设置开发环境
12
+
13
+ ### Fork 仓库
14
+
15
+ [Fork](https://help.github.com/articles/fork-a-repo/) Modern.js 仓库到你的 GitHub 账户,然后 [clone](https://help.github.com/articles/cloning-a-repository/) 到你的本地。
16
+
17
+ ### 安装 Node.js
18
+
19
+ 我们推荐使用 Node.js 16 或 18。你可以通过以下命令查看当前使用的 Node.js 版本:
20
+
21
+ ```bash
22
+ node -v
23
+ #v16.18.0
24
+ ```
25
+
26
+ 如果你当前环境没有安装 Node.js,可以使用 [nvm](https://github.com/nvm-sh/nvm)或者 [fnm](https://github.com/Schniz/fnm) 来安装它。
27
+
28
+ 以下是如何通过 nvm 安装 Node.js 16 LTS 版本的示例:
29
+
30
+ ```bash
31
+ # 安装 Node.js 16 的 LTS 版本
32
+ nvm install 16 --lts
33
+
34
+ # 将新安装的 Node.js 16 设为默认版本
35
+ nvm alias default 16
36
+
37
+ # 切换到新安装的 Node.js 16
38
+ nvm use 16
39
+ ```
40
+
41
+ ### 安装 pnpm
42
+
43
+ ```bash
44
+ # 使用 corepack 启用 pnpm,仅在 Node.js >= `v14.19.0` 上可用
45
+ corepack enable
46
+ ```
47
+
48
+ ### 安装依赖
49
+
50
+ ```sh
51
+ pnpm install
52
+ ```
53
+
54
+ 这将完成:
55
+
56
+ - 安装所有依赖项
57
+ - 在 monorepo 中的 packages 之间创建 symlinks
58
+ - 运行 `prepare` 脚本来构建所有包(这将需要一些时间,但可以保证所有包都被正确构建)
59
+
60
+ > 在此之后,你通常不需要一次性构建所有 packages。如果你正在开发的新功能依赖另一个 package 的最新代码,通常只构建指定的 package 就足够了。
61
+
62
+ ### 设置 Git 邮箱
63
+
64
+ 请确保在 `<https://github.com/settings/emails>` 中设置了电子邮件,当你提交 Pull Request 时将需要它。
65
+
66
+ 检查你的 git 客户端是否已配置邮箱:
67
+
68
+ ```sh
69
+ git config --list | grep email
70
+ ```
71
+
72
+ 全局设置邮箱:
73
+
74
+ ```sh
75
+ git config --global user.email "SOME_EMAIL@example.com"
76
+ ```
77
+
78
+ 针对本地仓库设置邮箱:
79
+
80
+ ```sh
81
+ git config user.email "SOME_EMAIL@example.com"
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 代码变更和构建
87
+
88
+ 当你在 fork 的仓库中设置完本地开发环境后,我们就可以开始开发了。
89
+
90
+ ### 创建一个新分支
91
+
92
+ 建议在一个新的分支上开发,这样便于后续提交 pull request:
93
+
94
+ ```sh
95
+ git checkout -b MY_BRANCH_NAME
96
+ ```
97
+
98
+ ### 构建 Package
99
+
100
+ 要构建你要更改的 package,首先打开 package 目录,然后执行 `build` 命令:
101
+
102
+ ```sh
103
+ # 将 some-path 替换为你要构建的 package 的路径
104
+ cd ./packages/some-package
105
+ pnpm run build
106
+ ```
107
+
108
+ 此外,你可以使用 `--filter` 选项从仓库根目录来构建指定的 package:
109
+
110
+ ```sh
111
+ pnpm run --filter @modern-js/some-package build
112
+ ```
113
+
114
+ 构建所有包:
115
+
116
+ ```sh
117
+ pnpm run prepare
118
+ ```
119
+
120
+ 如果你需要清理项目中的所有 `node_modules/*`,执行 `reset` 命令:
121
+
122
+ ```sh
123
+ pnpm 运行重置
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 测试
129
+
130
+ ### 添加新测试
131
+
132
+ 如果你进行了 bugfix,或者添加了需要测试的代码,请添加一些测试代码。
133
+
134
+ 你可以在 `<PACKAGE_DIR>/tests` 文件夹中添加单元测试用例。测试语法基于 [Jest](https://jestjs.io/) 和 [Vitest](https://vitest.dev/)。
135
+
136
+ ### 运行单元测试
137
+
138
+ 在提交 pull request 之前,为了确保本次变更没有引入缺陷,你可以通过执行以下命令运行单元测试:
139
+
140
+ ```sh
141
+ pnpm run test
142
+ ```
143
+
144
+ 你也可以使用 `--filter` 选项运行单个包的单元测试:
145
+
146
+ ```sh
147
+ pnpm run --filter @modern-js/some-package test
148
+ ```
149
+
150
+ ### 运行 E2E 测试
151
+
152
+ 除了单元测试之外,Modern.js 仓库还包括端到端 (E2E) 测试,用于检查整个应用程序的功能。
153
+
154
+ 你可以执行 `test:e2e` 命令来运行 E2E 测试:
155
+
156
+ ```sh
157
+ pnpm run test:e2e
158
+ ```
159
+
160
+ 如果需要运行指定的测试,可以添加关键字进行过滤:
161
+
162
+ ```sh
163
+ # 只运行带有 copy-assets 关键词的测试用例
164
+ npx jest copy-assets
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Linting
170
+
171
+ 为了帮助保持代码风格的一致性和可读性,我们使用 ESLint 对代码进行校验。
172
+
173
+ 你可以执行以下命令来运行 Linter:
174
+
175
+ ```sh
176
+ pnpm run lint
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 文档
182
+
183
+ 目前 Modern.js 提供英文和中文文档。如果你熟悉中文,请同时更新中英文文档。否则,只需更新英文文档即可。
184
+
185
+ 你可以在 `packages/document` 文件夹中找到所有文档:
186
+
187
+ ```sh
188
+ root
189
+ └─ packages
190
+ └─ document
191
+ ├─ builder-doc # Modern.js Builder 文档
192
+ ├─ doc-tools-doc # Modern.js Doc 文档
193
+ ├─ main-doc # Modern.js Framework 文档
194
+ └─ module-doc # Modern.js Module 文档
195
+ ```
196
+
197
+ 文档站使用 [Modern.js Doc](https://modernjs.dev/doc-tools) 构建,文档内容可以使用 markdown 或 mdx 语法编写。详细使用方法可以参考 [Modern.js Doc 文档](https://modernjs.dev/doc-tools)。
198
+
199
+ Modern.js Doc 的源代码可以在 [这个文件夹](https://github.com/web-infra-dev/modern.js/tree/main/packages/solutions/doc-tools) 中找到。
200
+
201
+ ---
202
+
203
+ ## 提交变更
204
+
205
+ ### 添加 Changeset
206
+
207
+ Modern.js 使用 [Changesets](https://github.com/changesets/changesets) 来管理版本和 Changelog。
208
+
209
+ 如果你修改了一些包,则需要为本次变更添加一个新的变更集。请运行 `change` 命令来选择更改的包并添加 changeset 信息。
210
+
211
+ ```sh
212
+ pnpm run change
213
+ ```
214
+
215
+ ### 提交你的变更
216
+
217
+ 提交变更到 fork 后的仓库,并 [创建 pull request](https://help.github.com/articles/creating-a-pull-request/)。
218
+
219
+ ### PR 标题格式
220
+
221
+ PR 标题的格式遵循 Conventional Commits。
222
+
223
+ 一个例子:
224
+
225
+ ```
226
+ feat(plugin-swc): 添加 `xxx` 配置项
227
+ ^ ^ ^
228
+ | | |__ 主题
229
+ | |_______ 范围
230
+ |____________ 类型
231
+ ```
232
+
233
+ ---
234
+
235
+ ## 发布
236
+
237
+ Modern.js 使用 [Changesets](https://github.com/changesets/changesets) 来管理版本和 changelog。
238
+
239
+ 仓库的维护者可以将所有包的新版本发布到 npm。
240
+
241
+ 以下是发布的步骤(我们通常使用 CI 进行发布,并避免在本地发布 npm 包):
242
+
243
+ 1. 拉取 `main` 分支的最新代码。
244
+ 2. 安装依赖:
245
+
246
+ ```sh
247
+ pnpm i
248
+ ```
249
+
250
+ 3. 构建 packages:
251
+
252
+ ```sh
253
+ pnpm prepare
254
+ ```
255
+
256
+ 4. 升级版本:
257
+
258
+ ```sh
259
+ pnpm run bump
260
+ ```
261
+
262
+ 5. 提交版本变更。
263
+
264
+ ```sh
265
+ git add .
266
+ git commit -m "Release va.b.c"
267
+ ```
@@ -8,6 +8,22 @@ Modern.js 的开发由字节跳动的 Modern.js 团队和社区贡献者驱动
8
8
 
9
9
  ## 核心团队成员
10
10
 
11
+ 以下是 Modern.js 团队的核心成员:
12
+
11
13
  import { RandomMemberList } from '@site/src/components/RandomMemberList';
12
14
 
13
15
  <RandomMemberList />
16
+
17
+ ## 所有贡献者
18
+
19
+ 感谢以下伙伴们为 Modern.js 做出的贡献:
20
+
21
+ <a
22
+ href="https://github.com/web-infra-dev/modern.js/graphs/contributors"
23
+ style={{ display: 'block', marginTop: 24 }}
24
+ >
25
+ <img
26
+ src="https://opencollective.com/modernjs/contributors.svg?width=890&button=false"
27
+ alt="contributors"
28
+ />
29
+ </a>
@@ -36,7 +36,7 @@ export default defineConfig({
36
36
  node_modules
37
37
  └─ .modern-js
38
38
  └─ main
39
- ├─ bootstrap.jsx # 真正的入口代码
39
+ ├─ bootstrap.js # 真正的入口代码
40
40
  ├─ index.js # 异步入口文件(asynchronous boundary)
41
41
  └─ index.html
42
42
  ```
@@ -44,7 +44,7 @@ node_modules
44
44
  其中 `index.js` 的内容如下:
45
45
 
46
46
  ```js
47
- import('./bootstrap.jsx');
47
+ import('./bootstrap.js');
48
48
  ```
49
49
 
50
50
  此时,就可以在当前页面中消费任意的远程模块了。
@@ -26,6 +26,7 @@ import InitRspackApp from '@site-docs/components/init-rspack-app';
26
26
  :::tip
27
27
  在使用 Rspack 作为打包工具时,由于部分能力尚在开发中,以下 features 暂时无法使用,我们将在未来提供支持:
28
28
 
29
+ - 微前端(Micro Frontend)
29
30
  - Storybook 调试
30
31
  - 同时使用服务端渲染(SSR)和约定式路由的场景
31
32
  - 同时使用静态站点生成(SSG)和约定式路由的场景
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-1682468392848",
14
+ "version": "0.0.0-next-1682520086226",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-1682468392848"
20
+ "@modern-js/builder-doc": "0.0.0-next-1682520086226"
21
21
  },
22
22
  "devDependencies": {
23
23
  "classnames": "^2",
@@ -29,9 +29,9 @@
29
29
  "fs-extra": "^10",
30
30
  "@types/node": "^16",
31
31
  "@types/fs-extra": "^9",
32
- "@modern-js/builder-doc": "0.0.0-next-1682468392848",
33
- "@modern-js/doc-tools": "0.0.0-next-1682468392848",
34
- "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1682468392848"
32
+ "@modern-js/builder-doc": "0.0.0-next-1682520086226",
33
+ "@modern-js/doc-tools": "0.0.0-next-1682520086226",
34
+ "@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1682520086226"
35
35
  },
36
36
  "scripts": {
37
37
  "dev": "modern dev",