jiek 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +104 -68
- package/dist/cli-only-build.cjs +6 -2
- package/dist/cli-only-build.js +6 -2
- package/dist/cli.cjs +2 -0
- package/dist/cli.js +2 -0
- package/package.json +1 -1
- package/src/cli-only-build.ts +5 -3
- package/src/cli.ts +4 -0
package/README.md
CHANGED
@@ -1,36 +1,46 @@
|
|
1
1
|
# Jiek
|
2
2
|
|
3
|
-
|
|
4
|
-
| [
|
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
|
-
>
|
12
|
+
> A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.
|
10
13
|
|
11
|
-
- [x]
|
12
|
-
- `exports
|
13
|
-
- `imports
|
14
|
-
- `type: module
|
15
|
-
- `dependencies
|
16
|
-
- `devDependencies
|
17
|
-
- [ ]
|
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]
|
22
|
-
- [ ]
|
23
|
-
- [ ]
|
24
|
-
- [x]
|
25
|
-
- [x]
|
26
|
-
- [x]
|
27
|
-
- [ ]
|
28
|
-
- [
|
29
|
-
- [
|
30
|
-
|
31
|
-
- [ ]
|
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
|
-
-
|
57
|
+
- Add entry files in `package.json`, here you need to set the original file path.
|
48
58
|
|
49
|
-
|
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
|
-
-
|
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
|
-
-
|
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
|
-
-
|
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
|
-
>
|
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
|
-
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,120 @@ jb @monorepo/utils
|
|
121
131
|
jb utils
|
122
132
|
```
|
123
133
|
|
124
|
-
###
|
134
|
+
### Custom Build Tools
|
125
135
|
|
126
|
-
|
136
|
+
We support multiple build tools, you can specify the build tool through `--type <type: esbuild | swc>`.
|
127
137
|
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
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
|
-
-
|
143
|
-
-
|
144
|
-
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
###
|
203
|
+
### Custom tsconfig Path
|
194
204
|
|
195
|
-
|
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
|
-
|
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
|
-
|
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
|
+
- According to `conditions`
|
208
247
|
|
209
|
-
|
248
|
+
## About this README
|
210
249
|
|
211
|
-
-
|
212
|
-
- 编写入口文件的规则过于繁琐,不够自然
|
213
|
-
- 无法处理 `tsconfig.json` 中的 `Project Reference` 相关问题
|
214
|
-
- 根据`conditions`
|
250
|
+
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.
|
package/dist/cli-only-build.cjs
CHANGED
@@ -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.
|
119
|
+
var version = "2.1.4";
|
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
|
-
|
675
|
+
if (process.env.JIEK_IS_ONLY_BUILD === "true") {
|
676
|
+
import('commander').then(({ program }) => {
|
677
|
+
program.parse(process.argv);
|
678
|
+
});
|
679
|
+
}
|
package/dist/cli-only-build.js
CHANGED
@@ -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.
|
111
|
+
var version = "2.1.4";
|
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
|
-
|
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
package/dist/cli.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.1.
|
4
|
+
"version": "2.1.5",
|
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": {
|
package/src/cli-only-build.ts
CHANGED
@@ -2,6 +2,8 @@ import './utils/filterSupport'
|
|
2
2
|
import './commands/base'
|
3
3
|
import './commands/build'
|
4
4
|
|
5
|
-
|
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
|
+
}
|