@visulima/packem 1.0.0-alpha.9 → 1.0.0-alpha.91

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 (67) hide show
  1. package/CHANGELOG.md +574 -0
  2. package/LICENSE.md +40 -40
  3. package/README.md +26 -6
  4. package/dist/cli.cjs +15 -1
  5. package/dist/cli.mjs +17 -1
  6. package/dist/config.cjs +1 -1
  7. package/dist/config.d.cts +9 -6
  8. package/dist/config.d.mts +9 -6
  9. package/dist/config.mjs +1 -1
  10. package/dist/create-bundler.cjs +79 -72
  11. package/dist/create-bundler.d.cts +7 -6
  12. package/dist/create-bundler.d.mts +7 -6
  13. package/dist/create-bundler.mjs +83 -70
  14. package/dist/rollup/plugins/esbuild/index.cjs +1 -1
  15. package/dist/rollup/plugins/esbuild/index.d.cts +1 -1
  16. package/dist/rollup/plugins/esbuild/index.d.mts +1 -1
  17. package/dist/rollup/plugins/esbuild/index.mjs +2 -8
  18. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.cjs +1 -0
  19. package/dist/{create-bundler.d.ts → rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.cts} +7 -10
  20. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +26 -0
  21. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.mjs +1 -0
  22. package/dist/rollup/plugins/sucrase/index.cjs +1 -1
  23. package/dist/rollup/plugins/sucrase/index.d.cts +1 -1
  24. package/dist/rollup/plugins/sucrase/index.d.mts +1 -1
  25. package/dist/rollup/plugins/sucrase/index.mjs +1 -1
  26. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.cjs +1 -0
  27. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.cts +26 -0
  28. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +26 -0
  29. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.mjs +1 -0
  30. package/dist/rollup/plugins/swc/swc-plugin.cjs +1 -0
  31. package/dist/rollup/plugins/swc/{index.d.ts → swc-plugin.d.cts} +1 -1
  32. package/dist/rollup/plugins/swc/{index.d.cts → swc-plugin.d.mts} +1 -1
  33. package/dist/rollup/plugins/swc/swc-plugin.mjs +1 -0
  34. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.cjs +1 -0
  35. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.cts +27 -0
  36. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +27 -0
  37. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.mjs +1 -0
  38. package/dist/shared/constants-DcRh98q_.mjs +1 -0
  39. package/dist/shared/constants-lwnJ_PjR.cjs +1 -0
  40. package/dist/shared/resolve-file-BcJmI4Tm.mjs +1 -0
  41. package/dist/shared/resolve-file-DUZi_m4G.cjs +1 -0
  42. package/dist/shared/{packem.aHRI8QbF.d.ts → types-CqOiWvwZ.d.cts} +48 -18
  43. package/dist/shared/{packem.C44tLE3n.d.cts → types-CzGE8V_d.d.cts} +34 -2
  44. package/dist/shared/{packem.C44tLE3n.d.mts → types-CzGE8V_d.d.mts} +34 -2
  45. package/dist/shared/{packem.CAQMZ6ex.d.mts → types-DRxO9m8T.d.mts} +48 -18
  46. package/dist/shared/{packem.D09xRBAa.d.ts → types-Db-Z_7e-.d.cts} +1 -1
  47. package/dist/shared/{packem.D09xRBAa.d.cts → types-Db-Z_7e-.d.mts} +1 -1
  48. package/package.json +135 -82
  49. package/dist/cli.d.cts +0 -2
  50. package/dist/cli.d.mts +0 -2
  51. package/dist/cli.d.ts +0 -2
  52. package/dist/config.d.ts +0 -27
  53. package/dist/rollup/plugins/esbuild/index.d.ts +0 -9
  54. package/dist/rollup/plugins/sucrase/index.d.ts +0 -8
  55. package/dist/rollup/plugins/swc/index.cjs +0 -1
  56. package/dist/rollup/plugins/swc/index.d.mts +0 -7
  57. package/dist/rollup/plugins/swc/index.mjs +0 -1
  58. package/dist/shared/packem.Bdmp1hC5.mjs +0 -1
  59. package/dist/shared/packem.Bj4QPFg7.mjs +0 -1
  60. package/dist/shared/packem.C44tLE3n.d.ts +0 -1919
  61. package/dist/shared/packem.CEXB7aOL.cjs +0 -1
  62. package/dist/shared/packem.D09xRBAa.d.mts +0 -25
  63. package/dist/shared/packem.DZfoF9Bk.d.cts +0 -176
  64. package/dist/shared/packem.DvWhOdt5.d.ts +0 -10
  65. package/dist/shared/packem.uvB0cQX0.cjs +0 -1
  66. /package/dist/shared/{packem.DvWhOdt5.d.cts → types-DvWhOdt5.d.cts} +0 -0
  67. /package/dist/shared/{packem.DvWhOdt5.d.mts → types-DvWhOdt5.d.mts} +0 -0
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,20 +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
53
+
54
+ ```bash
55
+ packem init [options]
56
+ ```
57
+
58
+ ### Bundle files
45
59
 
60
+ ```bash
61
+ packem build [options]
46
62
  ```
47
63
 
64
+ > This will write the files into the `./dist` folder.
65
+
48
66
  Links:
49
- - https://github.com/frehner/modern-guide-to-packaging-js-library#set-the-main-field
67
+
68
+ - https://github.com/frehner/modern-guide-to-packaging-js-library#set-the-main-field
50
69
 
51
70
  ## Related
52
71
 
53
72
  - [bunchee](https://github.com/huozhi/bunchee) - Zero config bundler for ECMAScript and TypeScript packages
54
73
  - [unbuild](https://github.com/unjs/unbuild) - 📦 An unified javascript build system
55
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
56
76
  - [tsup](https://github.com/egoist/tsup) - The simplest and fastest way to bundle your TypeScript libraries
57
77
 
58
78
  ## Supported Node.js Versions
@@ -77,7 +97,7 @@ The visulima pack is open-sourced software licensed under the [MIT][license-url]
77
97
 
78
98
  [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
79
99
  [typescript-url]: "typescript"
80
- [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
81
101
  [license-url]: LICENSE.md "license"
82
- [npm-image]: https://img.shields.io/npm/v/@visulima/pack/latest.svg?style=for-the-badge&logo=npm
83
- [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.cjs CHANGED
@@ -1,2 +1,16 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var s=Object.defineProperty;var a=(t,e)=>s(t,"name",{value:e,configurable:!0});const l=require("node:process"),p=require("@visulima/cerebro"),u=require("./create-bundler.cjs");function m(t){return t&&typeof t=="object"&&"default"in t?t.default:t}a(m,"_interopDefaultCompat");const d=m(p),f="@visulima/packem",y="1.0.0-alpha.8";var g=Object.defineProperty,o=a((t,e)=>g(t,"name",{value:e,configurable:!0}),"n");const h=o(t=>{t.addCommand({description:"Demonstrate options required",execute:o(async({options:e})=>{let n="build";e.watch?n="watch":e.jit&&(n="jit");const i={};if(e.env)for(const c of e.env)i[c.key]=c.value;await u(e.dir,n,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...i},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:o(e=>{const[n,i]=e.split("=");return{key:n,value:i}},"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"),r=new d("packem",{packageName:f,packageVersion:y});h(r),r.setDefaultCommand("build"),r.run().catch(t=>{console.error(t.message),l.exit(1)});
2
+ "use strict";var w=Object.defineProperty;var d=(r,i)=>w(r,"name",{value:i,configurable:!0});const h=require("@visulima/cerebro"),b=require("@visulima/pail/reporter"),p=require("node:process"),l=require("./shared/constants-lwnJ_PjR.cjs"),E=require("./create-bundler.cjs"),v=require("@antfu/install-pkg"),o=require("@clack/prompts"),m=require("@visulima/fs"),D=require("@visulima/package/package-json"),u=require("@visulima/path"),j=d(r=>r&&typeof r=="object"&&"default"in r?r.default:r,"_interopDefaultCompat"),N=j(h),C="@visulima/packem",O="1.0.0-alpha.90";var V=Object.defineProperty,g=d((r,i)=>V(r,"name",{value:i,configurable:!0}),"a");const P=g(r=>{r.addCommand({description:"Demonstrate options required",execute:g(async({logger:i,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const a={};let n;if(p.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(p.env.NODE_ENV)&&(n=p.env.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(n)throw new Error("NODE_ENV was already set, this can't be overridden.");n=t.value}else a["process.env."+t.key]=JSON.stringify(t.value);n===void 0&&(e.production?n=l.PRODUCTION_ENV:e.development&&(n=l.DEVELOPMENT_ENV));try{await E(e.dir,s,n,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?n===l.PRODUCTION_ENV:e.minify,replace:{...a},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})}catch(t){i.error(t),p.exit(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:g(i=>{const[e,s]=i.split("=");return{key:e,value:s}},"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},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var T=Object.defineProperty,k=d((r,i)=>T(r,"name",{value:i,configurable:!0}),"m");const x=k(r=>{r.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(o.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(o.isCancel(e.transformer)){o.cancel("Operation cancelled");return}const s=u.join(e.dir,"package.json");if(!m.isAccessibleSync(s))throw new Error("No package.json found in the directory");const a=D.parsePackageJson(s),n=[];if(a.dependencies&&n.push(...Object.keys(a.dependencies)),a.devDependencies&&n.push(...Object.keys(a.devDependencies)),e.transformer===void 0&&(e.transformer=await o.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!n.includes(e.transformer)&&await o.confirm({message:"Do you want to install "+e.transformer+"?"}))){const t=o.spinner();t.start("Installing "+e.transformer),await v.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await o.select({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let t;switch(e.isolatedDeclarationTransformer){case"typescript":{t="typescript";break}case"swc":{t="@swc/core";break}case"oxc":{t="oxc-transform";break}default:o.cancel("Invalid isolated declaration transformer")}if(t&&!n.includes(t)&&await o.confirm({message:"Do you want to install "+t+"?"})){const c=o.spinner();c.start("Installing "+e.isolatedDeclarationTransformer),await v.installPackage(t,{cwd:e.dir,dev:!0,silent:!0}),c.stop("")}}if(n.includes("typescript")||a.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
3
+ import transformer from "@visulima/packem/transformer/${e.transformer}";
4
+ ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
5
+ `}
6
+ export default defineConfig({
7
+ transformer${e.isolatedDeclarationTransformer===null?"":`,
8
+ isolatedDeclarationTransformer`}
9
+ });
10
+ `,c=o.spinner(),f=a.type==="module"?"mjs":"ts";c.start("Creating packem.config."+f),m.writeFileSync(u.join(e.dir,"packem.config."+f),t),c.stop("Created packem.config."+f)}else{const t=`const { defineConfig } = require("@visulima/packem/config");
11
+ const transformer = require("@visulima/packem/transformer/${e.transformer}");
12
+
13
+ module.exports = defineConfig({
14
+ transformer
15
+ });
16
+ `,c=o.spinner();c.start("Creating packem.config.js"),m.writeFileSync(u.join(e.dir,"packem.config.js"),t),c.stop("Created packem.config.js")}o.outro("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",name:"transformer",type:String},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:String}]})},"createInitCommand"),y=new N("packem",{logger:{reporters:[new b.SimpleReporter({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:C,packageVersion:O});x(y);P(y);y.run({shouldExitProcess:!1});
package/dist/cli.mjs CHANGED
@@ -1,2 +1,18 @@
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.8";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 E=Object.defineProperty;var p=(a,t)=>E(a,"name",{value:t,configurable:!0});import C from"@visulima/cerebro";import{SimpleReporter as N}from"@visulima/pail/reporter";import{env as d,exit as V}from"node:process";import{b as y,P as f}from"./shared/constants-DcRh98q_.mjs";import x from"./create-bundler.mjs";import{installPackage as v}from"@antfu/install-pkg";import{intro as O,isCancel as T,cancel as w,select as h,confirm as k,spinner as c,outro as P}from"@clack/prompts";import{isAccessibleSync as b,writeFileSync as j}from"@visulima/fs";import{parsePackageJson as S}from"@visulima/package/package-json";import{join as l}from"@visulima/path";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
+ const require = __cjs_mod__.createRequire(import.meta.url);
4
+ const B="@visulima/packem",I="1.0.0-alpha.90";var z=Object.defineProperty,u=p((a,t)=>z(a,"name",{value:t,configurable:!0}),"a");const _=u(a=>{a.addCommand({description:"Demonstrate options required",execute:u(async({logger:t,options:e})=>{let n="build";e.watch?n="watch":e.jit&&(n="jit");const i={};let o;if(d.NODE_ENV&&[y,f].includes(d.NODE_ENV)&&(o=d.NODE_ENV),e.env)for(const r of e.env)if(r.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=r.value}else i["process.env."+r.key]=JSON.stringify(r.value);o===void 0&&(e.production?o=f:e.development&&(o=y));try{await x(e.dir,n,o,t,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===f:e.minify,replace:{...i},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})}catch(r){t.error(r),V(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:u(t=>{const[e,n]=t.split("=");return{key:e,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},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean}]})},"createBuildCommand");var $=Object.defineProperty,D=p((a,t)=>$(a,"name",{value:t,configurable:!0}),"m");const J=D(a=>{a.addCommand({description:"Initialize packem configuration",execute:D(async({logger:t,options:e})=>{if(O("Welcome to packem setup"),b(l(e.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(T(e.transformer)){w("Operation cancelled");return}const n=l(e.dir,"package.json");if(!b(n))throw new Error("No package.json found in the directory");const i=S(n),o=[];if(i.dependencies&&o.push(...Object.keys(i.dependencies)),i.devDependencies&&o.push(...Object.keys(i.devDependencies)),e.transformer===void 0&&(e.transformer=await h({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await k({message:"Do you want to install "+e.transformer+"?"}))){const r=c();r.start("Installing "+e.transformer),await v(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),r.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let r;switch(e.isolatedDeclarationTransformer){case"typescript":{r="typescript";break}case"swc":{r="@swc/core";break}case"oxc":{r="oxc-transform";break}default:w("Invalid isolated declaration transformer")}if(r&&!o.includes(r)&&await k({message:"Do you want to install "+r+"?"})){const s=c();s.start("Installing "+e.isolatedDeclarationTransformer),await v(r,{cwd:e.dir,dev:!0,silent:!0}),s.stop("")}}if(o.includes("typescript")||i.type==="module"){const r=`import { defineConfig } from "@visulima/packem/config";
5
+ import transformer from "@visulima/packem/transformer/${e.transformer}";
6
+ ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
7
+ `}
8
+ export default defineConfig({
9
+ transformer${e.isolatedDeclarationTransformer===null?"":`,
10
+ isolatedDeclarationTransformer`}
11
+ });
12
+ `,s=c(),m=i.type==="module"?"mjs":"ts";s.start("Creating packem.config."+m),j(l(e.dir,"packem.config."+m),r),s.stop("Created packem.config."+m)}else{const r=`const { defineConfig } = require("@visulima/packem/config");
13
+ const transformer = require("@visulima/packem/transformer/${e.transformer}");
14
+
15
+ module.exports = defineConfig({
16
+ transformer
17
+ });
18
+ `,s=c();s.start("Creating packem.config.js"),j(l(e.dir,"packem.config.js"),r),s.stop("Created packem.config.js")}P("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",name:"transformer",type:String},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:String}]})},"createInitCommand"),g=new C("packem",{logger:{reporters:[new N({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:B,packageVersion:I});J(g);_(g);g.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 r=Object.defineProperty;var i=(e,n)=>r(e,"name",{value:n,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=Object.defineProperty,f=i((e,n)=>t(e,"name",{value:n,configurable:!0}),"e");const o=f(e=>e,"defineConfig"),d=f(e=>e,"definePreset");exports.defineConfig=o;exports.definePreset=d;
package/dist/config.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, a as BuildPreset } from './shared/packem.DZfoF9Bk.cjs';
2
- export { b as BuildHooks } from './shared/packem.DZfoF9Bk.cjs';
1
+ import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/types-CqOiWvwZ.cjs';
2
+ export { b as BuildHooks } from './shared/types-CqOiWvwZ.cjs';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -9,19 +9,22 @@ import '@rollup/plugin-wasm';
9
9
  import '@rollup/pluginutils';
10
10
  import '@visulima/package';
11
11
  import '@visulima/pail';
12
+ import '@visulima/tsconfig';
12
13
  import 'hookable';
13
14
  import 'jiti';
14
15
  import 'rollup';
15
16
  import 'rollup-plugin-dts';
16
17
  import 'rollup-plugin-polyfill-node';
17
18
  import 'rollup-plugin-visualizer';
18
- import './shared/packem.D09xRBAa.cjs';
19
+ import './shared/types-Db-Z_7e-.cjs';
19
20
  import 'esbuild';
20
- import './shared/packem.DvWhOdt5.cjs';
21
+ import './shared/types-DvWhOdt5.cjs';
21
22
  import 'sucrase';
22
- import './shared/packem.C44tLE3n.cjs';
23
+ import './shared/types-CzGE8V_d.cjs';
23
24
 
24
- declare const defineConfig: (config: BuildConfig | BuildConfig[]) => BuildConfig[];
25
+ type BuildConfigFunction = (enviroment: Environment, mode: Mode) => BuildConfig;
26
+
27
+ declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
25
28
  declare const definePreset: (preset: BuildPreset) => BuildPreset;
26
29
 
27
30
  export { BuildConfig, BuildPreset, defineConfig, definePreset };
package/dist/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, a as BuildPreset } from './shared/packem.CAQMZ6ex.mjs';
2
- export { b as BuildHooks } from './shared/packem.CAQMZ6ex.mjs';
1
+ import { B as BuildConfig, a as BuildPreset, E as Environment, M as Mode } from './shared/types-DRxO9m8T.mjs';
2
+ export { b as BuildHooks } from './shared/types-DRxO9m8T.mjs';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -9,19 +9,22 @@ import '@rollup/plugin-wasm';
9
9
  import '@rollup/pluginutils';
10
10
  import '@visulima/package';
11
11
  import '@visulima/pail';
12
+ import '@visulima/tsconfig';
12
13
  import 'hookable';
13
14
  import 'jiti';
14
15
  import 'rollup';
15
16
  import 'rollup-plugin-dts';
16
17
  import 'rollup-plugin-polyfill-node';
17
18
  import 'rollup-plugin-visualizer';
18
- import './shared/packem.D09xRBAa.mjs';
19
+ import './shared/types-Db-Z_7e-.mjs';
19
20
  import 'esbuild';
20
- import './shared/packem.DvWhOdt5.mjs';
21
+ import './shared/types-DvWhOdt5.mjs';
21
22
  import 'sucrase';
22
- import './shared/packem.C44tLE3n.mjs';
23
+ import './shared/types-CzGE8V_d.mjs';
23
24
 
24
- declare const defineConfig: (config: BuildConfig | BuildConfig[]) => BuildConfig[];
25
+ type BuildConfigFunction = (enviroment: Environment, mode: Mode) => BuildConfig;
26
+
27
+ declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
25
28
  declare const definePreset: (preset: BuildPreset) => BuildPreset;
26
29
 
27
30
  export { BuildConfig, BuildPreset, defineConfig, definePreset };
package/dist/config.mjs CHANGED
@@ -1 +1 @@
1
- var f=Object.defineProperty;var i=(e,r)=>f(e,"name",{value:r,configurable:!0});var a=Object.defineProperty,n=i((e,r)=>a(e,"name",{value:r,configurable:!0}),"i");const o=n(e=>(Array.isArray(e)?e:[e]).filter(Boolean),"defineConfig"),t=n(e=>e,"definePreset");export{o as defineConfig,t as definePreset};
1
+ var r=Object.defineProperty;var f=(e,n)=>r(e,"name",{value:n,configurable:!0});var o=Object.defineProperty,i=f((e,n)=>o(e,"name",{value:n,configurable:!0}),"e");const a=i(e=>e,"defineConfig"),d=i(e=>e,"definePreset");export{a as defineConfig,d as definePreset};