@modern-js/main-doc 0.0.0-next-1686023023547 → 0.0.0-next-1686044917772
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 +12 -3
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/deploy.mdx +1 -0
- package/docs/en/components/init-app.mdx +4 -8
- package/docs/en/components/release-note.mdx +1 -0
- package/docs/en/configure/app/tools/swc.mdx +2 -16
- package/docs/en/guides/get-started/glossary.mdx +12 -12
- package/docs/en/guides/get-started/introduction.mdx +18 -21
- package/docs/en/guides/get-started/quick-start.mdx +21 -37
- package/docs/en/guides/get-started/upgrade.mdx +15 -14
- package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
- package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
- package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
- package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
- package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
- package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
- package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
- package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
- package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
- package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/components/init-app.mdx +5 -9
- package/docs/zh/configure/app/tools/swc.mdx +2 -16
- package/docs/zh/guides/get-started/quick-start.mdx +7 -10
- package/docs/zh/guides/get-started/upgrade.mdx +1 -1
- package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
- package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
- package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
- package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
- package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
- package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
- package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
- package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
- package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
- package/package.json +5 -5
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Publishing Version
|
|
6
|
+
|
|
7
|
+
When releasing a version, we need to upgrade the version of the corresponding packages based on the changeset generated during development, and run the publish command to publish them to NPM.
|
|
8
|
+
|
|
9
|
+
## Steps
|
|
10
|
+
|
|
11
|
+
:::info
|
|
12
|
+
The following example commands are all using pnpm. If you need to use other package management tools, please replace them as needed.
|
|
13
|
+
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
### Npm Module
|
|
17
|
+
|
|
18
|
+
#### Run the bump command in the root directory
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm run bump
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
When running this command, changesets will automatically perform the following operations:
|
|
27
|
+
|
|
28
|
+
- Delete all changeset files under the `.changesets` directory.
|
|
29
|
+
|
|
30
|
+
- Upgrade the package version based on the changeset information.
|
|
31
|
+
|
|
32
|
+
- Write changelog information to the `CHANGELOG.md` file in the root directory. The file will be automatically created if it does not exist.
|
|
33
|
+
|
|
34
|
+
#### Confirm and submit the current changes
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git add .
|
|
38
|
+
git commit -m "release: bump package"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Run the release command in the root directory to publish the package to NPM
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm run release
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
#### Push the tag to the remote repository
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git push --follow-tags
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Monorepo
|
|
56
|
+
|
|
57
|
+
#### Run the bmp command in the root directory
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pnpm run bump
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
When running this command, changesets will automatically perform the following operations:
|
|
66
|
+
|
|
67
|
+
- Delete all changeset files under the `.changesets` directory.
|
|
68
|
+
|
|
69
|
+
- Upgrade the version of the relevant packages based on the changeset information. In addition to the packages written in the changeset, changesets will also analyze the dependency graph of all packages in the Monorepo during running. If is required, the version will be automatically upgraded accordingly.
|
|
70
|
+
|
|
71
|
+
- Write changelog to the `CHANGELOG.md` file in the directory of the package that needs to be upgraded. The file will be automatically created if it does not exist.
|
|
72
|
+
|
|
73
|
+
#### Confirm and submit the current changes
|
|
74
|
+
|
|
75
|
+
:::info
|
|
76
|
+
Make sure that the automatically upgraded version meet the expected requirements. If you need to understand the version upgrade strategy, please refer to [Version Upgrade Strategy](/guides/topic-detail/changesets/release#version-upgrade-strategy).
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git add .
|
|
81
|
+
git commit -m "release: bump package"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Run the release command in the root directory to publish the package to NPM
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm run release
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
When running this command, it will sequentially determine whether the versions of all packages in the Monorepo exist on NPM. If they do not exist, the `publish` command will be run to publish them.
|
|
91
|
+
|
|
92
|
+
:::warning
|
|
93
|
+
When the dependencies between packages in the Monorepo are declared using workspace, do not directly run `npm publish` to publish the package in the corresponding subdirectory of the package. Use the `release` command instead. When publishing, the workspace declaration will be automatically removed to ensure that the NPM package is available after publishing.
|
|
94
|
+
:::
|
|
95
|
+
|
|
96
|
+
#### Push the tag to the remote repository
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git push --follow-tags
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Parameters
|
|
103
|
+
|
|
104
|
+
### Parameters for the `bump` command
|
|
105
|
+
|
|
106
|
+
- `--snapshot`: Generates a timestamp-based version.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm run bump --snapshot canary
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
After running, the corresponding upgraded version will become `0.0.0-canary-20220622092823`, and `canary` is the tag configured for snapshot. If not configured, it will directly generate the form of `0.0.0-20220622092823`.
|
|
113
|
+
|
|
114
|
+
This parameter is mainly used to publish temporary test versions for testing and does not require code submission.
|
|
115
|
+
|
|
116
|
+
- `--ignore`: Manually ignore some packages during publishing.
|
|
117
|
+
|
|
118
|
+
For example, if you need to ignore the `module-2` package for this release:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pnpm run bump --ignore module-2
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
After running the command, the update of the `module-2` package will be ignored. Note that if there are packages that depend on `module-2`, the corresponding packages also need to be added to the `ignore` parameter, otherwise the `bump` command will fail.
|
|
125
|
+
|
|
126
|
+
The usage for adding multiple packages is as follows:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pnpm run bump --ignore module-2 --ignore module-3
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Parameters for the `release` command
|
|
133
|
+
|
|
134
|
+
- `--otp`: Uses `npm token` to publish the package.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pnpm run relese --otp <token>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- `--tag`: Uses a specific tag for publishing, and `latest` is used by default.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pnpm run release --tag <tag>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `--ignore-scripts`: Ignores npm scripts during publishing.
|
|
147
|
+
|
|
148
|
+
When running the `publish` command, npm will automatically trigger many commands, such as `prepare` and `prepublish`. Using this parameter can ignore the running of these commands. This parameter is only supported in Monorepo using pnpm.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pnpm run release --ignore-scripts
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- `--no-git-checks`: Ignores checking the current branch during publishing.
|
|
155
|
+
|
|
156
|
+
By default, when running the `release` command, it will automatically check whether the current branch is a release branch, whether there are uncommitted changes, etc. Using this parameter can ignore git-related checks.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm run release --no-git-checks
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Version Upgrade Strategy
|
|
163
|
+
|
|
164
|
+
### dependencies or devDependencies
|
|
165
|
+
|
|
166
|
+
- Only upgrade the patch version of the package itself for patch version
|
|
167
|
+
|
|
168
|
+
For example, the following scenario exists:
|
|
169
|
+
|
|
170
|
+
There are two packages in Monorepo, `module-1` and `module-2`, and `module-1` exists in the `dependencies` of `module-2`.
|
|
171
|
+
|
|
172
|
+
The current changeset is the patch version upgrade of `module-1`.
|
|
173
|
+
|
|
174
|
+
After running the `bump` command, only the patch version of `module-1` will be upgraded.
|
|
175
|
+
|
|
176
|
+
- Upgrade the major or minor version of the package itself for major/minor version upgrades, and upgrade the patch version of the dependent packages
|
|
177
|
+
|
|
178
|
+
For example, the following scenario exists:
|
|
179
|
+
|
|
180
|
+
There are two packages in Monorepo, `module-1` and `module-2`, and `module-1` exists in the `dependencies` of `module-2`.
|
|
181
|
+
|
|
182
|
+
The current changeset is the minor version upgrade of `module-1`.
|
|
183
|
+
|
|
184
|
+
After running the `bump` command, `module-1` will upgrade the `minor` version, and `module-2` will upgrade the `patch` version number.
|
|
185
|
+
|
|
186
|
+
### peerDependencies
|
|
187
|
+
|
|
188
|
+
- Upgrade the patch version of the package itself and the dependent package for patch version dependencies
|
|
189
|
+
|
|
190
|
+
For example, the following scenario exists:
|
|
191
|
+
|
|
192
|
+
There are two packages in Monorepo, `module-1` and `module-2`, and `module-1` exists in the `peerDependencies` of `module-2`.
|
|
193
|
+
|
|
194
|
+
The current changeset is the patch version upgrade of `module-1`.
|
|
195
|
+
|
|
196
|
+
After running the `bump` command, both `module-1` and `module-2` will upgrade the patch version.
|
|
197
|
+
|
|
198
|
+
- Upgrade the major version of the dependent package for major/minor version upgrades of the package itself
|
|
199
|
+
|
|
200
|
+
For example, the following scenario exists:
|
|
201
|
+
|
|
202
|
+
There are two packages in Monorepo, `module-1` and `module-2`, and `module-1` exists in the `peerDependencies` of `module-2`.
|
|
203
|
+
|
|
204
|
+
The current changeset is the minor version upgrade of `module-1`.
|
|
205
|
+
|
|
206
|
+
After running the bump command, `module-1` will upgrade the `minor` version, and `module-2` will upgrade the `major` version number.
|
|
207
|
+
|
|
208
|
+
- Modify the upgrade strategy for peerDependencies
|
|
209
|
+
|
|
210
|
+
The upgrade strategy of `peerDependencies` can be modified by configuring `onlyUpdatePeerDependentsWhenOutOfRange`. When only the declared version type range is exceeded, the corresponding `peerDependencies` will be upgraded.
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
|
|
215
|
+
"onlyUpdatePeerDependentsWhenOutOfRange": true
|
|
216
|
+
},
|
|
217
|
+
...
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
For example, the following scenario exists:
|
|
222
|
+
|
|
223
|
+
There are two packages in Monorepo, `module-1` and `module-2`, and `module-1` exists in the `peerDependencies` of `module-2`, and the version of `module-1` is declared using `^`.
|
|
224
|
+
|
|
225
|
+
The current changeset is the patch or minor version upgrade of `module-1`.
|
|
226
|
+
|
|
227
|
+
After running the `bump` command, only the version of `module-1` will be upgraded.
|
|
228
|
+
|
|
229
|
+
Note that if the package version is in the `0.x.x` range, upgrading the `minor` version is also beyond the declared version type range.
|
|
@@ -71,7 +71,7 @@ sidebar_position: 97
|
|
|
71
71
|
|
|
72
72
|
<div style={{ textAlign: 'center', fontStyle: 'italic' }}>Rspack Logo</div>
|
|
73
73
|
|
|
74
|
-
相较于
|
|
74
|
+
相较于 webpack,Rspack 的构建性能有明显提升,除了 Rust 带来的语言优势,这也来自于它的并行架构和增量编译等特性。经过 benchmark 验证,**Rspack 可以给 Modern.js 项目带来 5 ~ 10 倍编译性能的提升。**
|
|
75
75
|
|
|
76
76
|

|
|
77
77
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
`@modern-js/create` 会提供一个可交互的问答界面,根据结果初始化项目,按照默认的选择进行初始化:
|
|
2
2
|
|
|
3
3
|
```bash
|
|
4
|
-
?
|
|
5
|
-
?
|
|
6
|
-
?
|
|
4
|
+
? 请选择你想创建的工程类型 Web 应用
|
|
5
|
+
? 请选择开发语言 TS
|
|
6
|
+
? 请选择包管理工具 pnpm
|
|
7
|
+
? 请选择构建工具 webpack
|
|
7
8
|
```
|
|
8
9
|
|
|
9
10
|
在生成项目后,Modern.js 会自动安装依赖、创建 git 仓库。
|
|
@@ -20,11 +21,6 @@ pnpm run lint # 运行 ESLint 并自动修复问题
|
|
|
20
21
|
pnpm run new # 启用可选功能或创建项目要素
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
:::note
|
|
24
|
-
Modern.js 生成器除了在项目初始化时工作外,也能在后续研发中生成项目各种粒度的模块,并非一用即抛开。
|
|
25
|
-
|
|
26
|
-
:::
|
|
27
|
-
|
|
28
24
|
现在,项目结构如下:
|
|
29
25
|
|
|
30
26
|
```
|
|
@@ -19,23 +19,9 @@ import SWC from '@modern-js/builder-doc/docs/zh/shared/swc.md';
|
|
|
19
19
|
|
|
20
20
|
## 安装
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
import EnableSWC from '@modern-js/builder-doc/docs/zh/shared/enable-swc.md';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
? 请选择你想要的操作 启用可选功能
|
|
26
|
-
? 请选择功能名称 启用「SWC 编译」
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
执行完成后,你只需在 `modern.config.ts` 文件中注册 SWC 插件,即可启用 SWC 编译和压缩能力。
|
|
30
|
-
|
|
31
|
-
```ts title="modern.config.ts"
|
|
32
|
-
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
33
|
-
import swcPlugin from '@modern-js/plugin-swc';
|
|
34
|
-
|
|
35
|
-
export default defineConfig({
|
|
36
|
-
plugins: [appTools(), swcPlugin()],
|
|
37
|
-
});
|
|
38
|
-
```
|
|
24
|
+
<EnableSWC />
|
|
39
25
|
|
|
40
26
|
## 配置项
|
|
41
27
|
|
|
@@ -12,9 +12,9 @@ import Prerequisites from "@site-docs/components/prerequisites"
|
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
15
|
-
Modern.js 提供了 `@modern-js/create`
|
|
15
|
+
Modern.js 提供了 `@modern-js/create` 工具来创建项目,不要全局安装,使用 `npx` 按需运行。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
可以在已有的空目录来创建项目:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
mkdir myapp && cd myapp
|
|
@@ -41,9 +41,9 @@ import DebugApp from "@site-docs/components/debug-app"
|
|
|
41
41
|
|
|
42
42
|
## 使用配置
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
通过 `@modern-js/create` 创建的 Modern.js 项目中,会默认生成 `modern.config.ts` 文件。
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
可以通过该配置文件修改配置,覆盖 Modern.js 的默认行为。例如添加如下配置,开启 SSR:
|
|
47
47
|
|
|
48
48
|
```ts title="modern.config.ts"
|
|
49
49
|
import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
@@ -51,7 +51,6 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
|
|
|
51
51
|
export default defineConfig({
|
|
52
52
|
runtime: {
|
|
53
53
|
router: true,
|
|
54
|
-
state: true,
|
|
55
54
|
},
|
|
56
55
|
server: {
|
|
57
56
|
ssr: true,
|
|
@@ -93,14 +92,12 @@ info File sizes after production build:
|
|
|
93
92
|
构建产物默认生成到 `dist/`,目录结构如下:
|
|
94
93
|
|
|
95
94
|
```
|
|
96
|
-
|
|
97
|
-
├── asset-manifest.json
|
|
95
|
+
dist
|
|
98
96
|
├── html
|
|
99
|
-
│
|
|
100
|
-
├── loader-routes
|
|
101
|
-
│ └── main
|
|
97
|
+
│ └── main
|
|
102
98
|
├── modern.config.json
|
|
103
99
|
├── route.json
|
|
100
|
+
├── routes-manifest.json
|
|
104
101
|
└── static
|
|
105
102
|
├── css
|
|
106
103
|
└── js
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
sidebar_position: 2
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# 添加 Changesets
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
当我们开发完成时,需要添加一个 changeset 声明当前变更,用于后续版本发布。
|
|
8
8
|
|
|
9
9
|
## 信息
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ sidebar_position: 2
|
|
|
14
14
|
|
|
15
15
|
- 本次变更需要升级的版本号类型,类型符合 [semver](https://semver.org/) 规范。
|
|
16
16
|
|
|
17
|
-
- 本次变更的
|
|
17
|
+
- 本次变更的 changelog 信息。
|
|
18
18
|
|
|
19
19
|
## 步骤
|
|
20
20
|
|
|
@@ -25,17 +25,17 @@ sidebar_position: 2
|
|
|
25
25
|
|
|
26
26
|
### 模块工程方案
|
|
27
27
|
|
|
28
|
-
####
|
|
28
|
+
#### 在根目录执行 change 命令
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
pnpm run change
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
####
|
|
34
|
+
#### 选择本次变更需要升级的版本号类型
|
|
35
35
|
|
|
36
36
|

|
|
37
37
|
|
|
38
|
-
#### 填入
|
|
38
|
+
#### 填入 changelog 信息,并点击两次回车:
|
|
39
39
|
|
|
40
40
|

|
|
41
41
|
|
|
@@ -55,13 +55,13 @@ feat: test module solution changeset
|
|
|
55
55
|
|
|
56
56
|
我们假设 monorepo 中存在三个模块包,分别为 `module-1`,`module-2`,`module-3`。
|
|
57
57
|
|
|
58
|
-
####
|
|
58
|
+
#### 在根目录执行 change 命令
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
61
|
pnpm run change
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
####
|
|
64
|
+
#### 选择本次需要升级的包列表
|
|
65
65
|
|
|
66
66
|
Changesets 会根据当前代码变更(`git diff Head...baseBranch`),将 Monorepo 中的 package 分为两类,`changed packages` 和 `unchanged packages`,方便用户进行选择。
|
|
67
67
|
|
|
@@ -69,11 +69,13 @@ Changesets 会根据当前代码变更(`git diff Head...baseBranch`),将 Monor
|
|
|
69
69
|
|
|
70
70
|

|
|
71
71
|
|
|
72
|
-
####
|
|
72
|
+
#### 分别选择不同版本类型对应的包
|
|
73
|
+
|
|
74
|
+
changeset 会询问 `major` 和 `minor` 类型,如果存在包未选择这两种类型,将会默认使用 `patch` 类型。
|
|
73
75
|
|
|
74
76
|

|
|
75
77
|
|
|
76
|
-
#### 填入
|
|
78
|
+
#### 填入 changelog 信息
|
|
77
79
|
|
|
78
80
|

|
|
79
81
|
|
|
@@ -94,10 +96,10 @@ feat: test-changeset
|
|
|
94
96
|
|
|
95
97
|
change 命令支持以下参数:
|
|
96
98
|
|
|
97
|
-
- `--empty
|
|
99
|
+
- `--empty`: 添加一个空的 changeset。
|
|
98
100
|
|
|
99
101
|
```bash
|
|
100
|
-
pnpm run change --
|
|
102
|
+
pnpm run change --empty
|
|
101
103
|
```
|
|
102
104
|
|
|
103
105
|
执行完成后,将在项目的 `.changeset` 目录创建空的 changeset 文件,文件内容如下:
|
|
@@ -107,7 +109,7 @@ pnpm run change -- --empty
|
|
|
107
109
|
---
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
- `--open
|
|
112
|
+
- `--open`: 使用该参数时,在填写 changelog 步骤会打开系统默认编辑器进行填写。
|
|
111
113
|
|
|
112
114
|
## 注意事项
|
|
113
115
|
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
sidebar_position: 6
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# 自定义
|
|
5
|
+
# 自定义 changelog 生成
|
|
6
6
|
|
|
7
|
-
Changesets 默认会使用 `@changesets/cli/changelog` 生成 Changelog 信息,如果默认的
|
|
7
|
+
Changesets 默认会使用 `@changesets/cli/changelog` 生成 Changelog 信息,如果默认的 changelog 信息不能满足需求,可以自定义 changelog 的生成。
|
|
8
8
|
|
|
9
|
-
## 自定义
|
|
9
|
+
## 自定义 changelog 内容
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
changelog 信息主要包含以下两种信息:
|
|
12
12
|
|
|
13
|
-
- changeset 中写入的
|
|
13
|
+
- changeset 中写入的 changelog 信息。
|
|
14
14
|
|
|
15
15
|
- 本次版本升级关联包的版本变更信息。
|
|
16
16
|
|
|
@@ -41,7 +41,7 @@ export type Changeset = {
|
|
|
41
41
|
|
|
42
42
|
#### 返回值
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
changelog 内容。
|
|
45
45
|
|
|
46
46
|
#### 默认实现
|
|
47
47
|
|
|
@@ -91,7 +91,7 @@ type DependenciesUpdated = ModCompWithPackage[];
|
|
|
91
91
|
|
|
92
92
|
#### 返回值
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
changelog 内容。
|
|
95
95
|
|
|
96
96
|
#### 默认实现
|
|
97
97
|
|
|
@@ -128,11 +128,11 @@ async function getDependencyReleaseLine(changesets, dependenciesUpdated) {
|
|
|
128
128
|
|
|
129
129
|
## 配置
|
|
130
130
|
|
|
131
|
-
Changesets 配置文件中 `changelog`
|
|
131
|
+
Changesets 配置文件中 `changelog` 字段用于标记 changelog 信息的获取途径。
|
|
132
132
|
|
|
133
|
-
该配置可以为字符串,直接声明获取
|
|
133
|
+
该配置可以为字符串,直接声明获取 changelog 信息模块的模块名称或者路径。
|
|
134
134
|
|
|
135
|
-
该配置还支持配置数组,数组中第一个元素为获取
|
|
135
|
+
该配置还支持配置数组,数组中第一个元素为获取 changelog 信息模块的模块名称或者路径,第二个元素为传入对应函数的参数值,会作为 `getReleaseLine` 和 `getDependencyReleaseLine` 函数的第三个参数传入。
|
|
136
136
|
|
|
137
137
|
### 配置相对路径
|
|
138
138
|
|
|
@@ -162,9 +162,9 @@ module.exports = {
|
|
|
162
162
|
|
|
163
163
|
### 使用模块工程方案
|
|
164
164
|
|
|
165
|
-
自定义
|
|
165
|
+
自定义 changelog 还可以使用模块工程方案进行管理,提供通用方案。
|
|
166
166
|
|
|
167
|
-
#### 使用 `npx @modern-js/create@latest`
|
|
167
|
+
#### 使用 `npx @modern-js/create@latest` 创建模块工程方案
|
|
168
168
|
|
|
169
169
|
```md
|
|
170
170
|
? 请选择你想创建的工程类型:Npm 模块
|
|
@@ -173,7 +173,7 @@ module.exports = {
|
|
|
173
173
|
? 请选择包管理工具:pnpm
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
####
|
|
176
|
+
#### 实现自定义内容
|
|
177
177
|
|
|
178
178
|
```ts title="src/index.ts"
|
|
179
179
|
export async function getReleaseLine() {}
|
|
@@ -181,11 +181,11 @@ export async function getReleaseLine() {}
|
|
|
181
181
|
export async function getDependencyReleaseLine() {}
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
#### 将模块发布到 NPM
|
|
184
|
+
#### 将模块发布到 NPM
|
|
185
185
|
|
|
186
|
-
#### 在目标仓库根目录安装对应模块,例如 `custom-changelog
|
|
186
|
+
#### 在目标仓库根目录安装对应模块,例如 `custom-changelog`
|
|
187
187
|
|
|
188
|
-
#### 配置 changeset 的 changelog
|
|
188
|
+
#### 配置 changeset 的 changelog 配置为包名称
|
|
189
189
|
|
|
190
190
|
```json title=".changesets/config.json"
|
|
191
191
|
{
|
|
@@ -198,7 +198,7 @@ export async function getDependencyReleaseLine() {}
|
|
|
198
198
|
|
|
199
199
|
如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
|
|
200
200
|
|
|
201
|
-
#### 执行 `pnpm run new`
|
|
201
|
+
#### 执行 `pnpm run new` 创建模块子项目
|
|
202
202
|
|
|
203
203
|
```md
|
|
204
204
|
? 请选择你想创建的工程类型:Npm 模块
|
|
@@ -207,7 +207,7 @@ export async function getDependencyReleaseLine() {}
|
|
|
207
207
|
? 请选择开发语言:TS
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
####
|
|
210
|
+
#### 实现自定义内容
|
|
211
211
|
|
|
212
212
|
```ts title="src/index.ts"
|
|
213
213
|
export async function getReleaseLine() {}
|
|
@@ -215,7 +215,7 @@ export async function getReleaseLine() {}
|
|
|
215
215
|
export async function getDependencyReleaseLine() {}
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
#### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-changelog
|
|
218
|
+
#### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-changelog`
|
|
219
219
|
|
|
220
220
|
```json title="package.json"
|
|
221
221
|
{
|
|
@@ -226,7 +226,7 @@ export async function getDependencyReleaseLine() {}
|
|
|
226
226
|
}
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
#### 配置 changeset 的 changelog
|
|
229
|
+
#### 配置 changeset 的 changelog 配置为包名称
|
|
230
230
|
|
|
231
231
|
```json title=".changesets/config.json"
|
|
232
232
|
{
|
|
@@ -118,7 +118,7 @@ type ReleasePlan = {
|
|
|
118
118
|
|
|
119
119
|
- options
|
|
120
120
|
|
|
121
|
-
配置 commit
|
|
121
|
+
配置 commit 时的其他参数。
|
|
122
122
|
|
|
123
123
|
> commit 配置为数组时,第二个参数支持传入默认的配置信息,会对应的使用该参数传递。
|
|
124
124
|
|
|
@@ -169,7 +169,7 @@ Changesets 配置文件中 `commit` 字段,该字段用于标记是否需要
|
|
|
169
169
|
|
|
170
170
|
commit 配置如果为相对路径为 `.changesets` 目录下的相对路径。
|
|
171
171
|
|
|
172
|
-
例如创建
|
|
172
|
+
例如创建 `.changeset/my-commit-config.js` 文件,定义如下内容:
|
|
173
173
|
|
|
174
174
|
```js title=".changeset/my-commit-config.js"
|
|
175
175
|
async function getAddMessage(changeset, options) {}
|
|
@@ -195,9 +195,7 @@ commit 配置为 ./my-commit-config.js 即可:
|
|
|
195
195
|
|
|
196
196
|
自定义 commit 还可以使用模块工程方案进行管理,提供通用方案。
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
#### 使用 `npx @modern-js/create@latest` 创建模块工程方案。
|
|
198
|
+
#### 使用 `npx @modern-js/create@latest` 创建模块工程方案
|
|
201
199
|
|
|
202
200
|
```md
|
|
203
201
|
? 请选择你想创建的工程类型:Npm 模块
|
|
@@ -206,7 +204,7 @@ commit 配置为 ./my-commit-config.js 即可:
|
|
|
206
204
|
? 请选择包管理工具:pnpm
|
|
207
205
|
```
|
|
208
206
|
|
|
209
|
-
####
|
|
207
|
+
#### 实现自定义内容
|
|
210
208
|
|
|
211
209
|
```ts title="src/index.ts"
|
|
212
210
|
export async function getAddMessage() {}
|
|
@@ -214,15 +212,15 @@ export async function getAddMessage() {}
|
|
|
214
212
|
export async function getVersionMessage() {}
|
|
215
213
|
```
|
|
216
214
|
|
|
217
|
-
#### 将模块发布到 NPM
|
|
215
|
+
#### 将模块发布到 NPM
|
|
218
216
|
|
|
219
|
-
#### 在目标仓库根目录安装对应模块,例如 custom-commit
|
|
217
|
+
#### 在目标仓库根目录安装对应模块,例如 `custom-commit`
|
|
220
218
|
|
|
221
|
-
#### 配置 changeset 的 commit
|
|
219
|
+
#### 配置 changeset 的 commit 配置为包名称
|
|
222
220
|
|
|
223
221
|
```json title="package.json"
|
|
224
222
|
{
|
|
225
|
-
"
|
|
223
|
+
"commit": "custom-commit",
|
|
226
224
|
...
|
|
227
225
|
}
|
|
228
226
|
```
|
|
@@ -231,7 +229,7 @@ export async function getVersionMessage() {}
|
|
|
231
229
|
|
|
232
230
|
如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
|
|
233
231
|
|
|
234
|
-
#### 执行 `pnpm run new`
|
|
232
|
+
#### 执行 `pnpm run new` 创建模块子项目
|
|
235
233
|
|
|
236
234
|
```md
|
|
237
235
|
? 请选择你想创建的工程类型:Npm 模块
|
|
@@ -240,7 +238,7 @@ export async function getVersionMessage() {}
|
|
|
240
238
|
? 请选择开发语言:TS
|
|
241
239
|
```
|
|
242
240
|
|
|
243
|
-
####
|
|
241
|
+
#### 实现自定义内容
|
|
244
242
|
|
|
245
243
|
```ts title="src/index.ts"
|
|
246
244
|
export async function getAddMessage() {}
|
|
@@ -248,7 +246,7 @@ export async function getAddMessage() {}
|
|
|
248
246
|
export async function getVersionMessage() {}
|
|
249
247
|
```
|
|
250
248
|
|
|
251
|
-
#### 在 Monorepo 根目录添加子项目模块依赖,例如 custom-commit
|
|
249
|
+
#### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-commit`
|
|
252
250
|
|
|
253
251
|
```json title="package.json"
|
|
254
252
|
{
|
|
@@ -259,7 +257,7 @@ export async function getVersionMessage() {}
|
|
|
259
257
|
}
|
|
260
258
|
```
|
|
261
259
|
|
|
262
|
-
#### 配置 changeset 的 commit
|
|
260
|
+
#### 配置 changeset 的 commit 配置为包名称
|
|
263
261
|
|
|
264
262
|
```json title=".changesets/config.json"
|
|
265
263
|
{
|