@visulima/packem 1.0.0-alpha.7 → 1.0.0-alpha.70

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +448 -0
  2. package/LICENSE.md +40 -40
  3. package/README.md +28 -5
  4. package/dist/cli.mjs +116 -1
  5. package/dist/config.cjs +1 -1
  6. package/dist/config.d.cts +6 -5
  7. package/dist/config.d.mts +6 -5
  8. package/dist/config.d.ts +6 -5
  9. package/dist/config.mjs +1 -1
  10. package/dist/create-bundler.cjs +78 -71
  11. package/dist/create-bundler.d.cts +6 -5
  12. package/dist/create-bundler.d.mts +6 -5
  13. package/dist/create-bundler.d.ts +6 -5
  14. package/dist/create-bundler.mjs +84 -71
  15. package/dist/rollup/plugins/esbuild/index.cjs +1 -1
  16. package/dist/rollup/plugins/esbuild/index.d.cts +1 -1
  17. package/dist/rollup/plugins/esbuild/index.d.mts +1 -1
  18. package/dist/rollup/plugins/esbuild/index.d.ts +1 -1
  19. package/dist/rollup/plugins/esbuild/index.mjs +2 -8
  20. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.cjs +1 -0
  21. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.cts +26 -0
  22. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +26 -0
  23. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +26 -0
  24. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.mjs +1 -0
  25. package/dist/rollup/plugins/sucrase/index.cjs +1 -1
  26. package/dist/rollup/plugins/sucrase/index.mjs +1 -1
  27. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.cjs +1 -0
  28. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.cts +26 -0
  29. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +26 -0
  30. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +26 -0
  31. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.mjs +1 -0
  32. package/dist/rollup/plugins/swc/{index.cjs → swc-plugin.cjs} +1 -1
  33. package/dist/rollup/plugins/swc/{index.d.cts → swc-plugin.d.cts} +1 -1
  34. package/dist/rollup/plugins/swc/{index.d.mts → swc-plugin.d.mts} +1 -1
  35. package/dist/rollup/plugins/swc/{index.d.ts → swc-plugin.d.ts} +1 -1
  36. package/dist/rollup/plugins/swc/{index.mjs → swc-plugin.mjs} +1 -1
  37. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.cjs +1 -0
  38. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.cts +27 -0
  39. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +27 -0
  40. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +27 -0
  41. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.mjs +1 -0
  42. package/dist/shared/{packem.aHRI8QbF.d.ts → packem.BCrBTnWG.d.ts} +30 -14
  43. package/dist/shared/{packem.DZfoF9Bk.d.cts → packem.BUYvl64L.d.cts} +30 -14
  44. package/dist/shared/packem.BcJmI4Tm.mjs +1 -0
  45. package/dist/shared/packem.CFplOoR-.cjs +1 -0
  46. package/dist/shared/{packem.C44tLE3n.d.cts → packem.Cvy5yEVh.d.cts} +35 -3
  47. package/dist/shared/{packem.C44tLE3n.d.mts → packem.Cvy5yEVh.d.mts} +35 -3
  48. package/dist/shared/{packem.C44tLE3n.d.ts → packem.Cvy5yEVh.d.ts} +35 -3
  49. package/dist/shared/{packem.CAQMZ6ex.d.mts → packem.DS_-5GJd.d.mts} +30 -14
  50. package/dist/shared/packem.DUZi_m4G.cjs +1 -0
  51. package/dist/shared/{packem.D09xRBAa.d.cts → packem.Db-Z_7e-.d.cts} +1 -1
  52. package/dist/shared/{packem.D09xRBAa.d.mts → packem.Db-Z_7e-.d.mts} +1 -1
  53. package/dist/shared/{packem.D09xRBAa.d.ts → packem.Db-Z_7e-.d.ts} +1 -1
  54. package/dist/shared/packem.aBqM5EY7.mjs +1 -0
  55. package/package.json +127 -81
  56. package/dist/cli.cjs +0 -2
  57. package/dist/cli.d.cts +0 -2
  58. package/dist/cli.d.mts +0 -2
  59. package/dist/cli.d.ts +0 -2
  60. package/dist/shared/packem.Bdmp1hC5.mjs +0 -1
  61. package/dist/shared/packem.Bj4QPFg7.mjs +0 -1
  62. package/dist/shared/packem.CEXB7aOL.cjs +0 -1
  63. package/dist/shared/packem.uvB0cQX0.cjs +0 -1
package/LICENSE.md CHANGED
@@ -33,11 +33,11 @@ By: Rich Harris
33
33
  Repository: https://github.com/Rich-Harris/estree-walker
34
34
 
35
35
  > Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/contributors)
36
- >
36
+ >
37
37
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
38
- >
38
+ >
39
39
  > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
40
- >
40
+ >
41
41
  > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
42
 
43
43
  <!-- DEPENDENCIES -->
@@ -57,17 +57,17 @@ Repository: git+https://github.com/swc-project/swc.git
57
57
  > Apache License
58
58
  > Version 2.0, January 2004
59
59
  > http://www.apache.org/licenses/
60
- >
60
+ >
61
61
  > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
62
- >
62
+ >
63
63
  > 1. Definitions.
64
- >
64
+ >
65
65
  > "License" shall mean the terms and conditions for use, reproduction,
66
66
  > and distribution as defined by Sections 1 through 9 of this document.
67
- >
67
+ >
68
68
  > "Licensor" shall mean the copyright owner or entity authorized by
69
69
  > the copyright owner that is granting the License.
70
- >
70
+ >
71
71
  > "Legal Entity" shall mean the union of the acting entity and all
72
72
  > other entities that control, are controlled by, or are under common
73
73
  > control with that entity. For the purposes of this definition,
@@ -75,24 +75,24 @@ Repository: git+https://github.com/swc-project/swc.git
75
75
  > direction or management of such entity, whether by contract or
76
76
  > otherwise, or (ii) ownership of fifty percent (50%) or more of the
77
77
  > outstanding shares, or (iii) beneficial ownership of such entity.
78
- >
78
+ >
79
79
  > "You" (or "Your") shall mean an individual or Legal Entity
80
80
  > exercising permissions granted by this License.
81
- >
81
+ >
82
82
  > "Source" form shall mean the preferred form for making modifications,
83
83
  > including but not limited to software source code, documentation
84
84
  > source, and configuration files.
85
- >
85
+ >
86
86
  > "Object" form shall mean any form resulting from mechanical
87
87
  > transformation or translation of a Source form, including but
88
88
  > not limited to compiled object code, generated documentation,
89
89
  > and conversions to other media types.
90
- >
90
+ >
91
91
  > "Work" shall mean the work of authorship, whether in Source or
92
92
  > Object form, made available under the License, as indicated by a
93
93
  > copyright notice that is included in or attached to the work
94
94
  > (an example is provided in the Appendix below).
95
- >
95
+ >
96
96
  > "Derivative Works" shall mean any work, whether in Source or Object
97
97
  > form, that is based on (or derived from) the Work and for which the
98
98
  > editorial revisions, annotations, elaborations, or other modifications
@@ -100,7 +100,7 @@ Repository: git+https://github.com/swc-project/swc.git
100
100
  > of this License, Derivative Works shall not include works that remain
101
101
  > separable from, or merely link (or bind by name) to the interfaces of,
102
102
  > the Work and Derivative Works thereof.
103
- >
103
+ >
104
104
  > "Contribution" shall mean any work of authorship, including
105
105
  > the original version of the Work and any modifications or additions
106
106
  > to that Work or Derivative Works thereof, that is intentionally
@@ -114,18 +114,18 @@ Repository: git+https://github.com/swc-project/swc.git
114
114
  > Licensor for the purpose of discussing and improving the Work, but
115
115
  > excluding communication that is conspicuously marked or otherwise
116
116
  > designated in writing by the copyright owner as "Not a Contribution."
117
- >
117
+ >
118
118
  > "Contributor" shall mean Licensor and any individual or Legal Entity
119
119
  > on behalf of whom a Contribution has been received by Licensor and
120
120
  > subsequently incorporated within the Work.
121
- >
121
+ >
122
122
  > 2. Grant of Copyright License. Subject to the terms and conditions of
123
123
  > this License, each Contributor hereby grants to You a perpetual,
124
124
  > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
125
125
  > copyright license to reproduce, prepare Derivative Works of,
126
126
  > publicly display, publicly perform, sublicense, and distribute the
127
127
  > Work and such Derivative Works in Source or Object form.
128
- >
128
+ >
129
129
  > 3. Grant of Patent License. Subject to the terms and conditions of
130
130
  > this License, each Contributor hereby grants to You a perpetual,
131
131
  > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
@@ -141,24 +141,24 @@ Repository: git+https://github.com/swc-project/swc.git
141
141
  > or contributory patent infringement, then any patent licenses
142
142
  > granted to You under this License for that Work shall terminate
143
143
  > as of the date such litigation is filed.
144
- >
144
+ >
145
145
  > 4. Redistribution. You may reproduce and distribute copies of the
146
146
  > Work or Derivative Works thereof in any medium, with or without
147
147
  > modifications, and in Source or Object form, provided that You
148
148
  > meet the following conditions:
149
- >
149
+ >
150
150
  > (a) You must give any other recipients of the Work or
151
151
  > Derivative Works a copy of this License; and
152
- >
152
+ >
153
153
  > (b) You must cause any modified files to carry prominent notices
154
154
  > stating that You changed the files; and
155
- >
155
+ >
156
156
  > (c) You must retain, in the Source form of any Derivative Works
157
157
  > that You distribute, all copyright, patent, trademark, and
158
158
  > attribution notices from the Source form of the Work,
159
159
  > excluding those notices that do not pertain to any part of
160
160
  > the Derivative Works; and
161
- >
161
+ >
162
162
  > (d) If the Work includes a "NOTICE" text file as part of its
163
163
  > distribution, then any Derivative Works that You distribute must
164
164
  > include a readable copy of the attribution notices contained
@@ -175,14 +175,14 @@ Repository: git+https://github.com/swc-project/swc.git
175
175
  > or as an addendum to the NOTICE text from the Work, provided
176
176
  > that such additional attribution notices cannot be construed
177
177
  > as modifying the License.
178
- >
178
+ >
179
179
  > You may add Your own copyright statement to Your modifications and
180
180
  > may provide additional or different license terms and conditions
181
181
  > for use, reproduction, or distribution of Your modifications, or
182
182
  > for any such Derivative Works as a whole, provided Your use,
183
183
  > reproduction, and distribution of the Work otherwise complies with
184
184
  > the conditions stated in this License.
185
- >
185
+ >
186
186
  > 5. Submission of Contributions. Unless You explicitly state otherwise,
187
187
  > any Contribution intentionally submitted for inclusion in the Work
188
188
  > by You to the Licensor shall be under the terms and conditions of
@@ -190,12 +190,12 @@ Repository: git+https://github.com/swc-project/swc.git
190
190
  > Notwithstanding the above, nothing herein shall supersede or modify
191
191
  > the terms of any separate license agreement you may have executed
192
192
  > with Licensor regarding such Contributions.
193
- >
193
+ >
194
194
  > 6. Trademarks. This License does not grant permission to use the trade
195
195
  > names, trademarks, service marks, or product names of the Licensor,
196
196
  > except as required for reasonable and customary use in describing the
197
197
  > origin of the Work and reproducing the content of the NOTICE file.
198
- >
198
+ >
199
199
  > 7. Disclaimer of Warranty. Unless required by applicable law or
200
200
  > agreed to in writing, Licensor provides the Work (and each
201
201
  > Contributor provides its Contributions) on an "AS IS" BASIS,
@@ -205,7 +205,7 @@ Repository: git+https://github.com/swc-project/swc.git
205
205
  > PARTICULAR PURPOSE. You are solely responsible for determining the
206
206
  > appropriateness of using or redistributing the Work and assume any
207
207
  > risks associated with Your exercise of permissions under this License.
208
- >
208
+ >
209
209
  > 8. Limitation of Liability. In no event and under no legal theory,
210
210
  > whether in tort (including negligence), contract, or otherwise,
211
211
  > unless required by applicable law (such as deliberate and grossly
@@ -217,7 +217,7 @@ Repository: git+https://github.com/swc-project/swc.git
217
217
  > work stoppage, computer failure or malfunction, or any and all
218
218
  > other commercial damages or losses), even if such Contributor
219
219
  > has been advised of the possibility of such damages.
220
- >
220
+ >
221
221
  > 9. Accepting Warranty or Additional Liability. While redistributing
222
222
  > the Work or Derivative Works thereof, You may choose to offer,
223
223
  > and charge a fee for, acceptance of support, warranty, indemnity,
@@ -228,11 +228,11 @@ Repository: git+https://github.com/swc-project/swc.git
228
228
  > defend, and hold each Contributor harmless for any liability
229
229
  > incurred by, or claims asserted against, such Contributor by reason
230
230
  > of your accepting any such warranty or additional liability.
231
- >
231
+ >
232
232
  > END OF TERMS AND CONDITIONS
233
- >
233
+ >
234
234
  > APPENDIX: How to apply the Apache License to your work.
235
- >
235
+ >
236
236
  > To apply the Apache License to your work, attach the following
237
237
  > boilerplate notice, with the fields enclosed by brackets "[]"
238
238
  > replaced with your own identifying information. (Don't include
@@ -241,15 +241,15 @@ Repository: git+https://github.com/swc-project/swc.git
241
241
  > file or class name and description of purpose be included on the
242
242
  > same "printed page" as the copyright notice for easier
243
243
  > identification within third-party archives.
244
- >
244
+ >
245
245
  > Copyright [yyyy] [name of copyright owner]
246
- >
246
+ >
247
247
  > Licensed under the Apache License, Version 2.0 (the "License");
248
248
  > you may not use this file except in compliance with the License.
249
249
  > You may obtain a copy of the License at
250
- >
250
+ >
251
251
  > http://www.apache.org/licenses/LICENSE-2.0
252
- >
252
+ >
253
253
  > Unless required by applicable law or agreed to in writing, software
254
254
  > distributed under the License is distributed on an "AS IS" BASIS,
255
255
  > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -261,22 +261,22 @@ Repository: git+https://github.com/swc-project/swc.git
261
261
  ## ts-essentials
262
262
  License: MIT
263
263
  By: Krzysztof Kaczor
264
- Repository: git@github.com:krzkaczor/ts-essentials.git
264
+ Repository: git@github.com:ts-essentials/ts-essentials.git
265
265
 
266
266
  > The MIT License
267
- >
267
+ >
268
268
  > Copyright (c) 2018-2019 Chris Kaczor (github.com/krzkaczor)
269
- >
269
+ >
270
270
  > Permission is hereby granted, free of charge, to any person obtaining a copy
271
271
  > of this software and associated documentation files (the "Software"), to deal
272
272
  > in the Software without restriction, including without limitation the rights
273
273
  > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
274
274
  > copies of the Software, and to permit persons to whom the Software is
275
275
  > furnished to do so, subject to the following conditions:
276
- >
276
+ >
277
277
  > The above copyright notice and this permission notice shall be included in
278
278
  > all copies or substantial portions of the Software.
279
- >
279
+ >
280
280
  > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
281
281
  > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
282
282
  > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <div align="center">
2
2
  <h3>Visulima packem</h3>
3
3
  <p>
4
- A fast and modern bundler for Node.js and TypeScript.
4
+ A fast and modern bundler for Node.js and TypeScript. <br /> Bundles anything that's supported by Node.js natively, namely .js, .json, .mjs, .cjs and TypeScript .ts, .cts, .mts, .tsx.
5
5
  </p>
6
6
  </div>
7
7
 
@@ -39,17 +39,40 @@ yarn add @visulima/packem
39
39
  pnpm add @visulima/packem
40
40
  ```
41
41
 
42
+ ### Choose you transformer
43
+
44
+ You choose which one of the three supported transformer to use.
45
+
46
+ - [esbuild](https://github.com/evanw/esbuild)
47
+ - [@swc/core](https://github.com/swc-project/swc)
48
+ - [sucrase](https://github.com/alangpierce/sucrase)
49
+
42
50
  ## Usage
43
51
 
44
- ```typescript
52
+ ### Initialize the packem configuration
45
53
 
54
+ ```bash
55
+ packem init [options]
46
56
  ```
47
57
 
58
+ ### Bundle files
59
+
60
+ ```bash
61
+ packem build [options]
62
+ ```
63
+
64
+ > This will write the files into the `./dist` folder.
65
+
66
+ Links:
67
+
68
+ - https://github.com/frehner/modern-guide-to-packaging-js-library#set-the-main-field
69
+
48
70
  ## Related
49
71
 
50
72
  - [bunchee](https://github.com/huozhi/bunchee) - Zero config bundler for ECMAScript and TypeScript packages
51
73
  - [unbuild](https://github.com/unjs/unbuild) - 📦 An unified javascript build system
52
74
  - [pkgroll](https://github.com/privatenumber/pkgroll) - 📦 Zero-config package bundler for Node.js + TypeScript
75
+ - [siroc](https://github.com/danielroe/siroc) - Zero-config build tooling for Node
53
76
  - [tsup](https://github.com/egoist/tsup) - The simplest and fastest way to bundle your TypeScript libraries
54
77
 
55
78
  ## Supported Node.js Versions
@@ -74,7 +97,7 @@ The visulima pack is open-sourced software licensed under the [MIT][license-url]
74
97
 
75
98
  [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
76
99
  [typescript-url]: "typescript"
77
- [license-image]: https://img.shields.io/npm/l/@visulima/pack?color=blueviolet&style=for-the-badge
100
+ [license-image]: https://img.shields.io/npm/l/@visulima/packem?color=blueviolet&style=for-the-badge
78
101
  [license-url]: LICENSE.md "license"
79
- [npm-image]: https://img.shields.io/npm/v/@visulima/pack/latest.svg?style=for-the-badge&logo=npm
80
- [npm-url]: https://www.npmjs.com/package/@visulima/pack/v/latest "npm"
102
+ [npm-image]: https://img.shields.io/npm/v/@visulima/packem/latest.svg?style=for-the-badge&logo=npm
103
+ [npm-url]: https://www.npmjs.com/package/@visulima/packem/v/latest "npm"
package/dist/cli.mjs CHANGED
@@ -1,2 +1,117 @@
1
1
  #!/usr/bin/env node
2
- var s=Object.defineProperty;var c=(t,e)=>s(t,"name",{value:e,configurable:!0});import{exit as p}from"node:process";import l from"@visulima/cerebro";import m from"./create-bundler.mjs";const d="@visulima/packem",u="1.0.0-alpha.6";var f=Object.defineProperty,a=c((t,e)=>f(t,"name",{value:e,configurable:!0}),"n");const g=a(t=>{t.addCommand({description:"Demonstrate options required",execute:a(async({options:e})=>{let i="build";e.watch?i="watch":e.jit&&(i="jit");const n={};if(e.env)for(const r of e.env)n[r.key]=r.value;await m(e.dir,i,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...n},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{description:"Watch for changes",name:"watch",type:Boolean},{description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:a(e=>{const[i,n]=e.split("=");return{key:i,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean}]})},"createBuildCommand"),o=new l("packem",{packageName:d,packageVersion:u});g(o),o.setDefaultCommand("build"),o.run().catch(t=>{console.error(t.message),p(1)});
2
+ var St=Object.defineProperty;var d=(e,t)=>St(e,"name",{value:t,configurable:!0});import Nt from"@visulima/cerebro";import{SimpleReporter as _t}from"@visulima/pail/reporter";import{env as j,versions as Pt,cwd as Ct,exit as Mt}from"node:process";import{DEFAULTS as It,nodeResolve as Be}from"@rollup/plugin-node-resolve";import{chmod as Rt,stat as We,readdir as Ft}from"node:fs/promises";import je from"node:module";import{cyan as v,bold as N,gray as R,yellow as Tt,grey as At,green as Jt}from"@visulima/colorize";import{readFile as ce,writeFile as L,isAccessibleSync as E,collectSync as Bt,readFileSync as Le,writeFileSync as H,writeJsonSync as Wt,ensureDirSync as Lt,emptyDir as ze,walk as zt,isAccessible as Ut}from"@visulima/fs";import{NotFoundError as Vt}from"@visulima/fs/error";import{formatBytes as M,duration as Ht}from"@visulima/humanizer";import{parsePackageJson as Ue}from"@visulima/package/package-json";import{resolve as g,join as h,normalize as pe,extname as ue,relative as S,dirname as de,basename as G,isAbsolute as Ve,toNamespacedPath as ke}from"@visulima/path";import{readTsConfig as qt,findTsConfig as Gt}from"@visulima/tsconfig";import{defu as Yt}from"defu";import{createHooks as Kt}from"hookable";import{rollup as He,watch as xe,VERSION as Xt}from"rollup";import{pathToFileURL as Zt,fileURLToPath as Qt}from"node:url";import{resolvePath as eo,resolveModuleExportNames as to,findStaticImports as qe}from"mlly";import P from"magic-string";import Ge from"jiti";import{existsSync as me,rmSync as oo}from"node:fs";import Ye from"@rollup/plugin-alias";import ro from"@rollup/plugin-commonjs";import no from"@rollup/plugin-dynamic-import-vars";import Ke from"@rollup/plugin-replace";import{wasm as io}from"@rollup/plugin-wasm";import so from"rollup-plugin-polyfill-node";import{visualizer as ao}from"rollup-plugin-visualizer";import{minVersion as Xe}from"semver";import{glob as lo}from"glob";import co from"glob-parent";import{createFilter as Y,normalizePath as Ee}from"@rollup/pluginutils";import po from"@rollup/plugin-json";import uo from"rollup-plugin-license";import{createHash as mo}from"node:crypto";import{parse as fo}from"@babel/parser";import{findCacheDirSync as go}from"@visulima/find-cache-dir";import{distance as ho}from"fastest-levenshtein";import{installPackage as yo}from"@antfu/install-pkg";import{intro as vo,isCancel as bo,cancel as $o,select as wo,confirm as jo,spinner as Q,outro as ko}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
3
+ import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
4
+ import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
5
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
6
+ const __dirname = __cjs_path__.dirname(__filename);
7
+ const require = __cjs_mod__.createRequire(import.meta.url);
8
+ const xo="@visulima/packem",Eo="1.0.0-alpha.69",A=[...It.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],D="production",B="development",Oo=[B,D],Ze=["react-server","react-native","edge-light"];[...Oo,...Ze];const ee=/node_modules/;var Do=Object.defineProperty,K=d((e,t)=>Do(e,"name",{value:t,configurable:!0}),"i$c");const fe=/^#![^\n]*/,ae=K(async e=>{await Rt(e,493).catch(()=>{})},"makeExecutable"),So=K((e,t=`#!/usr/bin/env node
9
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const i=new P(o);return i.prepend(t),{code:i.toString(),map:n.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,i]of Object.entries(r))if(i.type==="chunk"&&fe.test(i.code)&&o.dir){const s=g(o.dir,n);await ae(s)}}}),"shebangPlugin"),No=K(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(fe,"")}}),"removeShebangPlugin"),_o=K((e,t=`
10
+ `)=>{const o=fe.exec(e);return o?o+t:""},"getShebang");var Po=Object.defineProperty,Co=d((e,t)=>Po(e,"name",{value:t,configurable:!0}),"p$4");const ge=Co((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const i=r[n];typeof i=="string"&&(o[n]=h(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Mo=Object.defineProperty,Io=d((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o$3");const Ro=Io((e,t)=>{const o=Ge(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var Fo=Object.defineProperty,To=d((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$a");const W=To((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ao=Object.defineProperty,Jo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"u$a");const Bo=Jo(async e=>{const t=await eo("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ge(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,r.name),i=pe(Ro(r.input,e.options.rootDir)||r.input),s=i.slice(0,Math.max(0,i.length-ue(i).length)),a=await ce(i),l=_o(a);e.options.emitCJS&&await L(`${n}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
11
+ `));let c=[];try{c=await to(i,{extensions:A})}catch(u){W(e,`Cannot analyze ${i} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await L(`${n}.mjs`,l+[`import jiti from ${JSON.stringify(Zt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,p?`
12
+ export default _module;`:"",...c.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
13
+ `)),await L(`${n}.d.cts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
14
+ `)),await L(`${n}.d.mts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
15
+ `)),l&&(await ae(`${n}.cjs`),await ae(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Wo=Object.defineProperty,Lo=d((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"r$9");const Qe=Lo((e,t)=>Ge(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var zo=Object.defineProperty,et=d((e,t)=>zo(e,"name",{value:t,configurable:!0}),"t$7");const q=et(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),tt=et((e,t,o,r)=>{if(o){const s=q(o);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r==="commonjs"?"cjs":"esm";const[n,...i]=t;return tt(n,i,o,r)},"inferExportType");var Uo=Object.defineProperty,Vo=d((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"n$8");const he=Vo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=q(e),i=t==="module"?"esm":"cjs";if(n&&n!==i)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:n??i}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,i])=>n==="types"&&o===!1?[]:typeof i=="string"?{file:i,key:"exports",...["browser","default","deno","development","import","node","node-addons","production","require","types"].includes(n)?{subKey:n}:{},type:tt(n,r,i,t)}:he(i,t,o,[...r,n]))},"extractExportFilenames");var Ho=Object.defineProperty,ye=d((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"y$1");const qo=ye(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(j.production){if(!j.NODE_ENV.includes(D)&&!j.NODE_ENV.includes(B))throw new Error("Invalid production value: "+j.production+', must be either "'+D+'" or "'+B+'".');return j.production}return"production"},"getEnvironment"),z=ye((e,t,o,r,n,i)=>{const s=e.find(a=>a.input===t)??e[e.push({input:t})-1];if(o&&(s.outDir=r),n.isExecutable)s.executable=!0,s.declaration=!1,n.type==="cjs"&&(s.cjs=!0),n.type==="esm"&&(s.esm=!0);else{/\.d\.[mc]?ts$/.test(n.file)&&i!==!1&&(s.declaration=i),n.type==="cjs"&&(s.cjs=!0),n.type==="esm"&&(s.esm=!0);for(const a of Ze)if(n.file.includes("."+a+".")){s.runtime=a;break}}s.runtime===void 0&&(s.runtime="node"),s.environment=qo(n)},"createOrUpdateEntry"),Oe=/(?:\.d\.[mc]?ts|\.\w+)$/;let De=!1;const Go=ye((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs",i=he(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=q(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:q(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&i.push({file:e.types??e.typings,key:"types"});const s=[];for(const a of i){const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const p=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if(a.file.includes("/*")&&a.key==="exports"){De||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),De=!0);const f=[],b=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const $ of t)b.test($)&&f.push($.replace(Oe,""));if(f.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const $ of f)z(s,$,c,l,a,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),m=t.find(f=>u.test(f))?.replace(Oe,"");if(!m){me(g(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}E(m+".cts")&&E(m+".mts")?(z(s,m+".cts",c,l,{...a,type:"cjs"},o.options.declaration),z(s,m+".mts",c,l,{...a,type:"esm"},o.options.declaration)):z(s,m,c,l,a,o.options.declaration)}return{entries:s,warnings:r}},"inferEntries");var Yo=Object.defineProperty,Ko=d((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"t$6");const Xo=Ko((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Zo=Object.defineProperty,Qo=d((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$5");const er={hooks:{"build:prepare":Qo(function(e){if(e.options.entries.length>0)return;const t=h(e.options.rootDir,e.options.sourceDir);if(!me(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Bt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(r=Xo(r,e.options.declaration));const n=Go(r,o,e);for(const i of n.warnings)W(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v(e.options.entries.map(i=>N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),R([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var tr=Object.defineProperty,or=d((e,t)=>tr(e,"name",{value:t,configurable:!0}),"t$4");const rr=or((e,t)=>(e==="auto"?e=er:typeof e=="string"&&(e=Qe(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var nr=Object.defineProperty,ir=d((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$c");const le=ir((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var sr=Object.defineProperty,ar=d((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$b");const te=ar(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var lr=Object.defineProperty,cr=d((e,t)=>lr(e,"name",{value:t,configurable:!0}),"a$a");const ot=cr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var pr=Object.defineProperty,rt=d((e,t)=>pr(e,"name",{value:t,configurable:!0}),"s$c");const ur=rt((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),dr=rt(e=>{const t=new Map;return o=>ur(e,o,t)},"memoizeByKey");var mr=Object.defineProperty,fr=d((e,t)=>mr(e,"name",{value:t,configurable:!0}),"m$9");const nt=fr(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,i){if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new P(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
16
+ module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(r);if(s===null||s.length<2)return null;const a=s[1].split(", "),l=[];let c="";for(const u of a)if(!u.includes("type"))if(u.includes("as")){const[m,f]=u.split(" as ");if(f==="default"&&(c=m,!e))continue;l.push(f+": typeof "+m+";")}else l.push(u+": typeof "+u+";");const p=new P(r);return p.replace(" "+c+" as default,",""),p.append(`
17
+
18
+ declare const defaultExport: {
19
+ `+(l.length>0?" ":"")+l.join(`
20
+ `)+`
21
+ }`+(c?" & typeof "+c:"")+`;
22
+
23
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var gr=Object.defineProperty,hr=d((e,t)=>gr(e,"name",{value:t,configurable:!0}),"f$4");const yr=hr((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const i=await Promise.all(n.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await lo(s.src,{ignore:s.exclude}).then(a=>({dest:s.dest??"",parent:co(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?pe(s.dest):h(s.dest,S(s.parent,de(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await We(s);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),l=await ce(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const p=G(s),u=h(c,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:u,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${s} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var vr=Object.defineProperty,X=d((e,t)=>vr(e,"name",{value:t,configurable:!0}),"t$3");const br=/\Wrequire(?:\.resolve)?\(/,$r=X((e,t)=>{if(j.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,n=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),br.test(e)&&(n=!0),!o&&!r&&!n)return null;const i=qe(e).pop(),s=i?i.end:0,a=new P(e);return a.appendRight(s,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),wr=X((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
24
+ `),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
25
+ `),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
26
+ `),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
27
+ `),t&&(r+=`const __dirname = __cjs_path__.dirname(__filename);
28
+ `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
29
+ `),r},"generateCJSShim"),jr=X((e,t,o)=>{let r="";return o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
30
+ `),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
31
+ `),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
32
+ `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
33
+ `),r},"generateCJSShimNode20_11"),kr=X(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=wr;if(e.engines?.node){const i=Xe(e.engines.node);i&&i.major>=20&&i.minor>=11&&(n=jr)}return $r(t,n)}return null}}),"cjsPlugin");var xr=Object.defineProperty,Er=d((e,t)=>xr(e,"name",{value:t,configurable:!0}),"n$3");const Or=Er(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Dr=Object.defineProperty,Se=d((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"c$8");const Sr=Se(e=>(t,o={})=>{const r=Y(o.include,o.exclude),n={},i=Se((s,a)=>{n[s.replace(/\..?[jt]s$/,"")]=a},"addOutput");return{generateBundle(s,a){let{entryFileNames:l}=s;typeof l=="function"&&(l=l(a));const c=l.replace(/\.(.)?[jt]s$/,(p,u)=>`.d.${u||""}ts`);for(const[p,u]of Object.entries(n))this.emitFile({fileName:c.replace("[name]",S(e,p)),source:u,type:"asset"})},name:"packem:isolated-declarations",async transform(s,a){if(!r(a))return;const l=await t(a,s),{errors:c,sourceText:p}=l;c.length>0?o.ignoreErrors?this.warn(c[0]):this.error(c[0]):i(a,p)}}},"isolatedDeclarationsPlugin");var Nr=Object.defineProperty,_r=d((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"n$2");const Ne="export default ",it=_r(e=>{const t=po(e);return{...t,name:"packem:json",transform(o,r){const n=t.transform?.call(this,o,r);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(Ne)&&(n.code=n.code.replace(Ne,"module.exports = ")),n}}},"JSONPlugin");class Pr{static{d(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class Cr extends Pr{static{d(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_skip,p=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(p)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];_e(c)&&(this.visit(c,t,i,l)||l--)}}else _e(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const l=this.should_remove;if(this.replacement=s,this.should_remove=a,l)return null}}return t}}function _e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}d(_e,"isNode");function st(e,{enter:t,leave:o}){return new Cr(t,o).visit(e,null)}d(st,"walk");var Mr=Object.defineProperty,Ir=d((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"u$8");const Rr=Ir(({attributes:e,logger:t})=>{const o=Y([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(r,n){if(!o(n))return null;let i=null;try{i=this.parse(r,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(l),null}let s=!1;const a=new P(r);return st(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(a.overwrite(u.start-2,u.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Fr=Object.defineProperty,ve=d((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"g$3");const Tr=ve(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Ar=ve((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
34
+ ${o}
35
+ $2`)},"replaceContentWithin"),at=ve(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:i,packageName:s})=>uo({thirdParty(a){const l=new Set,c=a.sort(({name:u},{name:m})=>(u||0)>(m||0)?1:(m||0)>(u||0)?-1:0).map(({author:u,contributors:m,license:f,licenseText:b,maintainers:$,name:O,repository:y})=>{let C="## "+O+`
36
+ `;f&&(C+=`License: ${f}
37
+ `);const Z=new Set;for(const T of[u,...$,...m]){const we=typeof T=="string"?T:T?.name;we&&Z.add(we)}return Z.size>0&&(C+=`By: ${[...Z].join(", ")}
38
+ `),y&&(C+=`Repository: ${typeof y=="string"?y:y.url}
39
+ `),b&&(C+=`
40
+ `+b.trim().replaceAll(/\r\n|\r/g,`
41
+ `).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
42
+ `).map(T=>T?`> ${T}`:">").join(`
43
+ `)+`
44
+ `),f&&l.add(f),C}).join(`
45
+ ---------------------------------------
46
+
47
+ `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const p=o(Tr(l),c,s);try{const u=Le(t),m=Ar(u,n,p);if(!m){r.error({message:`Could not find the license marker: <!-- ${n} --> in ${t}`,prefix:"plugin:license:"+i});return}u!==m&&(H(t,m),r.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(u){r.error(u)}}}),"license");var Jr=Object.defineProperty,Br=d((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"i$8");const Wr=Br(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const i of n.importedIds)t.push({source:r,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Wt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Lr=Object.defineProperty,zr=d((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$6");const I=zr(e=>{const t=mo("md5");return t.update(e),t.digest("hex")},"getHash");var Ur=Object.defineProperty,lt=d((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"m$6");const J=lt(e=>e.handler||e,"getHandler"),x=lt((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await J(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await J(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=h("load",I(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await J(e.load).call(this,o);return t.set(r,n,e.name),n},name:`cached(${e.name})`,async resolveId(o,r,n){if(!e.resolveId)return null;const i=h("resolveId",I(o),r?I(r):"",I(JSON.stringify(n)));if(t.has(i,e.name))return await t.get(i,e.name);const s=await J(e.resolveId).call(this,o,r,n);return t.set(i,s,e.name),s},async transform(o,r){if(!e.transform)return null;const n=h("transform",I(r),I(o));if(t.has(n,e.name))return await t.get(n,e.name);const i=await J(e.transform).call(this,o,r);return t.set(n,i,e.name),i}}),"cachingPlugin");var Vr=Object.defineProperty,Hr=d((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"c$6");const qr=/\.(?:m|c)?(?:j|t)sx?$/,Gr=/^use \w+$/,Yr=Hr(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(r,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,n,{sourcemap:i}){const s=n.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),a=new P(r);s.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...s].map(c=>`'${c}';`).join(`
48
+ `)}
49
+ `));let l=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(l=o[n.facadeModuleId]),l&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${l}
50
+ `)),s.size===0&&l===null?null:{code:a.toString(),map:i?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const i=ue(n);if(!qr.test(i))return null;let s=!1;const a=new P(r);if(r.startsWith("#")&&r[1]==="!"){let c=0;for(let p=2,u=r.length;p<u;p++){const m=r.codePointAt(p);if(m===10||m===13||m===8232||m===8233){c=p;break}}c&&(o[n]=r.slice(0,c),a.remove(0,c+1),s=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(c),null}if(l.type!=="Program")return null;for(const c of l.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let p=null;"directive"in c?p=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Gr.test(c.expression.value)&&(p=c.expression.value),p!=="use strict"&&p&&(t[n]||=new Set,t[n].add(p),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(a.remove(c.start,c.end),s=!0),e.debug({message:`directive "${p}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return s?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Kr=Object.defineProperty,Xr=d((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"r$5");const Zr={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Qr=Xr((e={})=>{e={...e,...Zr};const t=Y(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var en=Object.defineProperty,tn=d((e,t)=>en(e,"name",{value:t,configurable:!0}),"l$4");const oe="\0__file_url__",ct=tn(()=>({async load(e){if(e.startsWith(oe)){const t=Qt(e.slice(oe.length));return await ce(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${oe}${e}`}}),"resolveFileUrl");var on=Object.defineProperty,F=d((e,t)=>on(e,"name",{value:t,configurable:!0}),"r$4");const rn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,nn=/MIT License|MIT license|BSD license/,sn=/\n{2,}/g,an=/\b(\w+)\$\d+\b/g,ln=/[-/\\^$*+?.()|[\]{}]/g,cn=F(e=>e.replaceAll(ln,"\\$&"),"escapeRegex"),pn=F(e=>[...new Set(e)],"unique"),un=F(e=>e.replaceAll(rn,t=>nn.test(t)?"":t).replaceAll(sn,`
51
+
52
+ `),"cleanUnnecessaryComments"),Pe=new Map;function pt(e,t,{identifierReplacements:o},r){const n=qe(e);for(const s in o){const a=n.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const p=l[c],u=cn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const i=pn(Array.from(e.matchAll(an),s=>s[0]));if(i.length>0){const s=i.map(l=>`
53
+ - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Pe.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${s}
54
+
55
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Pe.set(a,!0)}return e}d(pt,"I$1");F(pt,"replaceConfusingTypeNames");function ut(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}d(ut,"N");F(ut,"removeInternal");function dt(e,t){if(e.includes("@internal")){const o=new P(e),r=fo(e,{plugins:["typescript"],sourceType:"module"});if(st(r,{enter(n){ut(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}d(dt,"S");F(dt,"stripInternalTypes");const dn=F((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=pt.call(this,o,r,e,t),o=dt.call(this,o,r),o=un(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var mn=Object.defineProperty,mt=d((e,t)=>mn(e,"name",{value:t,configurable:!0}),"u$6");const ft=mt((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:i}=o.compilerOptions;if(!n)return null;const s=g(de(r),n),a=[];if(i)for(const[l,c]of Object.entries(i)){const p=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of c){const f=[...Ee(g(s,m))].map(b=>b==="*"?"$"+(++u+""):b==="$"?"$$":b).join("");a.push({find:p,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Ee(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),gt=mt((e,t)=>{const o=ft(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,i){if(!o||r.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(r)){const l=r.replace(s,a),c=await this.resolve(l,n,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var fn=Object.defineProperty,ht=d((e,t)=>fn(e,"name",{value:t,configurable:!0}),"u$5");const gn=ht((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const i=[];for(const s of n){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);i.push(g(e,s))}return i},"getRootDirectories"),yt=ht((e,t,o)=>{const r=gn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,i,s){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=h(a,n),c=await this.resolve(l,i,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var hn=Object.defineProperty,yn=d((e,t)=>hn(e,"name",{value:t,configurable:!0}),"r$3");const vt=yn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var vn=Object.defineProperty,bn=d((e,t)=>vn(e,"name",{value:t,configurable:!0}),"s$8");const $n=bn(e=>{const t=G(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(A.includes(r)&&i&&i.length>0)return n+"-"+i}},"getCustomModuleLayer");var wn=Object.defineProperty,jn=d((e,t)=>wn(e,"name",{value:t,configurable:!0}),"i$4");const re=jn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var kn=Object.defineProperty,Ce=d((e,t)=>kn(e,"name",{value:t,configurable:!0}),"c$4");const Me=Ce((e,t)=>{const o=new Map;return Ce(function(r,n){const i=n.getModuleInfo(r);if(!i)return;const{isEntry:s}=i,a=i.meta,l=re(a);if(!s){const c=o.get(r);if(c)return c;const p=$n(r);if(p)return o.set(r,p),p}if(s){const c=n.getModuleIds();for(const p of c)n.getModuleInfo(p)&&re(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,l]))}if(l&&!s&&e.has(r)){const c=[...e.get(r)];if(c.some(([u])=>{if(t.some(m=>m.path===u)){const m=n.getModuleInfo(u);return re(m?m.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(r)?o.get(r):void 0;const p=`${G(r,ue(r))}-${l}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var xn=Object.defineProperty,En=d((e,t)=>xn(e,"name",{value:t,configurable:!0}),"n");const _=En((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var On=Object.defineProperty,Dn=d((e,t)=>On(e,"name",{value:t,configurable:!0}),"s$6");const Sn=process.platform==="win32",Ie=Dn((e,t)=>{const o=Sn?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Nn=Object.defineProperty,w=d((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"p$2");const _n=w((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+Pt.node.split(".")[0];if(t.pkg.engines?.node){const r=Xe(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=te(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...te(o),...r])])}else t.options.rollup.esbuild.target=te(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),bt=w((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v(S(g(),e.id))}"
56
+ Is the module installed? Note:
57
+ ↳ to inline a module into your bundle, install it to "devDependencies".
58
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Re=new Map,$t=w((e,t,o)=>{const r=w(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),n=ft(e.tsconfig,!1);return{external(i){const s=r(i);s&&(i=s);const a=ot(i);if(le(e.options.externals,a)||le(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||Ve(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name)||l?.imports?.[i]!==void 0)return!1;if(n){for(const{find:c}of n)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return Re.has(i)||e.logger.info({message:'Inlined implicit external "'+v(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Re.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,g(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
59
+ ${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){bt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),wt=w(async(e,t)=>{const o=ge(e,"build");let r;return e.options.rollup.resolve&&(r=x(Be({extensions:A,...e.options.rollup.resolve}),t)),{...$t(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:w(n=>_(e,n,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>Ie(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:w(n=>_(e,n,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>Ie(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(ct(),t),x(vt(),t),e.tsconfig&&x(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ye({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&so({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&it({...e.options.rollup.json}),Yr(e.logger),So(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&io(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Sr(h(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(_n(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&nt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Or(),e.options.rollup.dynamicVars&&no(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(ro({extensions:A,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&kr(e.pkg),e.options.rollup.raw&&Qr(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Rr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Wr({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&yr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&at({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ao({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Pn=w(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Cn=dr(Pn),jt=w(async(e,t)=>{const o=ge(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let i;e.options.rollup.resolve&&(i=x(Be({extensions:A,...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...$t(e,o,"dts"),onwarn(a,l){bt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:w(a=>_(e,a,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:w(a=>_(e,a,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:w(a=>_(e,a,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(ct(),t),x(vt(),t),e.options.rollup.json&&it({...e.options.rollup.json}),r,e.tsconfig&&x(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ye({customResolver:i,...e.options.rollup.alias,entries:o}),i,await Cn(s)(e),e.options.cjsInterop&&e.options.emitCJS&&nt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&dn(e.options.rollup.patchTypes,e.logger),No(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&at({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Mn=Object.defineProperty,In=d((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"c$3");const ne=In(async(e,t)=>{const o=await wt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-build.json";o.cache=t.get(r);const n=await He(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const s of o.output){const{output:a}=await n.write(s),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>c.find(f=>f.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,f])=>({bytes:f.renderedLength,id:m})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of l)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var Rn=Object.defineProperty,U=d((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"s$5");const ie=U(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await jt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-dts.json";o.cache=t.get(r);const n=await He(o);t.set(r,n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:U(i=>_(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:U(i=>_(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:U(i=>_(e,i,"d.mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Fn=Object.defineProperty,be=d((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"i$2");const Tn=be(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
60
+ `;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),An=be(e=>`
61
+ ${e.replaceAll(/^\n|\n$/g,"")}
62
+ `,"normalizeCodeFrame"),kt=be(e=>{const t=Tn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
63
+ file: ${v(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
64
+ `+Tt(An(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
65
+ ${t}`)},"enhanceRollupError");var Jn=Object.defineProperty,xt=d((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"l$3");const Fe=xt((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:i})=>{o.info({message:`${v(S(".",n))} was ${i}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",async n=>{switch(n.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:r});break}case"BUNDLE_START":{o.info({message:v("build started..."),prefix:r});break}case"BUNDLE_END":{await n.result.close(),o.info({message:v(`built in ${n.duration+""}ms.`),prefix:r});break}case"ERROR":{kt(n.error),o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r});break}}})},"watchHandler"),Bn=xt(async(e,t)=>{const o=await wt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[h(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const r=xe(o);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of n)i+=R(`
66
+ └─ ${S(process.cwd(),s)}`);if(e.logger.info(i),Fe(r,"bundle",e.logger),e.options.declaration){const s=await jt(e,t);await e.hooks.callHook("rollup:dts:options",e,s);const a=xe(s);await e.hooks.callHook("rollup:watch",e,a),Fe(a,"types",e.logger)}},"watch");var Wn=Object.defineProperty,Ln=d((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"i$1");const Et=Ln(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var zn=Object.defineProperty,Un=d((e,t)=>zn(e,"name",{value:t,configurable:!0}),"a$4");let Vn=class{static{d(this,"p")}static{Un(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#i;constructor(t,o,r){this.#r=t,this.#e=go("@visulima/packem",{cwd:t}),this.#n=o,this.#i=r,this.#e===void 0?r.debug("Could not create cache directory."):r.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:E(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!E(r))return;const n=Le(r);try{const i=JSON.parse(n);return this.#o.set(r,i),i}catch{this.#i.warn(`Could not parse cache file: ${r}, deleting the broken cache file.`),this.#o.delete(r),oo(r,{force:!0});return}}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),H(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(ke(this.#r),"");return r=r.replaceAll(":","-"),h(this.#e,this.#n,o?.replaceAll(":","-")??"",ke(r))}};var Hn=Object.defineProperty,V=d((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"l$2");const qn=Y,Gn=V((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=V(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=V(()=>!1,"hasSideEffects");else{const n=o.map(i=>i.includes("/")?i:`**/${i}`);r=qn(n,null,{resolve:e})}else r=V(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Yn=Object.defineProperty,Kn=d((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"y");const Xn=Kn((e,t,o)=>e.reduce((r,n)=>{const i=n[t],s=n[o];return r[i]||(r[i]={}),r[i][s]||(r[i][s]=[]),r[i][s].push(n),r},{}),"groupByKeys");var Zn=Object.defineProperty,Qn=d((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"a$3");const ei=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,ti=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Te=Qn(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(ei.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(ti.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=g(o);if(!E(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var oi=Object.defineProperty,ri=d((e,t)=>oi(e,"name",{value:t,configurable:!0}),"o");const ni=ri(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),r=new Set;for(const n of e.usedImports)o.delete(n),t.add(n);if(e.pkg.dependencies)for(const n of Object.keys(e.pkg.dependencies))o.delete(n);for(const n of t){const i=ot(n);!le(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg.dependencies?.[i]===void 0&&e.pkg.peerDependencies?.[i]===void 0&&r.add(n)}o.size>0&&W(e,`Potential unused dependencies found: ${[...o].map(n=>v(n)).join(", ")}`),r.size>0&&W(e,`Potential implicit dependencies found: ${[...r].map(n=>v(n)).join(", ")}`)},"validateDependencies");var ii=Object.defineProperty,Ot=d((e,t)=>ii(e,"name",{value:t,configurable:!0}),"i");const si=Ot((e,t)=>ho(e,t)<=e.length/3||t.includes(e),"isSimilar"),ai=Ot((e,t)=>{const o=e.toLowerCase();return t.filter(r=>si(r.toLowerCase(),o))},"findAlternatives");var li=Object.defineProperty,Ae=d((e,t)=>li(e,"name",{value:t,configurable:!0}),"s");const ci=Ae((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...he(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&g(t.options.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!me(n)&&r.push(n.replace(`${t.options.rootDir}/`,""));if(r.length>0){const n=Ae(a=>S(t.options.rootDir,g(t.options.outDir,a)),"rPath"),i=t.buildEntries.filter(a=>!a.chunk).map(a=>n(a.path));let s="Potential missing or wrong package.json files:";for(const a of r){const l=ai(a,i);s+=`
67
+ - `+v(a)+(l.length>0?At` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}W(t,s)}},"validatePackage");var pi=Object.defineProperty,k=d((e,t)=>pi(e,"name",{value:t,configurable:!0}),"h$1");const Dt=k((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
68
+ `),e.logger.warn(`Build is done with some warnings:
69
+
70
+ ${[...e.warnings].map(o=>`- ${o}`).join(`
71
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),ui=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),di=k((e,t,o,r,n,i,s,a,l)=>{const c=ui(l?.config.compilerOptions?.jsx),p=Yt(i,n,s,{alias:{},clean:!0,debug:r,declaration:!0,emitCJS:!0,emitESM:!0,entries:[],externals:[...je.builtinModules,...je.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:j.production==="production",name:(a.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:ee,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:k((u,m,f)=>`
72
+ # Licenses of bundled dependencies
73
+ The published ${f} artifact additionally contains code with the following licenses:
74
+ `+(u.length>0?`${u.join(", ")}
75
+
76
+ `:`
77
+ `)+`# Bundled dependencies:
78
+ `+m,"dependenciesTemplate"),dtsTemplate:k((u,m,f)=>`
79
+ # Licenses of bundled types
80
+ The published ${f} artifact additionally contains code with the following licenses:
81
+ `+(u.length>0?`${u.join(", ")}
82
+
83
+ `:`
84
+ `)+`# Bundled types:
85
+ `+m,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ee,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:j.production===D,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:j.production!==D,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Gn(t,a),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ee}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let m="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",m=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",m=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",m=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+v("rollup ")+Xt),e.info({message:"Using "+v(p.transformerName)+" "+m,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.devDependencies?.typescript&&!l?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
86
+ Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
87
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),a.dependencies&&p.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&p.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&p.externals.push(...Object.keys(a.optionalDependencies)),Te(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Te(p.rollup.alias.entries),p},"generateOptions"),mi=k(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),fi=k(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let r=Ve(o.input)?S(t,o.input):pe(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=mi(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Et(o)}`);if(o.input=g(e.options.rootDir,o.input),!E(o.input)){const r=new Set(await Ft(de(o.input)));let n=!1;for(const i of A)if(r.has(G(o.input)+i)){n=!0;break}if(!n)throw new Vt("Your configured entry: "+v(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),gi=k((e,t,o)=>{const r=k(i=>S(t.options.rootDir,g(t.options.outDir,i)),"rPath");let n=!1;for(const i of t.buildEntries.filter(s=>!s.chunk)){let s=i.bytes??0;for(const l of i.chunks??[])s+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let a=` ${N(r(i.path))} (${["total size: "+v(M(s)),i.type!=="asset"&&i.bytes&&"chunk size: "+v(M(i.bytes))].filter(Boolean).join(", ")})`;if(a+=i.exports?.length?`
88
+ exports: `+R(i.exports.join(", ")):"",i.chunks?.length&&(a+=`
89
+ ${i.chunks.map(l=>{const c=t.buildEntries.find(p=>p.path===l)??{};return R(" └─ "+r(l)+N(c.bytes?" ("+M(c?.bytes)+")":""))}).join(`
90
+ `)}`),i.modules&&i.modules.length>0){const l=i.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>R(" 📦 "+r(c.id)+N(c.bytes?" ("+M(c.bytes)+")":""))).join(`
91
+ `);a+=l.length>0?`
92
+ inlined modules:
93
+ `+l:""}if(t.options.declaration&&i.type==="entry"){let l=i.path.replace(/\.js$/,".d.ts"),c="commonjs";i.path.endsWith(".cjs")?l=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(c="module",l=i.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(l));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(m=>m.path.endsWith(l))),a+=u&&c===o.type?`
94
+ types:
95
+ `+[p,u].map(m=>R(" └─ ")+N(r(m.path))+" (total size: "+v(M(m.bytes??0))+")").join(`
96
+ `):`
97
+ types: `+N(r(p.path))+" (total size: "+v(M(p.bytes??0))+")"}}n=!0,a+=`
98
+
99
+ `,e.raw(i.chunk?R(a):a)}return n&&e.raw("Σ Total dist size (byte size):",v(M(t.buildEntries.reduce((i,s)=>i+(s.bytes??0),0))),`
100
+ `),n},"showSizeInformation"),hi=k(async(e,t,o,r,n,i,s,a)=>{const l=rr(i.preset??n.preset??"auto",t),c=di(e,t,o,r,n,i,l,s,a);Lt(h(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Kt(),logger:e,mode:o,options:c,pkg:s,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),n.hooks&&p.hooks.addHooks(n.hooks),i.hooks&&p.hooks.addHooks(i.hooks),await p.hooks.callHook("build:prepare",p),!p.options.emitESM&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled."),p.options.declaration&&a===void 0&&s.devDependencies?.typescript)throw new Error(" Cannot build declaration files without a tsconfig.json");return s.devDependencies?.typescript||(p.options.declaration=!1),p.options.declaration||p.logger.info("Declaration files, are disabled."),p},"createContext"),yi=k(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${S(e.options.rootDir,o)}\``),await ze(o))},"cleanDistributionDirectories"),vi=k(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=Xn(e.options.entries,"environment","runtime"),n=[];for(const[s,a]of Object.entries(r))for(const[l,c]of Object.entries(a)){e.logger.info("Preparing build for "+v(s)+" environment"+(l?" with "+v(l)+" runtime":"")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:s},l==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime="edge-runtime")):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const p=[],u=[],m=[];for(const f of c)f.cjs&&f.esm?p.push(f):f.cjs?m.push(f):f.esm&&u.push(f);if(p.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:p}};n.push(ne(f,o));const b=f.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&n.push(ie({...f,options:{...f.options,entries:b}},o))}if(u.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:u}};n.push(ne(f,o));const b=f.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&n.push(ie({...f,options:{...f.options,entries:b}},o))}if(m.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:m}};n.push(ne(f,o));const b=f.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&n.push(ie({...f,options:{...f.options,entries:b}},o))}}await Promise.all(n),e.logger.success(Jt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of zt(h(e.options.rootDir,e.options.outDir))){let a=e.buildEntries.find(l=>h(e.options.rootDir,e.options.outDir,l.path)===s.path);if(a||(a={chunk:!0,path:s.path},e.buildEntries.push(a)),!a.bytes){const l=await We(g(e.options.rootDir,e.options.outDir,s.path));a.bytes=l.size}}const i=gi(e.logger,e,t);ni(e),ci(t,e),await e.hooks.callHook("build:done",e),Dt(e,i)},"build"),bi=k(async(e,t,o,r={})=>{const{configPath:n,debug:i,tsconfigPath:s,...a}=r;o.wrapAll(),e=g(Ct(),e),o.debug("Root directory:",e);const l=h(e,"package.json");if(!E(l))throw new Error("package.json not found at "+l);const c=Ue(l);o.debug("Using package.json found at",l);let p;if(s){const u=h(e,s);if(!await Ut(u))throw new Error("tsconfig.json not found at "+u);p={config:qt(u),path:u},o.info("Using tsconfig settings at",u)}else if(c.devDependencies?.typescript)try{p=await Gt(e),o.debug("Using tsconfig settings found at",p.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}try{const u=n??"./packem.config.ts";if(!/\.(?:js|mjs|cjs|ts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed.");const m=Qe(u,e);o.debug("Using packem config found at",h(e,u));const f=Date.now(),b=k(()=>Ht(Math.floor(Date.now()-f)),"getDuration"),$=I(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types})),O=new Vn(e,$,o);O.cachePath&&!E(h(O.cachePath,$))&&E(O.cachePath)&&(o.info("Clearing file cache because the cache key has changed."),await ze(O.cachePath));const y=await hi(o,e,t,i??!1,a,m,c,p);if(O.isEnabled=y.options.fileCache,await fi(y,e),y.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+y.options.name)),y.logger.debug(`${N("Root dir:")} ${y.options.rootDir}
101
+ ${N("Entries:")}
102
+ ${y.options.entries.map(C=>` ${Et(C)}`).join(`
103
+ `)}`),await yi(y),y.options.stub){await Bo(y),await y.hooks.callHook("build:done",y);return}if(t==="watch"){if(y.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Bn(y,O),Dt(y,!1);return}await vi(y,c,O),o.raw(`
104
+ ⚡️ Build run in `+b()),o.restoreAll()}catch(u){throw o.raw(`
105
+ `),kt(u),u}},"createBundler");var $i=Object.defineProperty,se=d((e,t)=>$i(e,"name",{value:t,configurable:!0}),"a");const wi=se(e=>{e.addCommand({description:"Demonstrate options required",execute:se(async({logger:t,options:o})=>{let r="build";o.watch?r="watch":o.jit&&(r="jit");const n={};if(j.production&&[B,D].includes(j.production)&&(n.NODE_ENV=j.production),o.env)for(const i of o.env){if(i.key==="production"&&n.production)throw new Error("production was already set, this can't be overridden.");n[i.key]=i.value}n.production===void 0&&(o.production?n.NODE_ENV=D:o.development?n.NODE_ENV=B:n.NODE_ENV=D,j.NODE_ENV=n.production);try{await bi(o.dir,r,t,{cjsInterop:o.cjsInterop,configPath:o.config??void 0,debug:o.debug,minify:o.minify===void 0?j.production===D:o.minify,replace:{...n},rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,...o.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:o.sourcemap,tsconfigPath:o.tsconfig??void 0})}catch(i){t.error(i),Mt(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:se(t=>{const[o,r]=t.split("=");return{key:o,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean}]})},"createBuildCommand");var ji=Object.defineProperty,Je=d((e,t)=>ji(e,"name",{value:t,configurable:!0}),"m");const ki=Je(e=>{e.addCommand({description:"Initialize packem configuration",execute:Je(async({logger:t,options:o})=>{if(vo("Welcome to packem setup"),E(h(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(bo(o.transformer)){$o("Operation cancelled");return}const r=h(o.dir,"package.json");if(!E(r))throw new Error("No package.json found in the directory");const n=Ue(r),i=[];if(n.dependencies&&i.push(...Object.keys(n.dependencies)),n.devDependencies&&i.push(...Object.keys(n.devDependencies)),o.transformer===void 0&&(o.transformer=await wo({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!i.includes(o.transformer)&&await jo({message:"Do you want to install "+o.transformer+"?"}))){const s=Q();s.start("Installing "+o.transformer),await yo(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),s.stop("")}if(i.includes("typescript")||n.type==="module"){const s=`import { defineConfig } from "@visulima/packem/config";
106
+ import transformer from "@visulima/packem/transformer/${o.transformer}";
107
+
108
+ export default defineConfig({
109
+ transformer
110
+ });
111
+ `,a=Q(),l=n.type==="module"?"mjs":"ts";a.start("Creating packem.config."+l),H(h(o.dir,"packem.config."+l),s),a.stop("Created packem.config."+l)}else{const s=`const { defineConfig } = require("@visulima/packem/config");
112
+ const transformer = require("@visulima/packem/transformer/${o.transformer}");
113
+
114
+ module.exports = defineConfig({
115
+ transformer
116
+ });
117
+ `,a=Q();a.start("Creating packem.config.js"),H(h(o.dir,"packem.config.js"),s),a.stop("Created packem.config.js")}ko("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),$e=new Nt("packem",{logger:{reporters:[new _t({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:xo,packageVersion:Eo});ki($e);wi($e);$e.run({shouldExitProcess:!1});
package/dist/config.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var r=(e,i)=>f(e,"name",{value:i,configurable:!0});var t=Object.defineProperty,n=r((e,i)=>t(e,"name",{value:i,configurable:!0}),"i");const a=n(e=>(Array.isArray(e)?e:[e]).filter(Boolean),"defineConfig"),o=n(e=>e,"definePreset");exports.defineConfig=a,exports.definePreset=o;
1
+ "use strict";var f=Object.defineProperty;var n=(e,i)=>f(e,"name",{value:i,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=Object.defineProperty,t=n((e,i)=>r(e,"name",{value:i,configurable:!0}),"i");const o=t(e=>e,"defineConfig"),d=t(e=>e,"definePreset");exports.defineConfig=o;exports.definePreset=d;