jiek 2.1.4 → 2.1.6

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/README.md CHANGED
@@ -1,36 +1,46 @@
1
1
  # Jiek
2
2
 
3
- | zh-Hans
4
- | [en](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/en/README.md)
3
+ | English
4
+ | [简体中文](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/zh-Hans/README.md)
5
+ | [繁体中文](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/zh-Hant/README.md)
6
+ | [日本語](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/ja/README.md)
7
+ | [Français](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/fr/README.md)
5
8
 
6
9
  [![npm version](https://img.shields.io/npm/v/jiek)](https://npmjs.com/package/jiek)
7
10
  [![npm downloads](https://img.shields.io/npm/dm/jiek)](https://npm.chart.dev/jiek)
8
11
 
9
- > 基于 `package.json` 元数据并适用于 `Monorepo` 的**轻便**工具库编译管理套件。
12
+ > A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.
10
13
 
11
- - [x] 自动推断:基于 `package.json` 的相关字段自动推断出构建规则,减少配置文件的编写,更加轻便与符合标准
12
- - `exports`:根据入口文件推断构建目标与类型
13
- - `imports`:定义路径别名,并在构建的时候自动 bundle 进来
14
- - `type: module`:根据选项智能决定输出文件后缀,不需要考虑 `cjs` `esm` 的适配问题
15
- - `dependencies`、`peerDependencies`、`optionalDependencies`:自动将符合规则的依赖标记为 `external`
16
- - `devDependencies`:将标记为开发依赖的 bundle 进对应的最终产物之中
17
- - [ ] 构建工具:支持多种构建工具,无需纠结于用 swc 还是 esbuild 又或者是 tsc
14
+ - [x] Automatic inference: Automatically infer build rules based on relevant fields in `package.json`, reducing the need for configuration files, making it more lightweight and standard-compliant
15
+ - `exports`: Infer build targets and types based on entry files
16
+ - `imports`: Define path aliases and automatically bundle them during the build
17
+ - `type: module`: Intelligently decide the output file suffix based on options, eliminating the need to consider `cjs` and `esm` compatibility issues
18
+ - `dependencies`, `peerDependencies`, `optionalDependencies`: Automatically mark dependencies that meet the rules as `external`
19
+ - `devDependencies`: Bundle dependencies marked as development dependencies into the corresponding final product
20
+ - [ ] Build tools: Support multiple build tools, no need to struggle with using swc, esbuild, or tsc
18
21
  - [x] `esbuild`
19
22
  - [x] `swc`
20
23
  - [ ] `typescript`
21
- - [x] 工作空间友好:支持在 pnpm 下的工作空间开发范式
22
- - [ ] 支持更多的 PM
23
- - [ ] 更好的工作空间任务流
24
- - [x] 类型定义文件:支持聚合生成类型定义文件
25
- - [x] 监听模式:适配 rollup 的监听模式
26
- - [x] 发布适配:支持同构生成 `package.json` 等相关字段
27
- - [ ] 根据 `package.json` 中的路径自动替换 README.md 中的相对路径链接为对应的网络链接
28
- - [x] CommonJS:产物兼容正在使用 cjs 的用户
29
- - [ ] 插件化
30
- - [ ] Dotenv:支持 dotenv 配置文件
31
- - [ ] Replacer:支持替换文件内容
32
-
33
- ## 安装
24
+ - [x] Workspace-friendly: Support development paradigms in pnpm workspaces
25
+ - [ ] Support more PMs
26
+ - [ ] Better workspace task flow
27
+ - [x] Type definition files: Support aggregated generation of type definition files
28
+ - [x] Watch mode: Adapt to rollup's watch mode
29
+ - [x] Publish adaptation: Support isomorphic generation of `package.json` and other related fields
30
+ - [ ] Automatically replace relative path links in README.md with corresponding network links based on paths in `package.json`
31
+ - [ ] Automatically generate common fields such as `license`, `author`, `homepage`, `repository`, etc. based on the repository and project
32
+ - [x] CommonJS: Compatible with users who are still using cjs
33
+ - [ ] Plugin system
34
+ - [ ] Dotenv: Support dotenv configuration files
35
+ - [ ] Replacer: Support replacing file content
36
+ - [ ] Hooks: prepublish, postpublish
37
+ - [ ] Automatically generate changelog
38
+ - [ ] Automatically decide the next version number
39
+ - [ ] `feat: xxx` -> `patch`
40
+ - [ ] `feat!: xxx` -> `minor`
41
+ - [ ] `feat!!: xxx` -> `major`
42
+
43
+ ## Installation
34
44
 
35
45
  ```bash
36
46
  npm i -D jiek
@@ -40,13 +50,13 @@ pnpm i -D jiek
40
50
  yarn add -D jiek
41
51
  ```
42
52
 
43
- ## 快速起步
53
+ ## Quick Start
44
54
 
45
- 通过一些简单的方式能又快又轻松的生成需要的产物。
55
+ Generate the required products quickly and easily through some simple methods.
46
56
 
47
- - `package.json` 中添加入口文件,这里需要设置为原文件路径。
57
+ - Add entry files in `package.json`, here you need to set the original file path.
48
58
 
49
- 你可以在 Node.js 文档中查看更多对于 [exports](https://nodejs.org/api/packages.html#exports) 的相关内容。
59
+ You can see more about [exports](https://nodejs.org/api/packages.html#exports) in the Node.js documentation.
50
60
 
51
61
  ```json
52
62
  {
@@ -56,11 +66,11 @@ yarn add -D jiek
56
66
  }
57
67
  ```
58
68
 
59
- - 假设你在工作空间下有一个包名字为 `@monorepo/utils` ,那么你可以运行 `jk -f utils build` 来构建这个包。
69
+ - Suppose you have a package named `@monorepo/utils` in the workspace, then you can run `jk -f utils build` to build this package.
60
70
 
61
- - 当需要发布当前的包的时候,首先你可以通过 `jk -f utils prepublish` 来准备发布内容,然后再运行 `jk -f utils publish` 来发布,最后通过 `jk -f utils postpublish` 来清理发布内容。
71
+ - When you need to publish the current package, you can first run `jk -f utils prepublish` to prepare the publishing content, then run `jk -f utils publish` to publish, and finally run `jk -f utils postpublish` to clean up the publishing content.
62
72
 
63
- - 当然可能你会觉得上面的操作有点繁琐,你可以通过在对应包的 `package.json` 中添加 `scripts` 来简化操作。
73
+ - Of course, you may find the above operations a bit cumbersome, you can simplify the operations by adding `scripts` in the corresponding package's `package.json`.
64
74
 
65
75
  ```json
66
76
  {
@@ -73,9 +83,9 @@ yarn add -D jiek
73
83
  }
74
84
  ```
75
85
 
76
- > 如果你需要在发布前对要发布的内容进行检查,你可以通过 `prepublish` 子指令来在你的 dist 产物目录(可配置)下会生成相关的 `package.json` 文件,你可以检阅相关生成的文件。
86
+ > If you need to check the content to be published before publishing, you can use the `prepublish` subcommand to generate the relevant `package.json` file in your dist product directory (configurable), and you can review the generated files.
77
87
 
78
- - 当配置好了上述的 hook 后,通过 `jk publish` 就可以一键完成构建发布动作了。
88
+ - After configuring the above hooks, you can complete the build and publish actions with one command `jk publish`.
79
89
 
80
90
  ## CLI
81
91
 
@@ -84,9 +94,9 @@ jk/jiek [options] [command]
84
94
  jb/jiek-build [options] [filters/entries]
85
95
  ```
86
96
 
87
- ### 自定义构建入口
97
+ ### Custom Build Entry
88
98
 
89
- 你可以通过 `--entries` 来指定构建入口,这里的入口定义是基于 `package.json` 中的 `exports` 字段来进行的。
99
+ You can specify the build entry through `--entries`, the entry definition here is based on the `exports` field in `package.json`.
90
100
 
91
101
  ```bash
92
102
  jb -e .
@@ -95,7 +105,7 @@ jb --entries ./foo
95
105
  jb --entries ./foo,./bar
96
106
  ```
97
107
 
98
- 当你的项目是一个非 `monorepo` 项目时,你可以直接通过 `jb [entries]` 来进行构建。
108
+ When your project is a non-`monorepo` project, you can directly build through `jb [entries]`.
99
109
 
100
110
  ```bash
101
111
  jb .
@@ -103,9 +113,9 @@ jb ./foo
103
113
  jb ./foo,./bar
104
114
  ```
105
115
 
106
- ### 过滤器
116
+ ### Filters
107
117
 
108
- 你可以通过 `--filter` 来过滤需要构建的包,我们使用了和 pnpm 一样的过滤器规则,所以你可以在这里查阅 [pnpm 的过滤器规则](https://pnpm.io/filtering)
118
+ You can filter the packages to be built through `--filter`, we use the same filter rules as pnpm, so you can check the [pnpm filter rules](https://pnpm.io/filtering) here.
109
119
 
110
120
  ```bash
111
121
  jb --filter @monorepo/*
@@ -113,7 +123,7 @@ jb --filter @monorepo/utils
113
123
  jb -f utils
114
124
  ```
115
125
 
116
- 当你的项目是一个 `monorepo` 项目时,你可以直接通过 `jb [filters]` 来进行构建。
126
+ When your project is a `monorepo` project, you can directly build through `jb [filters]`.
117
127
 
118
128
  ```bash
119
129
  jb @monorepo/*
@@ -121,94 +131,128 @@ jb @monorepo/utils
121
131
  jb utils
122
132
  ```
123
133
 
124
- ### 自定义构建工具
134
+ ### Custom Build Tools
125
135
 
126
- 我们支持多种构建工具,你可以通过 `--type <type: esbuild | swc>` 来指定构建工具。
136
+ We support multiple build tools, you can specify the build tool through `--type <type: esbuild | swc>`.
127
137
 
128
- - 默认会使用 `esbuild`(`rollup-plugin-esbuild`)
129
- - 如果你的依赖空间中存在 `swc`(`rollup-plugin-swc3`) 依赖,那么我们会自动切换到 `swc`
130
- - 如果俩个都存在,默认会使用 `esbuild`
138
+ - By default, `esbuild` (`rollup-plugin-esbuild`) will be used
139
+ - If the `swc` (`rollup-plugin-swc3`) dependency exists in your dependency space, we will automatically switch to `swc`
140
+ - If both exist, `esbuild` will be used by default
131
141
 
132
142
  ```bash
133
143
  jb --type swc
134
144
  ```
135
145
 
136
- > 如果使用类型的构建工具依赖没有安装,那我们会提示你安装对应的依赖。
146
+ > If the build tool dependency is not installed, we will prompt you to install the corresponding dependency.
137
147
 
138
- ### 最小化
148
+ ### Minification
139
149
 
140
- 我们提供了多种方式来支持最小化的构建,默认会自动启用,同时我们默认会选择使用构建工具内置的最小化插件来进行最小化。
150
+ We provide multiple ways to support minified builds, which are enabled by default, and we will use the build tool's built-in minification plugin for minification by default.
141
151
 
142
- - 你可以通过 `--minType` 选择使用 `terser`(`rollup-plugin-terser`) 来进行最小化,如果你没有安装 `terser`,我们会提示你安装。
143
- - 你可以通过 `--noMin` 来关闭生成最小化产物。
144
- - 你可以通过 `--onlyMinify` 来只生成最小化产物,这样我们会直接替换原产物路径,而不是添加一个 `.min` 后缀再进行输出。
152
+ - You can choose to use `terser` (`rollup-plugin-terser`) for minification through `--minType`, if you have not installed `terser`, we will prompt you to install it.
153
+ - You can disable the generation of minified products through `--noMin`.
154
+ - You can generate only minified products through `--onlyMinify`, in this case, we will directly replace the original product path instead of adding a `.min` suffix before outputting.
145
155
 
146
156
  ```bash
147
157
  jb --minType terser
148
158
  jb --onlyMinify
149
159
  ```
150
160
 
151
- ### 去除指定构建内容
161
+ ### Exclude Specific Build Content
152
162
 
153
- 你可以通过 `--noJs` 来关闭 `js` 的构建,通过 `--noDts` 来关闭 `dts` 的构建。
163
+ You can disable the build of `js` through `--noJs`, and disable the build of `dts` through `--noDts`.
154
164
 
155
165
  ```bash
156
166
  jb --noJs
157
167
  jb --noDts
158
168
  ```
159
169
 
160
- ### 自定义产物目录
170
+ ### Custom Output Directory
161
171
 
162
- 你可以通过 `--outdir` 来指定产物目录。
172
+ You can specify the output directory through `--outdir`.
163
173
 
164
174
  ```bash
165
175
  jb --outdir lib
166
176
  ```
167
177
 
168
- ### 监听模式
178
+ ### Watch Mode
169
179
 
170
- 你可以通过 `--watch` 来开启监听模式。
180
+ You can enable watch mode through `--watch`.
171
181
 
172
182
  ```bash
173
183
  jb --watch
174
184
  ```
175
185
 
176
- ### 外部模块
186
+ ### External Modules
177
187
 
178
- 除了通过 `package.json` 中的 `dependencies`、`peerDependencies`、`optionalDependencies` 来自动标记外部模块外,你还可以通过 `--external` 来手动标记外部模块。
188
+ In addition to automatically marking external modules through `dependencies`, `peerDependencies`, `optionalDependencies` in `package.json`, you can also manually mark external modules through `--external`.
179
189
 
180
190
  ```bash
181
191
  jb --external react
182
192
  jb --external react,react-dom
183
193
  ```
184
194
 
185
- ### 关闭产物的自动清理
195
+ ### Disable Automatic Cleanup of Products
186
196
 
187
- 你可以通过 `--noClean` 来关闭产物的自动清理。
197
+ You can disable the automatic cleanup of products through `--noClean`.
188
198
 
189
199
  ```bash
190
200
  jb --noClean
191
201
  ```
192
202
 
193
- ### 自定义 tsconfig 路径
203
+ ### Custom tsconfig Path
194
204
 
195
- 你可以通过 `--tsconfig` 来指定 `tsconfig` 的路径。
205
+ You can specify the path of `tsconfig` through `--tsconfig`.
196
206
 
197
207
  ```bash
198
208
  jb --tsconfig ./tsconfig.custom-build.json
199
209
  ```
200
210
 
201
- 同时你还可以通过 `--dtsconfig` 来指定 `dts` 插件使用的 `tsconfig` 的路径(当然我不建议你这么做)。
211
+ You can also specify the path of `dtsconfig` used by the `dts` plugin through `--dtsconfig` (although I don't recommend doing this).
202
212
 
203
213
  ```bash
204
214
  jb --dtsconfig ./tsconfig.custom-dts.json
205
215
  ```
206
216
 
207
- ## 为什么不使用 X?
217
+ ### Publish Command
218
+
219
+ The `publish` command allows you to publish the current package to the npm registry. It also automatically generates the `exports` field and other fields in the published `package.json`.
220
+
221
+ ```bash
222
+ jk publish [options]
223
+ ```
224
+
225
+ #### Options
226
+
227
+ - `-b, --bumper <bumper>`: Bump version (default: `patch`)
228
+ - `-no-b, --no-bumper`: No bump version
229
+ - `-o, --outdir <OUTDIR>`: Specify the output directory (default: `dist`)
230
+
231
+ #### Pass-through Options
232
+
233
+ If you want to pass options to the `pnpm publish` command, you can pass the options after `--`.
234
+
235
+ ```bash
236
+ jk publish -- --access public --no-git-checks
237
+ ```
238
+
239
+ ## Why not use X?
240
+
241
+ Similar tools to `jiek` include: [tsup](https://github.com/egoist/tsup), [unbuild](https://github.com/unjs/unbuild), [bunchee](https://github.com/huozhi/bunchee), [pkgroll](https://github.com/privatenumber/pkgroll), [tsdown](https://github.com/sxzz/tsdown). However, they all have some common issues that have not been resolved, such as:
242
+
243
+ - There are certain issues with `monorepo` support, and dependencies on other packages in the workspace must be recompiled
244
+ - The rules for writing entry files are too cumbersome and not natural enough
245
+ - Unable to handle issues related to `Project Reference` in `tsconfig.json`
246
+ - Unable to fully utilize `conditional` features
247
+ - Unable to choose the required builder, can only replace the entire toolchain
248
+
249
+ ## Who is using Jiek?
250
+
251
+ - [nonzzz/vite-plugin-compression](https://github.com/nonzzz/vite-plugin-compression)
252
+ - [nonzzz/vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)
253
+ - [nonzzz/squarified](https://github.com/nonzzz/squarified)
254
+ - [typp-js/typp](https://github.com/typp-js/typp)
208
255
 
209
- 在这里与 `jiek` 类似的工具有:[tsup](https://github.com/egoist/tsup)、[unbuild](https://github.com/unjs/unbuild)、[bunchee](https://github.com/huozhi/bunchee)、[pkgroll](https://github.com/privatenumber/pkgroll)、[tsdown](https://github.com/sxzz/tsdown)。但是他们都有着一些共同问题没有解决,比如说:
256
+ ## About this README
210
257
 
211
- - `monorepo` 的支持存在一定的问题,在依赖工作空间其他的包时必须重新编译相关依赖
212
- - 编写入口文件的规则过于繁琐,不够自然
213
- - 无法处理 `tsconfig.json` 中的 `Project Reference` 相关问题
214
- - 根据`conditions`
258
+ This README is generated by [copilot workspace](https://githubnext.com/projects/copilot-workspace) and originates from the [zh-Hans/README.md](https://github.com/NWYLZW/jiek/blob/master/packages/jiek/.about/zh-Hans/README.md) file.
@@ -116,7 +116,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
116
116
 
117
117
  var name = "jiek";
118
118
  var type = "module";
119
- var version = "2.1.3";
119
+ var version = "2.1.5";
120
120
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
121
121
  var author = "YiJie <yijie4188@gmail.com>";
122
122
  var repository = {
@@ -672,4 +672,8 @@ ${errorStr}`)));
672
672
  }
673
673
  });
674
674
 
675
- commander.program.parse(process.argv);
675
+ if (process.env.JIEK_IS_ONLY_BUILD === "true") {
676
+ import('commander').then(({ program }) => {
677
+ program.parse(process.argv);
678
+ });
679
+ }
@@ -108,7 +108,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
108
108
 
109
109
  var name = "jiek";
110
110
  var type = "module";
111
- var version = "2.1.3";
111
+ var version = "2.1.5";
112
112
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
113
113
  var author = "YiJie <yijie4188@gmail.com>";
114
114
  var repository = {
@@ -664,4 +664,8 @@ ${errorStr}`)));
664
664
  }
665
665
  });
666
666
 
667
- program.parse(process.argv);
667
+ if (process.env.JIEK_IS_ONLY_BUILD === "true") {
668
+ import('commander').then(({ program }) => {
669
+ program.parse(process.argv);
670
+ });
671
+ }
package/dist/cli.cjs CHANGED
@@ -4801,3 +4801,5 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
4801
4801
  }
4802
4802
  `.trim();
4803
4803
  commander.program.command("postpublish").description(postpublishDescription).action(postpublish);
4804
+
4805
+ commander.program.parse(process.argv);
package/dist/cli.js CHANGED
@@ -4771,3 +4771,5 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
4771
4771
  }
4772
4772
  `.trim();
4773
4773
  program.command("postpublish").description(postpublishDescription).action(postpublish);
4774
+
4775
+ program.parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.1.4",
4
+ "version": "2.1.6",
5
5
  "description": "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.",
6
6
  "author": "YiJie <yijie4188@gmail.com>",
7
7
  "repository": {
@@ -2,6 +2,8 @@ import './utils/filterSupport'
2
2
  import './commands/base'
3
3
  import './commands/build'
4
4
 
5
- import { program } from 'commander'
6
-
7
- program.parse(process.argv)
5
+ if (process.env.JIEK_IS_ONLY_BUILD === 'true') {
6
+ import('commander').then(({ program }) => {
7
+ program.parse(process.argv)
8
+ })
9
+ }
package/src/cli.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import './commands/publish'
2
2
  import 'jiek/cli-only-build'
3
+
4
+ import { program } from 'commander'
5
+
6
+ program.parse(process.argv)