zshy 0.2.4 → 0.3.0
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 +76 -25
- package/dist/main.cjs +322 -239
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +322 -239
- package/dist/main.js.map +1 -1
- package/dist/tx-extension-rewrite.cjs +15 -1
- package/dist/tx-extension-rewrite.cjs.map +1 -1
- package/dist/tx-extension-rewrite.d.cts.map +1 -1
- package/dist/tx-extension-rewrite.d.ts.map +1 -1
- package/dist/tx-extension-rewrite.js +15 -1
- package/dist/tx-extension-rewrite.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -78,6 +78,8 @@ pnpm add --save-dev zshy
|
|
|
78
78
|
|
|
79
79
|
// with multiple entrypoints (subpaths, wildcards, deep wildcards)
|
|
80
80
|
+ "zshy": {
|
|
81
|
+
+ "main": "./src/index.ts",
|
|
82
|
+
+ "module": "./src/index.ts",
|
|
81
83
|
+ "exports": {
|
|
82
84
|
+ ".": "./src/index.ts",
|
|
83
85
|
+ "./utils": "./src/utils.ts",
|
|
@@ -348,6 +350,73 @@ Be sure to include a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) a
|
|
|
348
350
|
// CLI code here
|
|
349
351
|
```
|
|
350
352
|
|
|
353
|
+
<br/>
|
|
354
|
+
|
|
355
|
+
### ESM-only
|
|
356
|
+
|
|
357
|
+
For packages that only need ESM builds, you can disable CommonJS output entirely:
|
|
358
|
+
|
|
359
|
+
```jsonc
|
|
360
|
+
{
|
|
361
|
+
"zshy": {
|
|
362
|
+
"exports": { ... },
|
|
363
|
+
"cjs": false
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
This will generate only ESM files (`.js` and `.d.ts`) and the `package.json#/exports` will only include `"import"` and `"types"` conditions.
|
|
369
|
+
|
|
370
|
+
```jsonc
|
|
371
|
+
{
|
|
372
|
+
// package.json
|
|
373
|
+
"exports": {
|
|
374
|
+
".": {
|
|
375
|
+
"types": "./dist/index.d.ts",
|
|
376
|
+
"import": "./dist/index.js"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
<br/>
|
|
383
|
+
|
|
384
|
+
### Custom conditions
|
|
385
|
+
|
|
386
|
+
To specify custom conditions in your export maps, specify a `"conditions"` map. Each condition name must correspond to one of `"src" | "esm" | "cjs"`.
|
|
387
|
+
|
|
388
|
+
```diff
|
|
389
|
+
{
|
|
390
|
+
"zshy": {
|
|
391
|
+
"exports": {
|
|
392
|
+
".": "./src/index.ts"
|
|
393
|
+
},
|
|
394
|
+
+ "conditions": {
|
|
395
|
+
+ "my-src-condition": "src"
|
|
396
|
+
+ "my-esm-condition": "esm",
|
|
397
|
+
+ "my-cjs-condition": "cjs"
|
|
398
|
+
+ }
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
With this addition, `zshy` will add the `"my-source"` condition to the generated `"exports"` map:
|
|
403
|
+
|
|
404
|
+
```diff
|
|
405
|
+
// package.json
|
|
406
|
+
{
|
|
407
|
+
"exports": {
|
|
408
|
+
".": {
|
|
409
|
+
+ "my-src-condition": "./src/index.ts",
|
|
410
|
+
+ "my-esm-condition": "./dist/index.js",
|
|
411
|
+
+ "my-cjs-condition": "./dist/index.cjs"
|
|
412
|
+
"types": "./dist/index.d.cts",
|
|
413
|
+
"import": "./dist/index.js",
|
|
414
|
+
"require": "./dist/index.cjs"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
351
420
|
<br/>
|
|
352
421
|
<br/>
|
|
353
422
|
<br/>
|
|
@@ -634,40 +703,22 @@ This causes issues for packages that want to use subpath imports to structure th
|
|
|
634
703
|
|
|
635
704
|
With this setup, your build outputs (`index.js`, etc) will be written to the package root. Older environments will resolve imports like `"your-library/utils"` to `"your-library/utils/index.js"`, effectively simulating subpath imports in environments that don't support them.
|
|
636
705
|
|
|
637
|
-
<br/>
|
|
706
|
+
<br />
|
|
638
707
|
|
|
639
|
-
###
|
|
708
|
+
### Can I prevent `zshy` from modifying my `package.json`?
|
|
640
709
|
|
|
641
|
-
|
|
710
|
+
Yes. If you prefer to manage your `package.json` fields manually, you can prevent `zshy` from making any changes by setting the `noEdit` option to `true` in your `package.json#/zshy` config.
|
|
642
711
|
|
|
643
|
-
```
|
|
712
|
+
```jsonc
|
|
644
713
|
{
|
|
645
714
|
"zshy": {
|
|
646
|
-
"exports":
|
|
647
|
-
|
|
648
|
-
},
|
|
649
|
-
+ "sourceDialects": ["my-source"] // 👈 add this
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
```
|
|
653
|
-
|
|
654
|
-
With this addition, `zshy` will add the `"my-source"` condition to the generated `"exports"` map:
|
|
655
|
-
|
|
656
|
-
```diff
|
|
657
|
-
// package.json
|
|
658
|
-
{
|
|
659
|
-
"exports": {
|
|
660
|
-
".": {
|
|
661
|
-
+ "my-source": "./src/index.ts",
|
|
662
|
-
"types": "./dist/index.d.cts",
|
|
663
|
-
"import": "./dist/index.js",
|
|
664
|
-
"require": "./dist/index.cjs"
|
|
665
|
-
}
|
|
715
|
+
"exports": "./src/index.ts",
|
|
716
|
+
"noEdit": true
|
|
666
717
|
}
|
|
667
718
|
}
|
|
668
719
|
```
|
|
669
720
|
|
|
670
|
-
|
|
721
|
+
When `noEdit` is enabled, `zshy` will build your files but will not write to `package.json`. You will be responsible for populating the `"exports"`, `"bin"`, `"main"`, `"module"`, and `"types"` fields yourself.
|
|
671
722
|
|
|
672
723
|
<br />
|
|
673
724
|
|