@storm-software/esbuild 0.34.0 → 0.34.2

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 (91) hide show
  1. package/README.md +1 -1
  2. package/bin/esbuild.cjs +5 -5
  3. package/dist/build.cjs +15 -15
  4. package/dist/build.d.cts +1 -1
  5. package/dist/build.d.ts +1 -1
  6. package/dist/build.js +14 -14
  7. package/dist/{chunk-WRBUO7H6.cjs → chunk-27VOV3G4.cjs} +2 -2
  8. package/dist/{chunk-GWG4HOQ6.js → chunk-2TG2H4XL.js} +1 -1
  9. package/dist/{chunk-XEGYFRBF.js → chunk-2X5ZMEAN.js} +2 -2
  10. package/dist/{chunk-35YNFZCF.js → chunk-3PF5YMWK.js} +2 -2
  11. package/dist/{chunk-S2P6KHZV.js → chunk-3QHFCKSI.js} +3 -3
  12. package/dist/{chunk-RGWII6NP.js → chunk-5RVOO3YF.js} +2 -2
  13. package/dist/{chunk-LYDEMC26.js → chunk-AZON722Q.js} +1 -1
  14. package/dist/chunk-B4CUDMY2.cjs +39 -0
  15. package/dist/{chunk-MWGFCZF4.cjs → chunk-BNPCRQK4.cjs} +6 -6
  16. package/dist/{chunk-K6QIYIIY.cjs → chunk-BOFHC4OE.cjs} +4 -4
  17. package/dist/{chunk-IO2TXOKO.js → chunk-BWSIRV3D.js} +2 -2
  18. package/dist/chunk-CCEWV2BR.js +39 -0
  19. package/dist/{chunk-ETTFFUNG.cjs → chunk-CGMLIVTB.cjs} +12 -12
  20. package/dist/chunk-DPRINYB6.js +2939 -0
  21. package/dist/{chunk-Y3LXNK5C.cjs → chunk-GJHRTQAS.cjs} +36 -36
  22. package/dist/{chunk-EZGTDCYM.cjs → chunk-ILJQ4NCE.cjs} +4 -4
  23. package/dist/chunk-M3AOQRGN.cjs +2939 -0
  24. package/dist/{chunk-IMVMVEQS.cjs → chunk-N62ZR7UV.cjs} +17 -17
  25. package/dist/{chunk-4TQE46SC.cjs → chunk-QKJ7KLDL.cjs} +6 -6
  26. package/dist/{chunk-GQCYZOAM.cjs → chunk-RLQJRD62.cjs} +2 -2
  27. package/dist/{chunk-KGKL7VDG.js → chunk-SKJRUPDP.js} +11 -10
  28. package/dist/{chunk-IX6DNVUR.js → chunk-STCE44IS.js} +2 -2
  29. package/dist/{chunk-AXEZCHZS.cjs → chunk-TDBBRZTC.cjs} +99 -98
  30. package/dist/{chunk-Y4XWI6JJ.cjs → chunk-TH2QFJHI.cjs} +6 -6
  31. package/dist/{chunk-T5272PC2.js → chunk-UYE6LM4C.js} +1 -1
  32. package/dist/{chunk-XITTOHOG.cjs → chunk-VPTKC3UK.cjs} +6 -6
  33. package/dist/{chunk-2IGRKQGI.js → chunk-VQHKIS7J.js} +2 -2
  34. package/dist/{chunk-HXMVEX3P.js → chunk-XLUZXKDY.js} +1 -1
  35. package/dist/{chunk-S6M44SSZ.cjs → chunk-Y5SBBYX3.cjs} +3 -3
  36. package/dist/{chunk-YMTDVMD6.js → chunk-Y7JBB452.js} +1 -1
  37. package/dist/clean.cjs +5 -5
  38. package/dist/clean.d.cts +1 -1
  39. package/dist/clean.d.ts +1 -1
  40. package/dist/clean.js +4 -4
  41. package/dist/config.cjs +12 -12
  42. package/dist/config.d.cts +2 -2
  43. package/dist/config.d.ts +2 -2
  44. package/dist/config.js +11 -11
  45. package/dist/index.cjs +16 -16
  46. package/dist/index.d.cts +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +15 -15
  49. package/dist/plugins/deps-check.cjs +5 -5
  50. package/dist/plugins/deps-check.js +4 -4
  51. package/dist/plugins/esm-split-code-to-cjs.cjs +3 -3
  52. package/dist/plugins/esm-split-code-to-cjs.d.cts +1 -1
  53. package/dist/plugins/esm-split-code-to-cjs.d.ts +1 -1
  54. package/dist/plugins/esm-split-code-to-cjs.js +2 -2
  55. package/dist/plugins/fix-imports.cjs +3 -3
  56. package/dist/plugins/fix-imports.d.cts +1 -1
  57. package/dist/plugins/fix-imports.d.ts +1 -1
  58. package/dist/plugins/fix-imports.js +2 -2
  59. package/dist/plugins/native-node-module.cjs +3 -3
  60. package/dist/plugins/native-node-module.d.cts +1 -1
  61. package/dist/plugins/native-node-module.d.ts +1 -1
  62. package/dist/plugins/native-node-module.js +2 -2
  63. package/dist/plugins/node-protocol.cjs +3 -3
  64. package/dist/plugins/node-protocol.d.cts +1 -1
  65. package/dist/plugins/node-protocol.d.ts +1 -1
  66. package/dist/plugins/node-protocol.js +2 -2
  67. package/dist/plugins/on-error.cjs +5 -5
  68. package/dist/plugins/on-error.d.cts +1 -1
  69. package/dist/plugins/on-error.d.ts +1 -1
  70. package/dist/plugins/on-error.js +4 -4
  71. package/dist/plugins/resolve-paths.cjs +4 -4
  72. package/dist/plugins/resolve-paths.d.cts +1 -1
  73. package/dist/plugins/resolve-paths.d.ts +1 -1
  74. package/dist/plugins/resolve-paths.js +3 -3
  75. package/dist/plugins/tsc.cjs +5 -5
  76. package/dist/plugins/tsc.d.cts +1 -1
  77. package/dist/plugins/tsc.d.ts +1 -1
  78. package/dist/plugins/tsc.js +4 -4
  79. package/dist/tsc.cjs +5 -5
  80. package/dist/tsc.d.cts +1 -1
  81. package/dist/tsc.d.ts +1 -1
  82. package/dist/tsc.js +4 -4
  83. package/dist/{types-DwxFThZu.d.ts → types-B4jbZA4j.d.cts} +14 -14
  84. package/dist/{types-DwxFThZu.d.cts → types-B4jbZA4j.d.ts} +14 -14
  85. package/dist/types.d.cts +1 -1
  86. package/dist/types.d.ts +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunk-3GQAWCBQ.js +0 -13
  89. package/dist/chunk-BGYQAVKQ.cjs +0 -13
  90. package/dist/chunk-E5AAO2PH.cjs +0 -422
  91. package/dist/chunk-X6OXFNDR.js +0 -422
@@ -0,0 +1,2939 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard2(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault2(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkTH2QFJHIcjs = require('./chunk-TH2QFJHI.cjs');
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ var _chunkTDBBRZTCcjs = require('./chunk-TDBBRZTC.cjs');
12
+
13
+
14
+ var _chunkBNPCRQK4cjs = require('./chunk-BNPCRQK4.cjs');
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ var _chunkGJHRTQAScjs = require('./chunk-GJHRTQAS.cjs');
24
+
25
+
26
+ var _chunkVPTKC3UKcjs = require('./chunk-VPTKC3UK.cjs');
27
+
28
+
29
+
30
+
31
+
32
+ var _chunkB4CUDMY2cjs = require('./chunk-B4CUDMY2.cjs');
33
+
34
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-BYH4XDRH.js
35
+ var require_chunk_BYH4XDRH = _chunkB4CUDMY2cjs.__commonJS.call(void 0, {
36
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-BYH4XDRH.js"(exports) {
37
+ "use strict";
38
+ Object.defineProperty(exports, "__esModule", {
39
+ value: true
40
+ });
41
+ var version = "8.4.0";
42
+ exports.version = version;
43
+ }
44
+ });
45
+
46
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-TWFEYLU4.js
47
+ var require_chunk_TWFEYLU4 = _chunkB4CUDMY2cjs.__commonJS.call(void 0, {
48
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-TWFEYLU4.js"(exports) {
49
+ "use strict";
50
+ Object.defineProperty(exports, "__esModule", {
51
+ value: true
52
+ });
53
+ function _interopRequireDefault(obj) {
54
+ return obj && obj.__esModule ? obj : {
55
+ default: obj
56
+ };
57
+ }
58
+ _chunkB4CUDMY2cjs.__name.call(void 0, _interopRequireDefault, "_interopRequireDefault");
59
+ function _optionalChain(ops) {
60
+ let lastAccessLHS = void 0;
61
+ let value = ops[0];
62
+ let i = 1;
63
+ while (i < ops.length) {
64
+ const op = ops[i];
65
+ const fn = ops[i + 1];
66
+ i += 2;
67
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
68
+ return void 0;
69
+ }
70
+ if (op === "access" || op === "optionalAccess") {
71
+ lastAccessLHS = value;
72
+ value = fn(value);
73
+ } else if (op === "call" || op === "optionalCall") {
74
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
75
+ lastAccessLHS = void 0;
76
+ }
77
+ }
78
+ return value;
79
+ }
80
+ _chunkB4CUDMY2cjs.__name.call(void 0, _optionalChain, "_optionalChain");
81
+ var __create = Object.create;
82
+ var __defProp = Object.defineProperty;
83
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
84
+ var __getOwnPropNames = Object.getOwnPropertyNames;
85
+ var __getProtoOf = Object.getPrototypeOf;
86
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
87
+ var __require2 = /* @__PURE__ */ ((x) => typeof _chunkB4CUDMY2cjs.__require !== "undefined" ? _chunkB4CUDMY2cjs.__require : typeof Proxy !== "undefined" ? new Proxy(x, {
88
+ get: /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (a, b) => (typeof _chunkB4CUDMY2cjs.__require !== "undefined" ? _chunkB4CUDMY2cjs.__require : a)[b], "get")
89
+ }) : x)(function(x) {
90
+ if (typeof _chunkB4CUDMY2cjs.__require !== "undefined") return _chunkB4CUDMY2cjs.__require.apply(this, arguments);
91
+ throw Error('Dynamic require of "' + x + '" is not supported');
92
+ });
93
+ var __commonJS2 = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (cb, mod) => /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, function __require22() {
94
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
95
+ exports: {}
96
+ }).exports, mod), mod.exports;
97
+ }, "__require2"), "__commonJS");
98
+ var __copyProps = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (to, from, except, desc) => {
99
+ if (from && typeof from === "object" || typeof from === "function") {
100
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
101
+ get: /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => from[key], "get"),
102
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
103
+ });
104
+ }
105
+ return to;
106
+ }, "__copyProps");
107
+ var __toESM2 = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
108
+ // If the importer is in node compatibility mode or this is not an ESM
109
+ // file that has been converted to a CommonJS file using a Babel-
110
+ // compatible transform (i.e. "__esModule" has not been set), then set
111
+ // "default" to the CommonJS "module.exports" for node compatibility.
112
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
113
+ value: mod,
114
+ enumerable: true
115
+ }) : target,
116
+ mod
117
+ )), "__toESM");
118
+ var _fs = _chunkB4CUDMY2cjs.__require.call(void 0, "fs");
119
+ var _fs2 = _interopRequireDefault(_fs);
120
+ var _path = _chunkB4CUDMY2cjs.__require.call(void 0, "path");
121
+ var _path2 = _interopRequireDefault(_path);
122
+ var _resolvefrom = _chunkB4CUDMY2cjs.__require.call(void 0, "resolve-from");
123
+ var _resolvefrom2 = _interopRequireDefault(_resolvefrom);
124
+ var singleComment = Symbol("singleComment");
125
+ var multiComment = Symbol("multiComment");
126
+ var stripWithoutWhitespace = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => "", "stripWithoutWhitespace");
127
+ var stripWithWhitespace = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (string, start, end) => string.slice(start, end).replace(/\S/g, " "), "stripWithWhitespace");
128
+ var isEscaped = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (jsonString, quotePosition) => {
129
+ let index = quotePosition - 1;
130
+ let backslashCount = 0;
131
+ while (jsonString[index] === "\\") {
132
+ index -= 1;
133
+ backslashCount += 1;
134
+ }
135
+ return Boolean(backslashCount % 2);
136
+ }, "isEscaped");
137
+ function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
138
+ if (typeof jsonString !== "string") {
139
+ throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
140
+ }
141
+ const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
142
+ let isInsideString = false;
143
+ let isInsideComment = false;
144
+ let offset = 0;
145
+ let buffer = "";
146
+ let result = "";
147
+ let commaIndex = -1;
148
+ for (let index = 0; index < jsonString.length; index++) {
149
+ const currentCharacter = jsonString[index];
150
+ const nextCharacter = jsonString[index + 1];
151
+ if (!isInsideComment && currentCharacter === '"') {
152
+ const escaped = isEscaped(jsonString, index);
153
+ if (!escaped) {
154
+ isInsideString = !isInsideString;
155
+ }
156
+ }
157
+ if (isInsideString) {
158
+ continue;
159
+ }
160
+ if (!isInsideComment && currentCharacter + nextCharacter === "//") {
161
+ buffer += jsonString.slice(offset, index);
162
+ offset = index;
163
+ isInsideComment = singleComment;
164
+ index++;
165
+ } else if (isInsideComment === singleComment && currentCharacter + nextCharacter === "\r\n") {
166
+ index++;
167
+ isInsideComment = false;
168
+ buffer += strip(jsonString, offset, index);
169
+ offset = index;
170
+ continue;
171
+ } else if (isInsideComment === singleComment && currentCharacter === "\n") {
172
+ isInsideComment = false;
173
+ buffer += strip(jsonString, offset, index);
174
+ offset = index;
175
+ } else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
176
+ buffer += jsonString.slice(offset, index);
177
+ offset = index;
178
+ isInsideComment = multiComment;
179
+ index++;
180
+ continue;
181
+ } else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
182
+ index++;
183
+ isInsideComment = false;
184
+ buffer += strip(jsonString, offset, index + 1);
185
+ offset = index + 1;
186
+ continue;
187
+ } else if (trailingCommas && !isInsideComment) {
188
+ if (commaIndex !== -1) {
189
+ if (currentCharacter === "}" || currentCharacter === "]") {
190
+ buffer += jsonString.slice(offset, index);
191
+ result += strip(buffer, 0, 1) + buffer.slice(1);
192
+ buffer = "";
193
+ offset = index;
194
+ commaIndex = -1;
195
+ } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
196
+ buffer += jsonString.slice(offset, index);
197
+ offset = index;
198
+ commaIndex = -1;
199
+ }
200
+ } else if (currentCharacter === ",") {
201
+ result += buffer + jsonString.slice(offset, index);
202
+ buffer = "";
203
+ offset = index;
204
+ commaIndex = index;
205
+ }
206
+ }
207
+ }
208
+ return result + buffer + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
209
+ }
210
+ _chunkB4CUDMY2cjs.__name.call(void 0, stripJsonComments, "stripJsonComments");
211
+ var _tinyglobby = _chunkB4CUDMY2cjs.__require.call(void 0, "tinyglobby");
212
+ function getPostcss() {
213
+ return localRequire("postcss");
214
+ }
215
+ _chunkB4CUDMY2cjs.__name.call(void 0, getPostcss, "getPostcss");
216
+ function getApiExtractor() {
217
+ return localRequire("@microsoft/api-extractor");
218
+ }
219
+ _chunkB4CUDMY2cjs.__name.call(void 0, getApiExtractor, "getApiExtractor");
220
+ function localRequire(moduleName) {
221
+ const p = _resolvefrom2.default.silent(process.cwd(), moduleName);
222
+ return p && __require2(p);
223
+ }
224
+ _chunkB4CUDMY2cjs.__name.call(void 0, localRequire, "localRequire");
225
+ async function removeFiles(patterns, dir) {
226
+ const files = await _tinyglobby.glob.call(void 0, patterns, {
227
+ cwd: dir,
228
+ absolute: true
229
+ });
230
+ files.forEach((file) => _fs2.default.existsSync(file) && _fs2.default.unlinkSync(file));
231
+ }
232
+ _chunkB4CUDMY2cjs.__name.call(void 0, removeFiles, "removeFiles");
233
+ function debouncePromise(fn, delay, onError) {
234
+ let timeout;
235
+ let promiseInFly;
236
+ let callbackPending;
237
+ return /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, function debounced(...args) {
238
+ if (promiseInFly) {
239
+ callbackPending = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
240
+ debounced(...args);
241
+ callbackPending = void 0;
242
+ }, "callbackPending");
243
+ } else {
244
+ if (timeout != null) clearTimeout(timeout);
245
+ timeout = setTimeout(() => {
246
+ timeout = void 0;
247
+ promiseInFly = fn(...args).catch(onError).finally(() => {
248
+ promiseInFly = void 0;
249
+ if (callbackPending) callbackPending();
250
+ });
251
+ }, delay);
252
+ }
253
+ }, "debounced");
254
+ }
255
+ _chunkB4CUDMY2cjs.__name.call(void 0, debouncePromise, "debouncePromise");
256
+ function slash(path2) {
257
+ const isExtendedLengthPath = path2.startsWith("\\\\?\\");
258
+ if (isExtendedLengthPath) {
259
+ return path2;
260
+ }
261
+ return path2.replace(/\\/g, "/");
262
+ }
263
+ _chunkB4CUDMY2cjs.__name.call(void 0, slash, "slash");
264
+ function truthy(value) {
265
+ return Boolean(value);
266
+ }
267
+ _chunkB4CUDMY2cjs.__name.call(void 0, truthy, "truthy");
268
+ function jsoncParse(data) {
269
+ try {
270
+ return new Function(`return ${stripJsonComments(data).trim()}`)();
271
+ } catch (e2) {
272
+ return {};
273
+ }
274
+ }
275
+ _chunkB4CUDMY2cjs.__name.call(void 0, jsoncParse, "jsoncParse");
276
+ function defaultOutExtension({ format, pkgType }) {
277
+ let jsExtension = ".js";
278
+ let dtsExtension = ".d.ts";
279
+ const isModule = pkgType === "module";
280
+ if (isModule && format === "cjs") {
281
+ jsExtension = ".cjs";
282
+ dtsExtension = ".d.cts";
283
+ }
284
+ if (!isModule && format === "esm") {
285
+ jsExtension = ".mjs";
286
+ dtsExtension = ".d.mts";
287
+ }
288
+ if (format === "iife") {
289
+ jsExtension = ".global.js";
290
+ }
291
+ return {
292
+ js: jsExtension,
293
+ dts: dtsExtension
294
+ };
295
+ }
296
+ _chunkB4CUDMY2cjs.__name.call(void 0, defaultOutExtension, "defaultOutExtension");
297
+ function ensureTempDeclarationDir(options2) {
298
+ const cwd = _optionalChain2([options2, 'access', _40 => _40.workspaceConfig, 'optionalAccess', _41 => _41.workspaceRoot]) || process.cwd();
299
+ const dirPath = _path2.default.join(cwd, ".tsup", "declaration");
300
+ if (_fs2.default.existsSync(dirPath)) {
301
+ return dirPath;
302
+ }
303
+ _fs2.default.mkdirSync(dirPath, {
304
+ recursive: true
305
+ });
306
+ const gitIgnorePath = _path2.default.join(cwd, ".tsup", ".gitignore");
307
+ writeFileSync(gitIgnorePath, "**/*\n");
308
+ return dirPath;
309
+ }
310
+ _chunkB4CUDMY2cjs.__name.call(void 0, ensureTempDeclarationDir, "ensureTempDeclarationDir");
311
+ var toObjectEntry = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (entry) => {
312
+ if (typeof entry === "string") {
313
+ entry = [
314
+ entry
315
+ ];
316
+ }
317
+ if (!Array.isArray(entry)) {
318
+ return entry;
319
+ }
320
+ entry = entry.map((e) => e.replace(/\\/g, "/"));
321
+ const ancestor = findLowestCommonAncestor(entry);
322
+ return entry.reduce((result, item) => {
323
+ const key = item.replace(ancestor, "").replace(/^\//, "").replace(/\.[a-z]+$/, "");
324
+ return {
325
+ ...result,
326
+ [key]: item
327
+ };
328
+ }, {});
329
+ }, "toObjectEntry");
330
+ var findLowestCommonAncestor = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (filepaths) => {
331
+ if (filepaths.length <= 1) return "";
332
+ const [first, ...rest] = filepaths;
333
+ let ancestor = first.split("/");
334
+ for (const filepath of rest) {
335
+ const directories = filepath.split("/", ancestor.length);
336
+ let index = 0;
337
+ for (const directory of directories) {
338
+ if (directory === ancestor[index]) {
339
+ index += 1;
340
+ } else {
341
+ ancestor = ancestor.slice(0, index);
342
+ break;
343
+ }
344
+ }
345
+ ancestor = ancestor.slice(0, index);
346
+ }
347
+ return ancestor.length <= 1 && ancestor[0] === "" ? `/${ancestor[0]}` : ancestor.join("/");
348
+ }, "findLowestCommonAncestor");
349
+ function toAbsolutePath(p, cwd) {
350
+ if (_path2.default.isAbsolute(p)) {
351
+ return p;
352
+ }
353
+ return slash(_path2.default.normalize(_path2.default.join(cwd || process.cwd(), p)));
354
+ }
355
+ _chunkB4CUDMY2cjs.__name.call(void 0, toAbsolutePath, "toAbsolutePath");
356
+ function writeFileSync(filePath, content) {
357
+ _fs2.default.mkdirSync(_path2.default.dirname(filePath), {
358
+ recursive: true
359
+ });
360
+ _fs2.default.writeFileSync(filePath, content);
361
+ }
362
+ _chunkB4CUDMY2cjs.__name.call(void 0, writeFileSync, "writeFileSync");
363
+ function replaceDtsWithJsExtensions(dtsFilePath) {
364
+ return dtsFilePath.replace(/\.d\.(ts|mts|cts)$/, (_, fileExtension) => {
365
+ switch (fileExtension) {
366
+ case "ts":
367
+ return ".js";
368
+ case "mts":
369
+ return ".mjs";
370
+ case "cts":
371
+ return ".cjs";
372
+ default:
373
+ return "";
374
+ }
375
+ });
376
+ }
377
+ _chunkB4CUDMY2cjs.__name.call(void 0, replaceDtsWithJsExtensions, "replaceDtsWithJsExtensions");
378
+ var convertArrayEntriesToObjectEntries = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (arrayOfEntries) => {
379
+ const objectEntries = Object.fromEntries(arrayOfEntries.map((entry) => [
380
+ _path2.default.posix.join(...entry.split(_path2.default.posix.sep).slice(1, -1).concat(_path2.default.parse(entry).name)),
381
+ entry
382
+ ]));
383
+ return objectEntries;
384
+ }, "convertArrayEntriesToObjectEntries");
385
+ var resolveEntryPaths = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (entryPaths) => {
386
+ const resolvedEntryPaths = typeof entryPaths === "string" || Array.isArray(entryPaths) ? convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, entryPaths)) : entryPaths;
387
+ return resolvedEntryPaths;
388
+ }, "resolveEntryPaths");
389
+ var resolveExperimentalDtsConfig = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (options2, tsconfig) => {
390
+ const resolvedEntryPaths = await resolveEntryPaths(_optionalChain([
391
+ options2,
392
+ "access",
393
+ (_2) => _2.experimentalDts,
394
+ "optionalAccess",
395
+ (_3) => _3.entry
396
+ ]) || options2.entry);
397
+ const experimentalDtsObjectEntry = Object.keys(resolvedEntryPaths).length === 0 ? Array.isArray(options2.entry) ? convertArrayEntriesToObjectEntries(options2.entry) : options2.entry : resolvedEntryPaths;
398
+ const normalizedExperimentalDtsConfig = {
399
+ compilerOptions: {
400
+ ...tsconfig.data.compilerOptions || {},
401
+ ..._optionalChain([
402
+ options2,
403
+ "access",
404
+ (_4) => _4.experimentalDts,
405
+ "optionalAccess",
406
+ (_5) => _5.compilerOptions
407
+ ]) || {}
408
+ },
409
+ entry: experimentalDtsObjectEntry
410
+ };
411
+ return normalizedExperimentalDtsConfig;
412
+ }, "resolveExperimentalDtsConfig");
413
+ var resolveInitialExperimentalDtsConfig = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (experimentalDts) => {
414
+ if (experimentalDts == null) {
415
+ return;
416
+ }
417
+ if (typeof experimentalDts === "boolean") return experimentalDts ? {
418
+ entry: {}
419
+ } : void 0;
420
+ if (typeof experimentalDts === "string") {
421
+ return {
422
+ entry: convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, experimentalDts))
423
+ };
424
+ }
425
+ return {
426
+ ...experimentalDts,
427
+ entry: _optionalChain([
428
+ experimentalDts,
429
+ "optionalAccess",
430
+ (_6) => _6.entry
431
+ ]) == null ? {} : await resolveEntryPaths(experimentalDts.entry)
432
+ };
433
+ }, "resolveInitialExperimentalDtsConfig");
434
+ exports.__require = __require2;
435
+ exports.__commonJS = __commonJS2;
436
+ exports.__toESM = __toESM2;
437
+ exports.getPostcss = getPostcss;
438
+ exports.getApiExtractor = getApiExtractor;
439
+ exports.localRequire = localRequire;
440
+ exports.removeFiles = removeFiles;
441
+ exports.debouncePromise = debouncePromise;
442
+ exports.slash = slash;
443
+ exports.truthy = truthy;
444
+ exports.jsoncParse = jsoncParse;
445
+ exports.defaultOutExtension = defaultOutExtension;
446
+ exports.ensureTempDeclarationDir = ensureTempDeclarationDir;
447
+ exports.toObjectEntry = toObjectEntry;
448
+ exports.toAbsolutePath = toAbsolutePath;
449
+ exports.writeFileSync = writeFileSync;
450
+ exports.replaceDtsWithJsExtensions = replaceDtsWithJsExtensions;
451
+ exports.resolveExperimentalDtsConfig = resolveExperimentalDtsConfig;
452
+ exports.resolveInitialExperimentalDtsConfig = resolveInitialExperimentalDtsConfig;
453
+ }
454
+ });
455
+
456
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-VGC3FXLU.js
457
+ var require_chunk_VGC3FXLU = _chunkB4CUDMY2cjs.__commonJS.call(void 0, {
458
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-VGC3FXLU.js"(exports) {
459
+ "use strict";
460
+ Object.defineProperty(exports, "__esModule", {
461
+ value: true
462
+ });
463
+ function _interopRequireDefault(obj) {
464
+ return obj && obj.__esModule ? obj : {
465
+ default: obj
466
+ };
467
+ }
468
+ _chunkB4CUDMY2cjs.__name.call(void 0, _interopRequireDefault, "_interopRequireDefault");
469
+ function _optionalChain(ops) {
470
+ let lastAccessLHS = void 0;
471
+ let value = ops[0];
472
+ let i = 1;
473
+ while (i < ops.length) {
474
+ const op = ops[i];
475
+ const fn = ops[i + 1];
476
+ i += 2;
477
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
478
+ return void 0;
479
+ }
480
+ if (op === "access" || op === "optionalAccess") {
481
+ lastAccessLHS = value;
482
+ value = fn(value);
483
+ } else if (op === "call" || op === "optionalCall") {
484
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
485
+ lastAccessLHS = void 0;
486
+ }
487
+ }
488
+ return value;
489
+ }
490
+ _chunkB4CUDMY2cjs.__name.call(void 0, _optionalChain, "_optionalChain");
491
+ var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
492
+ var _fs = _chunkB4CUDMY2cjs.__require.call(void 0, "fs");
493
+ var _fs2 = _interopRequireDefault(_fs);
494
+ var _path = _chunkB4CUDMY2cjs.__require.call(void 0, "path");
495
+ var _path2 = _interopRequireDefault(_path);
496
+ var _joycon = _chunkB4CUDMY2cjs.__require.call(void 0, "joycon");
497
+ var _joycon2 = _interopRequireDefault(_joycon);
498
+ var _bundlerequire = _chunkB4CUDMY2cjs.__require.call(void 0, "bundle-require");
499
+ var joycon = new (0, _joycon2.default)();
500
+ var loadJson = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (filepath, options2) => {
501
+ try {
502
+ return _chunkTWFEYLU4js.jsoncParse.call(void 0, await _fs2.default.promises.readFile(filepath, "utf8"));
503
+ } catch (error) {
504
+ if (error instanceof Error) {
505
+ throw new Error(`Failed to parse ${_path2.default.relative(_optionalChain2([options2, 'access', _42 => _42.workspaceConfig, 'optionalAccess', _43 => _43.workspaceRoot]) || process.cwd(), filepath)}: ${error.message}`);
506
+ } else {
507
+ throw error;
508
+ }
509
+ }
510
+ }, "loadJson");
511
+ var jsonLoader = {
512
+ test: /\.json$/,
513
+ load(filepath) {
514
+ return loadJson(filepath);
515
+ }
516
+ };
517
+ joycon.addLoader(jsonLoader);
518
+ async function loadTsupConfig(cwd, configFile) {
519
+ const configJoycon = new (0, _joycon2.default)();
520
+ const configPath = await configJoycon.resolve({
521
+ files: configFile ? [
522
+ configFile
523
+ ] : [
524
+ "tsup.config.ts",
525
+ "tsup.config.cts",
526
+ "tsup.config.mts",
527
+ "tsup.config.js",
528
+ "tsup.config.cjs",
529
+ "tsup.config.mjs",
530
+ "tsup.config.json",
531
+ "package.json"
532
+ ],
533
+ cwd,
534
+ stopDir: _path2.default.parse(cwd).root,
535
+ packageKey: "tsup"
536
+ });
537
+ if (configPath) {
538
+ if (configPath.endsWith(".json")) {
539
+ let data = await loadJson(configPath);
540
+ if (configPath.endsWith("package.json")) {
541
+ data = data.tsup;
542
+ }
543
+ if (data) {
544
+ return {
545
+ path: configPath,
546
+ data
547
+ };
548
+ }
549
+ return {};
550
+ }
551
+ const config = await _bundlerequire.bundleRequire.call(void 0, {
552
+ filepath: configPath
553
+ });
554
+ return {
555
+ path: configPath,
556
+ data: config.mod.tsup || config.mod.default || config.mod
557
+ };
558
+ }
559
+ return {};
560
+ }
561
+ _chunkB4CUDMY2cjs.__name.call(void 0, loadTsupConfig, "loadTsupConfig");
562
+ async function loadPkg(cwd, clearCache = false) {
563
+ if (clearCache) {
564
+ joycon.clearCache();
565
+ }
566
+ const { data } = await joycon.load([
567
+ "package.json"
568
+ ], cwd, _path2.default.dirname(cwd));
569
+ return data || {};
570
+ }
571
+ _chunkB4CUDMY2cjs.__name.call(void 0, loadPkg, "loadPkg");
572
+ async function getProductionDeps(cwd, clearCache = false) {
573
+ const data = await loadPkg(cwd, clearCache);
574
+ const deps = Array.from(/* @__PURE__ */ new Set([
575
+ ...Object.keys(data.dependencies || {}),
576
+ ...Object.keys(data.peerDependencies || {})
577
+ ]));
578
+ return deps;
579
+ }
580
+ _chunkB4CUDMY2cjs.__name.call(void 0, getProductionDeps, "getProductionDeps");
581
+ async function getAllDepsHash(cwd) {
582
+ const data = await loadPkg(cwd, true);
583
+ return JSON.stringify({
584
+ ...data.dependencies,
585
+ ...data.peerDependencies,
586
+ ...data.devDependencies
587
+ });
588
+ }
589
+ _chunkB4CUDMY2cjs.__name.call(void 0, getAllDepsHash, "getAllDepsHash");
590
+ var _util = _chunkB4CUDMY2cjs.__require.call(void 0, "util");
591
+ var _util2 = _interopRequireDefault(_util);
592
+ var _worker_threads = _chunkB4CUDMY2cjs.__require.call(void 0, "worker_threads");
593
+ var _picocolors = _chunkB4CUDMY2cjs.__require.call(void 0, "picocolors");
594
+ var _picocolors2 = _interopRequireDefault(_picocolors);
595
+ var colorize = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (type, data, onlyImportant = false) => {
596
+ if (onlyImportant && (type === "info" || type === "success")) return data;
597
+ const color = type === "info" ? "blue" : type === "error" ? "red" : type === "warn" ? "yellow" : "green";
598
+ return _picocolors2.default[color](data);
599
+ }, "colorize");
600
+ var makeLabel = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (name, input, type) => {
601
+ return [
602
+ name && `${_picocolors2.default.dim("[")}${name.toUpperCase()}${_picocolors2.default.dim("]")}`,
603
+ colorize(type, input.toUpperCase())
604
+ ].filter(Boolean).join(" ");
605
+ }, "makeLabel");
606
+ var silent = false;
607
+ function setSilent(isSilent) {
608
+ silent = !!isSilent;
609
+ }
610
+ _chunkB4CUDMY2cjs.__name.call(void 0, setSilent, "setSilent");
611
+ function getSilent() {
612
+ return silent;
613
+ }
614
+ _chunkB4CUDMY2cjs.__name.call(void 0, getSilent, "getSilent");
615
+ var createLogger = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (name) => {
616
+ return {
617
+ setName(_name) {
618
+ name = _name;
619
+ },
620
+ success(label, ...args) {
621
+ return this.log(label, "success", ...args);
622
+ },
623
+ info(label, ...args) {
624
+ return this.log(label, "info", ...args);
625
+ },
626
+ error(label, ...args) {
627
+ return this.log(label, "error", ...args);
628
+ },
629
+ warn(label, ...args) {
630
+ return this.log(label, "warn", ...args);
631
+ },
632
+ log(label, type, ...data) {
633
+ const args = [
634
+ makeLabel(name, label, type),
635
+ ...data.map((item) => colorize(type, item, true))
636
+ ];
637
+ switch (type) {
638
+ case "error": {
639
+ if (!_worker_threads.isMainThread) {
640
+ _optionalChain([
641
+ _worker_threads.parentPort,
642
+ "optionalAccess",
643
+ (_) => _.postMessage,
644
+ "call",
645
+ (_2) => _2({
646
+ type: "error",
647
+ text: _util2.default.format(...args)
648
+ })
649
+ ]);
650
+ return;
651
+ }
652
+ return console.error(...args);
653
+ }
654
+ default:
655
+ if (silent) return;
656
+ if (!_worker_threads.isMainThread) {
657
+ _optionalChain([
658
+ _worker_threads.parentPort,
659
+ "optionalAccess",
660
+ (_3) => _3.postMessage,
661
+ "call",
662
+ (_4) => _4({
663
+ type: "log",
664
+ text: _util2.default.format(...args)
665
+ })
666
+ ]);
667
+ return;
668
+ }
669
+ console.log(...args);
670
+ }
671
+ }
672
+ };
673
+ }, "createLogger");
674
+ var prettyBytes = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (bytes) => {
675
+ if (bytes === 0) return "0 B";
676
+ const unit = [
677
+ "B",
678
+ "KB",
679
+ "MB",
680
+ "GB",
681
+ "TB",
682
+ "PB",
683
+ "EB",
684
+ "ZB",
685
+ "YB"
686
+ ];
687
+ const exp = Math.floor(Math.log(bytes) / Math.log(1024));
688
+ return `${(bytes / 1024 ** exp).toFixed(2)} ${unit[exp]}`;
689
+ }, "prettyBytes");
690
+ var getLengthOfLongestString = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (strings) => {
691
+ return strings.reduce((max, str) => {
692
+ return Math.max(max, str.length);
693
+ }, 0);
694
+ }, "getLengthOfLongestString");
695
+ var padRight = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (str, maxLength) => {
696
+ return str + " ".repeat(maxLength - str.length);
697
+ }, "padRight");
698
+ var reportSize = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (logger, format, files) => {
699
+ const filenames = Object.keys(files);
700
+ const maxLength = getLengthOfLongestString(filenames) + 1;
701
+ for (const name of filenames) {
702
+ logger.success(format, `${_picocolors2.default.bold(padRight(name, maxLength))}${_picocolors2.default.green(prettyBytes(files[name]))}`);
703
+ }
704
+ }, "reportSize");
705
+ exports.loadTsupConfig = loadTsupConfig;
706
+ exports.loadPkg = loadPkg;
707
+ exports.getProductionDeps = getProductionDeps;
708
+ exports.getAllDepsHash = getAllDepsHash;
709
+ exports.setSilent = setSilent;
710
+ exports.getSilent = getSilent;
711
+ exports.createLogger = createLogger;
712
+ exports.reportSize = reportSize;
713
+ }
714
+ });
715
+
716
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-JZ25TPTY.js
717
+ var require_chunk_JZ25TPTY = _chunkB4CUDMY2cjs.__commonJS.call(void 0, {
718
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-JZ25TPTY.js"(exports) {
719
+ "use strict";
720
+ Object.defineProperty(exports, "__esModule", {
721
+ value: true
722
+ });
723
+ function _interopRequireDefault(obj) {
724
+ return obj && obj.__esModule ? obj : {
725
+ default: obj
726
+ };
727
+ }
728
+ _chunkB4CUDMY2cjs.__name.call(void 0, _interopRequireDefault, "_interopRequireDefault");
729
+ var _worker_threads = _chunkB4CUDMY2cjs.__require.call(void 0, "worker_threads");
730
+ var _picocolors = _chunkB4CUDMY2cjs.__require.call(void 0, "picocolors");
731
+ var _picocolors2 = _interopRequireDefault(_picocolors);
732
+ var PrettyError = class extends Error {
733
+ static {
734
+ _chunkB4CUDMY2cjs.__name.call(void 0, this, "PrettyError");
735
+ }
736
+ constructor(message) {
737
+ super(message);
738
+ this.name = this.constructor.name;
739
+ if (typeof Error.captureStackTrace === "function") {
740
+ Error.captureStackTrace(this, this.constructor);
741
+ } else {
742
+ this.stack = new Error(message).stack;
743
+ }
744
+ }
745
+ };
746
+ function handleError(error) {
747
+ if (error.loc) {
748
+ console.error(_picocolors2.default.bold(_picocolors2.default.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)));
749
+ }
750
+ if (error.frame) {
751
+ console.error(_picocolors2.default.red(error.message));
752
+ console.error(_picocolors2.default.dim(error.frame));
753
+ } else if (error instanceof PrettyError) {
754
+ console.error(_picocolors2.default.red(error.message));
755
+ } else {
756
+ console.error(_picocolors2.default.red(error.stack));
757
+ }
758
+ process.exitCode = 1;
759
+ if (!_worker_threads.isMainThread && _worker_threads.parentPort) {
760
+ _worker_threads.parentPort.postMessage("error");
761
+ }
762
+ }
763
+ _chunkB4CUDMY2cjs.__name.call(void 0, handleError, "handleError");
764
+ exports.PrettyError = PrettyError;
765
+ exports.handleError = handleError;
766
+ }
767
+ });
768
+
769
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/index.js
770
+ var require_dist = _chunkB4CUDMY2cjs.__commonJS.call(void 0, {
771
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/index.js"(exports) {
772
+ "use strict";
773
+ Object.defineProperty(exports, "__esModule", {
774
+ value: true
775
+ });
776
+ function _interopRequireWildcard(obj) {
777
+ if (obj && obj.__esModule) {
778
+ return obj;
779
+ } else {
780
+ var newObj = {};
781
+ if (obj != null) {
782
+ for (var key in obj) {
783
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
784
+ newObj[key] = obj[key];
785
+ }
786
+ }
787
+ }
788
+ newObj.default = obj;
789
+ return newObj;
790
+ }
791
+ }
792
+ _chunkB4CUDMY2cjs.__name.call(void 0, _interopRequireWildcard, "_interopRequireWildcard");
793
+ function _interopRequireDefault(obj) {
794
+ return obj && obj.__esModule ? obj : {
795
+ default: obj
796
+ };
797
+ }
798
+ _chunkB4CUDMY2cjs.__name.call(void 0, _interopRequireDefault, "_interopRequireDefault");
799
+ function _nullishCoalesce(lhs, rhsFn) {
800
+ if (lhs != null) {
801
+ return lhs;
802
+ } else {
803
+ return rhsFn();
804
+ }
805
+ }
806
+ _chunkB4CUDMY2cjs.__name.call(void 0, _nullishCoalesce, "_nullishCoalesce");
807
+ function _optionalChain(ops) {
808
+ let lastAccessLHS = void 0;
809
+ let value = ops[0];
810
+ let i = 1;
811
+ while (i < ops.length) {
812
+ const op = ops[i];
813
+ const fn = ops[i + 1];
814
+ i += 2;
815
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
816
+ return void 0;
817
+ }
818
+ if (op === "access" || op === "optionalAccess") {
819
+ lastAccessLHS = value;
820
+ value = fn(value);
821
+ } else if (op === "call" || op === "optionalCall") {
822
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
823
+ lastAccessLHS = void 0;
824
+ }
825
+ }
826
+ return value;
827
+ }
828
+ _chunkB4CUDMY2cjs.__name.call(void 0, _optionalChain, "_optionalChain");
829
+ var _class;
830
+ var _chunkBYH4XDRHjs = require_chunk_BYH4XDRH();
831
+ var _chunkVGC3FXLUjs = require_chunk_VGC3FXLU();
832
+ var _chunkJZ25TPTYjs = require_chunk_JZ25TPTY();
833
+ var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
834
+ var _path = _chunkB4CUDMY2cjs.__require.call(void 0, "path");
835
+ var _path2 = _interopRequireDefault(_path);
836
+ var _fs = _chunkB4CUDMY2cjs.__require.call(void 0, "fs");
837
+ var _fs2 = _interopRequireDefault(_fs);
838
+ var _worker_threads = _chunkB4CUDMY2cjs.__require.call(void 0, "worker_threads");
839
+ var _bundlerequire = _chunkB4CUDMY2cjs.__require.call(void 0, "bundle-require");
840
+ var _tinyexec = _chunkB4CUDMY2cjs.__require.call(void 0, "tinyexec");
841
+ var _tinyglobby = _chunkB4CUDMY2cjs.__require.call(void 0, "tinyglobby");
842
+ var _treekill = _chunkB4CUDMY2cjs.__require.call(void 0, "tree-kill");
843
+ var _treekill2 = _interopRequireDefault(_treekill);
844
+ var _esbuild = _chunkB4CUDMY2cjs.__require.call(void 0, "esbuild");
845
+ var _consola = _chunkB4CUDMY2cjs.__require.call(void 0, "consola");
846
+ var _consola2 = _interopRequireDefault(_consola);
847
+ var nodeProtocolPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
848
+ const nodeProtocol = "node:";
849
+ return {
850
+ name: "node-protocol-plugin",
851
+ setup({ onResolve }) {
852
+ onResolve({
853
+ filter: /^node:/
854
+ }, ({ path: path12 }) => ({
855
+ path: path12.slice(nodeProtocol.length),
856
+ external: true
857
+ }));
858
+ }
859
+ };
860
+ }, "nodeProtocolPlugin");
861
+ var NON_NODE_MODULE_RE = /^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/;
862
+ var externalPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ external, noExternal, skipNodeModulesBundle, tsconfigResolvePaths }) => {
863
+ return {
864
+ name: `external`,
865
+ setup(build22) {
866
+ if (skipNodeModulesBundle) {
867
+ const resolvePatterns = _bundlerequire.tsconfigPathsToRegExp.call(void 0, tsconfigResolvePaths || {});
868
+ build22.onResolve({
869
+ filter: /.*/
870
+ }, (args) => {
871
+ if (_bundlerequire.match.call(void 0, args.path, resolvePatterns)) {
872
+ return;
873
+ }
874
+ if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
875
+ return;
876
+ }
877
+ if (_bundlerequire.match.call(void 0, args.path, external)) {
878
+ return {
879
+ external: true
880
+ };
881
+ }
882
+ if (!NON_NODE_MODULE_RE.test(args.path)) {
883
+ return {
884
+ path: args.path,
885
+ external: true
886
+ };
887
+ }
888
+ });
889
+ } else {
890
+ build22.onResolve({
891
+ filter: /.*/
892
+ }, (args) => {
893
+ if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
894
+ return;
895
+ }
896
+ if (_bundlerequire.match.call(void 0, args.path, external)) {
897
+ return {
898
+ external: true
899
+ };
900
+ }
901
+ });
902
+ }
903
+ }
904
+ };
905
+ }, "externalPlugin");
906
+ var postcssPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ options: options1, css, inject, cssLoader }) => {
907
+ return {
908
+ name: "postcss",
909
+ setup(build22) {
910
+ let configCache;
911
+ const getPostcssConfig = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
912
+ const loadConfig = _chunkTWFEYLU4js.__require.call(void 0, "postcss-load-config");
913
+ if (configCache) {
914
+ return configCache;
915
+ }
916
+ try {
917
+ const result = await loadConfig({}, _optionalChain2([options1, 'access', _44 => _44.workspaceConfig, 'optionalAccess', _45 => _45.workspaceRoot]) || process.cwd());
918
+ configCache = result;
919
+ return result;
920
+ } catch (error) {
921
+ if (error.message.includes("No PostCSS Config found in")) {
922
+ const result = {
923
+ plugins: [],
924
+ options: {}
925
+ };
926
+ return result;
927
+ }
928
+ throw error;
929
+ }
930
+ }, "getPostcssConfig");
931
+ build22.onResolve({
932
+ filter: /^#style-inject$/
933
+ }, () => {
934
+ return {
935
+ path: "#style-inject",
936
+ namespace: "#style-inject"
937
+ };
938
+ });
939
+ build22.onLoad({
940
+ filter: /^#style-inject$/,
941
+ namespace: "#style-inject"
942
+ }, () => {
943
+ return {
944
+ // Taken from https://github.com/egoist/style-inject/blob/master/src/index.js (MIT)
945
+ contents: `
946
+ export default function styleInject(css, { insertAt } = {}) {
947
+ if (!css || typeof document === 'undefined') return
948
+
949
+ const head = document.head || document.getElementsByTagName('head')[0]
950
+ const style = document.createElement('style')
951
+ style.type = 'text/css'
952
+
953
+ if (insertAt === 'top') {
954
+ if (head.firstChild) {
955
+ head.insertBefore(style, head.firstChild)
956
+ } else {
957
+ head.appendChild(style)
958
+ }
959
+ } else {
960
+ head.appendChild(style)
961
+ }
962
+
963
+ if (style.styleSheet) {
964
+ style.styleSheet.cssText = css
965
+ } else {
966
+ style.appendChild(document.createTextNode(css))
967
+ }
968
+ }
969
+ `,
970
+ loader: "js"
971
+ };
972
+ });
973
+ build22.onLoad({
974
+ filter: /\.css$/
975
+ }, async (args) => {
976
+ let contents;
977
+ if (css && args.path.endsWith(".svelte.css")) {
978
+ contents = css.get(args.path);
979
+ } else {
980
+ contents = await _fs2.default.promises.readFile(args.path, "utf8");
981
+ }
982
+ const { plugins, options: options12 } = await getPostcssConfig();
983
+ if (plugins && plugins.length > 0) {
984
+ const postcss = _chunkTWFEYLU4js.getPostcss.call(void 0);
985
+ if (!postcss) {
986
+ return {
987
+ errors: [
988
+ {
989
+ text: `postcss is not installed`
990
+ }
991
+ ]
992
+ };
993
+ }
994
+ const result = await _optionalChain([
995
+ postcss,
996
+ "optionalAccess",
997
+ (_2) => _2.default,
998
+ "call",
999
+ (_3) => _3(plugins),
1000
+ "access",
1001
+ (_4) => _4.process,
1002
+ "call",
1003
+ (_5) => _5(contents, {
1004
+ ...options12,
1005
+ from: args.path
1006
+ })
1007
+ ]);
1008
+ contents = result.css;
1009
+ }
1010
+ if (inject) {
1011
+ contents = (await _esbuild.transform.call(void 0, contents, {
1012
+ minify: build22.initialOptions.minify,
1013
+ minifyIdentifiers: build22.initialOptions.minifyIdentifiers,
1014
+ minifySyntax: build22.initialOptions.minifySyntax,
1015
+ minifyWhitespace: build22.initialOptions.minifyWhitespace,
1016
+ logLevel: build22.initialOptions.logLevel,
1017
+ loader: "css"
1018
+ })).code;
1019
+ contents = typeof inject === "function" ? await inject(JSON.stringify(contents), args.path) : `import styleInject from '#style-inject';styleInject(${JSON.stringify(contents)})`;
1020
+ return {
1021
+ contents,
1022
+ loader: "js"
1023
+ };
1024
+ }
1025
+ return {
1026
+ contents,
1027
+ loader: _nullishCoalesce(cssLoader, () => "css")
1028
+ };
1029
+ });
1030
+ }
1031
+ };
1032
+ }, "postcssPlugin");
1033
+ var useSvelteCssExtension = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (p) => p.replace(/\.svelte$/, ".svelte.css"), "useSvelteCssExtension");
1034
+ var sveltePlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ css, options: options1 }) => {
1035
+ return {
1036
+ name: "svelte",
1037
+ setup(build22) {
1038
+ let svelte;
1039
+ let sveltePreprocessor;
1040
+ build22.onResolve({
1041
+ filter: /\.svelte\.css$/
1042
+ }, (args) => {
1043
+ return {
1044
+ path: _path2.default.relative(_optionalChain2([options1, 'access', _46 => _46.workspaceConfig, 'optionalAccess', _47 => _47.workspaceRoot]) || process.cwd(), _path2.default.join(args.resolveDir, args.path)),
1045
+ namespace: "svelte-css"
1046
+ };
1047
+ });
1048
+ build22.onLoad({
1049
+ filter: /\.svelte$/
1050
+ }, async (args) => {
1051
+ svelte = svelte || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte/compiler");
1052
+ sveltePreprocessor = sveltePreprocessor || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte-preprocess");
1053
+ if (!svelte) {
1054
+ return {
1055
+ errors: [
1056
+ {
1057
+ text: `You need to install "svelte" in your project`
1058
+ }
1059
+ ]
1060
+ };
1061
+ }
1062
+ const convertMessage = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ message, start, end }) => {
1063
+ let location;
1064
+ if (start && end) {
1065
+ const lineText = source.split(/\r\n|\r|\n/g)[start.line - 1];
1066
+ const lineEnd = start.line === end.line ? end.column : lineText.length;
1067
+ location = {
1068
+ file: filename,
1069
+ line: start.line,
1070
+ column: start.column,
1071
+ length: lineEnd - start.column,
1072
+ lineText
1073
+ };
1074
+ }
1075
+ return {
1076
+ text: message,
1077
+ location
1078
+ };
1079
+ }, "convertMessage");
1080
+ const source = await _fs2.default.promises.readFile(args.path, "utf8");
1081
+ const filename = _path2.default.relative(_optionalChain2([options1, 'access', _48 => _48.workspaceConfig, 'optionalAccess', _49 => _49.workspaceRoot]) || process.cwd(), args.path);
1082
+ try {
1083
+ const preprocess = await svelte.preprocess(source, sveltePreprocessor ? sveltePreprocessor({
1084
+ sourceMap: true,
1085
+ typescript: {
1086
+ compilerOptions: {
1087
+ verbatimModuleSyntax: true
1088
+ }
1089
+ }
1090
+ }) : {
1091
+ async script({ content, attributes }) {
1092
+ if (attributes.lang !== "ts") return {
1093
+ code: content
1094
+ };
1095
+ const { code, map } = await _esbuild.transform.call(void 0, content, {
1096
+ sourcefile: args.path,
1097
+ loader: "ts",
1098
+ sourcemap: true,
1099
+ tsconfigRaw: {
1100
+ compilerOptions: {
1101
+ verbatimModuleSyntax: true
1102
+ }
1103
+ },
1104
+ logLevel: build22.initialOptions.logLevel
1105
+ });
1106
+ return {
1107
+ code,
1108
+ map
1109
+ };
1110
+ }
1111
+ }, {
1112
+ filename: args.path
1113
+ });
1114
+ const result = svelte.compile(preprocess.code, {
1115
+ filename,
1116
+ css: "external"
1117
+ });
1118
+ let contents = result.js.code;
1119
+ if (css && result.css && result.css.code) {
1120
+ const cssPath = useSvelteCssExtension(filename);
1121
+ css.set(cssPath, result.css.code);
1122
+ contents = `import '${useSvelteCssExtension(_path2.default.basename(args.path))}';${contents}`;
1123
+ }
1124
+ return {
1125
+ contents,
1126
+ warnings: result.warnings.map(convertMessage)
1127
+ };
1128
+ } catch (error) {
1129
+ return {
1130
+ errors: [
1131
+ convertMessage(error)
1132
+ ]
1133
+ };
1134
+ }
1135
+ });
1136
+ }
1137
+ };
1138
+ }, "sveltePlugin");
1139
+ var swcPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ logger: logger3 }) => {
1140
+ return {
1141
+ name: "swc",
1142
+ setup(build22) {
1143
+ const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
1144
+ if (!swc) {
1145
+ logger3.warn(build22.initialOptions.format, `You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin`);
1146
+ return;
1147
+ }
1148
+ build22.initialOptions.keepNames = true;
1149
+ build22.onLoad({
1150
+ filter: /\.[jt]sx?$/
1151
+ }, async (args) => {
1152
+ const isTs = /\.tsx?$/.test(args.path);
1153
+ const jsc = {
1154
+ parser: {
1155
+ syntax: isTs ? "typescript" : "ecmascript",
1156
+ decorators: true
1157
+ },
1158
+ transform: {
1159
+ legacyDecorator: true,
1160
+ decoratorMetadata: true
1161
+ },
1162
+ keepClassNames: true,
1163
+ target: "es2022"
1164
+ };
1165
+ const result = await swc.transformFile(args.path, {
1166
+ jsc,
1167
+ sourceMaps: true,
1168
+ configFile: false,
1169
+ swcrc: false
1170
+ });
1171
+ let code = result.code;
1172
+ if (result.map) {
1173
+ const map = JSON.parse(result.map);
1174
+ map.sources = map.sources.map((source) => {
1175
+ return _path2.default.isAbsolute(source) ? _path2.default.relative(_path2.default.dirname(args.path), source) : source;
1176
+ });
1177
+ code += `//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(map)).toString("base64")}`;
1178
+ }
1179
+ return {
1180
+ contents: code
1181
+ };
1182
+ });
1183
+ }
1184
+ };
1185
+ }, "swcPlugin");
1186
+ var nativeNodeModulesPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1187
+ return {
1188
+ name: "native-node-modules",
1189
+ setup(build22) {
1190
+ build22.onResolve({
1191
+ filter: /\.node$/,
1192
+ namespace: "file"
1193
+ }, (args) => {
1194
+ const resolvedId = _chunkTWFEYLU4js.__require.resolve(args.path, {
1195
+ paths: [
1196
+ args.resolveDir
1197
+ ]
1198
+ });
1199
+ if (resolvedId.endsWith(".node")) {
1200
+ return {
1201
+ path: resolvedId,
1202
+ namespace: "node-file"
1203
+ };
1204
+ }
1205
+ return {
1206
+ path: resolvedId
1207
+ };
1208
+ });
1209
+ build22.onLoad({
1210
+ filter: /.*/,
1211
+ namespace: "node-file"
1212
+ }, (args) => {
1213
+ return {
1214
+ contents: `
1215
+ import path from ${JSON.stringify(args.path)}
1216
+ try { module.exports = require(path) }
1217
+ catch {}
1218
+ `,
1219
+ resolveDir: _path2.default.dirname(args.path)
1220
+ };
1221
+ });
1222
+ build22.onResolve({
1223
+ filter: /\.node$/,
1224
+ namespace: "node-file"
1225
+ }, (args) => ({
1226
+ path: args.path,
1227
+ namespace: "file"
1228
+ }));
1229
+ const opts = build22.initialOptions;
1230
+ opts.loader = opts.loader || {};
1231
+ opts.loader[".node"] = "file";
1232
+ }
1233
+ };
1234
+ }, "nativeNodeModulesPlugin");
1235
+ var getOutputExtensionMap = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (options1, format, pkgType) => {
1236
+ const outExtension = options1.outExtension || _chunkTWFEYLU4js.defaultOutExtension;
1237
+ const defaultExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, {
1238
+ format,
1239
+ pkgType
1240
+ });
1241
+ const extension = outExtension({
1242
+ options: options1,
1243
+ format,
1244
+ pkgType
1245
+ });
1246
+ return {
1247
+ ".js": extension.js || defaultExtension.js
1248
+ };
1249
+ }, "getOutputExtensionMap");
1250
+ var generateExternal = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (external) => {
1251
+ const result = [];
1252
+ for (const item of external) {
1253
+ if (typeof item !== "string" || !item.endsWith("package.json")) {
1254
+ result.push(item);
1255
+ continue;
1256
+ }
1257
+ const pkgPath = _path2.default.isAbsolute(item) ? _path2.default.dirname(item) : _path2.default.dirname(_path2.default.resolve(_optionalChain2([options, 'access', _50 => _50.workspaceConfig, 'optionalAccess', _51 => _51.workspaceRoot]) || process.cwd(), item));
1258
+ const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, pkgPath);
1259
+ result.push(...deps);
1260
+ }
1261
+ return result;
1262
+ }, "generateExternal");
1263
+ async function runEsbuild(options1, { format, css, logger: logger3, buildDependencies, pluginContainer }) {
1264
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, _optionalChain2([options1, 'access', _52 => _52.workspaceConfig, 'optionalAccess', _53 => _53.workspaceRoot]) || process.cwd());
1265
+ const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, _optionalChain2([options1, 'access', _54 => _54.workspaceConfig, 'optionalAccess', _55 => _55.workspaceRoot]) || process.cwd());
1266
+ const external = [
1267
+ // Exclude dependencies, e.g. `lodash`, `lodash/get`
1268
+ ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
1269
+ ...await generateExternal(options1.external || [])
1270
+ ];
1271
+ const outDir = options1.outDir;
1272
+ const outExtension = getOutputExtensionMap(options1, format, pkg.type);
1273
+ const env = {
1274
+ ...options1.env
1275
+ };
1276
+ if (options1.replaceNodeEnv) {
1277
+ env.NODE_ENV = options1.minify || options1.minifyWhitespace ? "production" : "development";
1278
+ }
1279
+ logger3.info(format, "Build start");
1280
+ const startTime = Date.now();
1281
+ let result;
1282
+ const splitting = format === "iife" ? false : typeof options1.splitting === "boolean" ? options1.splitting : format === "esm";
1283
+ const platform = options1.platform || "node";
1284
+ const loader = options1.loader || {};
1285
+ const injectShims = options1.shims;
1286
+ pluginContainer.setContext({
1287
+ format,
1288
+ splitting,
1289
+ options: options1,
1290
+ logger: logger3
1291
+ });
1292
+ await pluginContainer.buildStarted();
1293
+ const esbuildPlugins = [
1294
+ format === "cjs" && options1.removeNodeProtocol && nodeProtocolPlugin(),
1295
+ {
1296
+ name: "modify-options",
1297
+ setup(build22) {
1298
+ pluginContainer.modifyEsbuildOptions(build22.initialOptions);
1299
+ if (options1.esbuildOptions) {
1300
+ options1.esbuildOptions(build22.initialOptions, {
1301
+ format
1302
+ });
1303
+ }
1304
+ }
1305
+ },
1306
+ // esbuild's `external` option doesn't support RegExp
1307
+ // So here we use a custom plugin to implement it
1308
+ format !== "iife" && externalPlugin({
1309
+ external,
1310
+ noExternal: options1.noExternal,
1311
+ skipNodeModulesBundle: options1.skipNodeModulesBundle,
1312
+ tsconfigResolvePaths: options1.tsconfigResolvePaths
1313
+ }),
1314
+ options1.tsconfigDecoratorMetadata && swcPlugin({
1315
+ logger: logger3
1316
+ }),
1317
+ nativeNodeModulesPlugin(),
1318
+ postcssPlugin({
1319
+ options: options1,
1320
+ css,
1321
+ inject: options1.injectStyle,
1322
+ cssLoader: loader[".css"]
1323
+ }),
1324
+ sveltePlugin({
1325
+ css,
1326
+ options: options1
1327
+ }),
1328
+ ...options1.esbuildPlugins || []
1329
+ ];
1330
+ const banner = typeof options1.banner === "function" ? options1.banner({
1331
+ format
1332
+ }) : options1.banner;
1333
+ const footer = typeof options1.footer === "function" ? options1.footer({
1334
+ format
1335
+ }) : options1.footer;
1336
+ try {
1337
+ result = await _esbuild.build.call(void 0, {
1338
+ entryPoints: options1.entry,
1339
+ format: format === "cjs" && splitting || options1.treeshake ? "esm" : format,
1340
+ bundle: typeof options1.bundle === "undefined" ? true : options1.bundle,
1341
+ platform,
1342
+ globalName: options1.globalName,
1343
+ jsxFactory: options1.jsxFactory,
1344
+ jsxFragment: options1.jsxFragment,
1345
+ sourcemap: options1.sourcemap ? "external" : false,
1346
+ target: options1.target,
1347
+ banner,
1348
+ footer,
1349
+ tsconfig: options1.tsconfig,
1350
+ loader: {
1351
+ ".aac": "file",
1352
+ ".css": "file",
1353
+ ".eot": "file",
1354
+ ".flac": "file",
1355
+ ".gif": "file",
1356
+ ".jpeg": "file",
1357
+ ".jpg": "file",
1358
+ ".mp3": "file",
1359
+ ".mp4": "file",
1360
+ ".ogg": "file",
1361
+ ".otf": "file",
1362
+ ".png": "file",
1363
+ ".svg": "file",
1364
+ ".ttf": "file",
1365
+ ".wav": "file",
1366
+ ".webm": "file",
1367
+ ".webp": "file",
1368
+ ".woff": "file",
1369
+ ".woff2": "file",
1370
+ ...loader
1371
+ },
1372
+ mainFields: platform === "node" ? [
1373
+ "module",
1374
+ "main"
1375
+ ] : [
1376
+ "browser",
1377
+ "module",
1378
+ "main"
1379
+ ],
1380
+ plugins: esbuildPlugins.filter(_chunkTWFEYLU4js.truthy),
1381
+ define: {
1382
+ TSUP_FORMAT: JSON.stringify(format),
1383
+ ...format === "cjs" && injectShims ? {
1384
+ "import.meta.url": "importMetaUrl"
1385
+ } : {},
1386
+ ...options1.define,
1387
+ ...Object.keys(env).reduce((res, key) => {
1388
+ const value = JSON.stringify(env[key]);
1389
+ return {
1390
+ ...res,
1391
+ [`process.env.${key}`]: value,
1392
+ [`import.meta.env.${key}`]: value
1393
+ };
1394
+ }, {})
1395
+ },
1396
+ inject: [
1397
+ format === "cjs" && injectShims ? _path2.default.join(__dirname, "../assets/cjs_shims.js") : "",
1398
+ format === "esm" && injectShims && platform === "node" ? _path2.default.join(__dirname, "../assets/esm_shims.js") : "",
1399
+ ...options1.inject || []
1400
+ ].filter(Boolean),
1401
+ outdir: options1.legacyOutput && format !== "cjs" ? _path2.default.join(outDir, format) : outDir,
1402
+ outExtension: options1.legacyOutput ? void 0 : outExtension,
1403
+ write: false,
1404
+ splitting,
1405
+ logLevel: "error",
1406
+ minify: options1.minify === "terser" ? false : options1.minify,
1407
+ minifyWhitespace: options1.minifyWhitespace,
1408
+ minifyIdentifiers: options1.minifyIdentifiers,
1409
+ minifySyntax: options1.minifySyntax,
1410
+ keepNames: options1.keepNames,
1411
+ pure: typeof options1.pure === "string" ? [
1412
+ options1.pure
1413
+ ] : options1.pure,
1414
+ metafile: true
1415
+ });
1416
+ } catch (error) {
1417
+ logger3.error(format, "Build failed");
1418
+ throw error;
1419
+ }
1420
+ if (result && result.warnings && !_chunkVGC3FXLUjs.getSilent.call(void 0)) {
1421
+ const messages = result.warnings.filter((warning) => {
1422
+ if (warning.text.includes(`This call to "require" will not be bundled because`) || warning.text.includes(`Indirect calls to "require" will not be bundled`)) return false;
1423
+ return true;
1424
+ });
1425
+ const formatted = await _esbuild.formatMessages.call(void 0, messages, {
1426
+ kind: "warning",
1427
+ color: true
1428
+ });
1429
+ formatted.forEach((message) => {
1430
+ _consola2.default.warn(message);
1431
+ });
1432
+ }
1433
+ if (result && result.outputFiles) {
1434
+ await pluginContainer.buildFinished({
1435
+ options: options1,
1436
+ outputFiles: result.outputFiles,
1437
+ metafile: result.metafile
1438
+ });
1439
+ const timeInMs = Date.now() - startTime;
1440
+ logger3.success(format, `\u26A1\uFE0F Build success in ${Math.floor(timeInMs)}ms`);
1441
+ }
1442
+ if (result.metafile) {
1443
+ for (const file of Object.keys(result.metafile.inputs)) {
1444
+ buildDependencies.add(file);
1445
+ }
1446
+ if (options1.metafile) {
1447
+ const outPath = _path2.default.resolve(outDir, `metafile-${format}.json`);
1448
+ await _fs2.default.promises.mkdir(_path2.default.dirname(outPath), {
1449
+ recursive: true
1450
+ });
1451
+ await _fs2.default.promises.writeFile(outPath, JSON.stringify(result.metafile), "utf8");
1452
+ }
1453
+ }
1454
+ }
1455
+ _chunkB4CUDMY2cjs.__name.call(void 0, runEsbuild, "runEsbuild");
1456
+ var shebang = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1457
+ return {
1458
+ name: "shebang",
1459
+ renderChunk(_, info) {
1460
+ if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) {
1461
+ info.mode = 493;
1462
+ }
1463
+ }
1464
+ };
1465
+ }, "shebang");
1466
+ var cjsSplitting = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1467
+ return {
1468
+ name: "cjs-splitting",
1469
+ async renderChunk(code, info) {
1470
+ if (!this.splitting || this.options.treeshake || // <-- handled by rollup
1471
+ this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path)) {
1472
+ return;
1473
+ }
1474
+ const { transform: transform3 } = await Promise.resolve().then(() => _interopRequireWildcard(_chunkB4CUDMY2cjs.__require.call(void 0, "sucrase")));
1475
+ const result = transform3(code, {
1476
+ filePath: info.path,
1477
+ transforms: [
1478
+ "imports"
1479
+ ],
1480
+ sourceMapOptions: this.options.sourcemap ? {
1481
+ compiledFilename: info.path
1482
+ } : void 0
1483
+ });
1484
+ return {
1485
+ code: result.code,
1486
+ map: result.sourceMap
1487
+ };
1488
+ }
1489
+ };
1490
+ }, "cjsSplitting");
1491
+ var _sourcemap = _chunkB4CUDMY2cjs.__require.call(void 0, "source-map");
1492
+ var outputFile = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (filepath, data, options1) => {
1493
+ await _fs2.default.promises.mkdir(_path2.default.dirname(filepath), {
1494
+ recursive: true
1495
+ });
1496
+ await _fs2.default.promises.writeFile(filepath, data, options1);
1497
+ }, "outputFile");
1498
+ function copyDirSync(srcDir, destDir) {
1499
+ if (!_fs2.default.existsSync(srcDir)) return;
1500
+ _fs2.default.mkdirSync(destDir, {
1501
+ recursive: true
1502
+ });
1503
+ for (const file of _fs2.default.readdirSync(srcDir)) {
1504
+ const srcFile = _path2.default.resolve(srcDir, file);
1505
+ if (srcFile === destDir) {
1506
+ continue;
1507
+ }
1508
+ const destFile = _path2.default.resolve(destDir, file);
1509
+ const stat = _fs2.default.statSync(srcFile);
1510
+ if (stat.isDirectory()) {
1511
+ copyDirSync(srcFile, destFile);
1512
+ } else {
1513
+ _fs2.default.copyFileSync(srcFile, destFile);
1514
+ }
1515
+ }
1516
+ }
1517
+ _chunkB4CUDMY2cjs.__name.call(void 0, copyDirSync, "copyDirSync");
1518
+ var parseSourceMap = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (map) => {
1519
+ return typeof map === "string" ? JSON.parse(map) : map;
1520
+ }, "parseSourceMap");
1521
+ var isJS = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (path12) => /\.(js|mjs|cjs)$/.test(path12), "isJS");
1522
+ var isCSS = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (path12) => /\.css$/.test(path12), "isCSS");
1523
+ var PluginContainer = class {
1524
+ static {
1525
+ _chunkB4CUDMY2cjs.__name.call(void 0, this, "PluginContainer");
1526
+ }
1527
+ constructor(plugins) {
1528
+ this.plugins = plugins;
1529
+ }
1530
+ setContext(context) {
1531
+ this.context = context;
1532
+ }
1533
+ getContext() {
1534
+ if (!this.context) throw new Error(`Plugin context is not set`);
1535
+ return this.context;
1536
+ }
1537
+ modifyEsbuildOptions(options1) {
1538
+ for (const plugin of this.plugins) {
1539
+ if (plugin.esbuildOptions) {
1540
+ plugin.esbuildOptions.call(this.getContext(), options1);
1541
+ }
1542
+ }
1543
+ }
1544
+ async buildStarted() {
1545
+ for (const plugin of this.plugins) {
1546
+ if (plugin.buildStart) {
1547
+ await plugin.buildStart.call(this.getContext());
1548
+ }
1549
+ }
1550
+ }
1551
+ async buildFinished({ options: options1, outputFiles, metafile }) {
1552
+ const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
1553
+ if (isJS(file.path) || isCSS(file.path)) {
1554
+ const relativePath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(_optionalChain2([options1, 'access', _56 => _56.workspaceConfig, 'optionalAccess', _57 => _57.workspaceRoot]) || process.cwd(), file.path));
1555
+ const meta = _optionalChain([
1556
+ metafile,
1557
+ "optionalAccess",
1558
+ (_6) => _6.outputs,
1559
+ "access",
1560
+ (_7) => _7[relativePath]
1561
+ ]);
1562
+ return {
1563
+ type: "chunk",
1564
+ path: file.path,
1565
+ code: file.text,
1566
+ map: _optionalChain([
1567
+ outputFiles,
1568
+ "access",
1569
+ (_8) => _8.find,
1570
+ "call",
1571
+ (_9) => _9((f) => f.path === `${file.path}.map`),
1572
+ "optionalAccess",
1573
+ (_10) => _10.text
1574
+ ]),
1575
+ entryPoint: _optionalChain([
1576
+ meta,
1577
+ "optionalAccess",
1578
+ (_11) => _11.entryPoint
1579
+ ]),
1580
+ exports: _optionalChain([
1581
+ meta,
1582
+ "optionalAccess",
1583
+ (_12) => _12.exports
1584
+ ]),
1585
+ imports: _optionalChain([
1586
+ meta,
1587
+ "optionalAccess",
1588
+ (_13) => _13.imports
1589
+ ])
1590
+ };
1591
+ } else {
1592
+ return {
1593
+ type: "asset",
1594
+ path: file.path,
1595
+ contents: file.contents
1596
+ };
1597
+ }
1598
+ });
1599
+ const writtenFiles = [];
1600
+ await Promise.all(files.map(async (info) => {
1601
+ for (const plugin of this.plugins) {
1602
+ if (info.type === "chunk" && plugin.renderChunk) {
1603
+ const result = await plugin.renderChunk.call(this.getContext(), info.code, info);
1604
+ if (result) {
1605
+ info.code = result.code;
1606
+ if (result.map) {
1607
+ const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(info.map));
1608
+ const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(result.map));
1609
+ const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer);
1610
+ generator.applySourceMap(originalConsumer, info.path);
1611
+ info.map = generator.toJSON();
1612
+ originalConsumer.destroy();
1613
+ newConsumer.destroy();
1614
+ }
1615
+ }
1616
+ }
1617
+ }
1618
+ const inlineSourceMap = this.context.options.sourcemap === "inline";
1619
+ const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents;
1620
+ await outputFile(info.path, contents, {
1621
+ mode: info.type === "chunk" ? info.mode : void 0
1622
+ });
1623
+ writtenFiles.push({
1624
+ get name() {
1625
+ return _path2.default.relative(_optionalChain2([options1, 'access', _58 => _58.workspaceConfig, 'optionalAccess', _59 => _59.workspaceRoot]) || process.cwd(), info.path);
1626
+ },
1627
+ get size() {
1628
+ return contents.length;
1629
+ }
1630
+ });
1631
+ if (info.type === "chunk" && info.map && !inlineSourceMap) {
1632
+ const map = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
1633
+ const outPath = `${info.path}.map`;
1634
+ const contents2 = JSON.stringify(map);
1635
+ await outputFile(outPath, contents2);
1636
+ writtenFiles.push({
1637
+ get name() {
1638
+ return _path2.default.relative(_optionalChain2([options1, 'access', _60 => _60.workspaceConfig, 'optionalAccess', _61 => _61.workspaceRoot]) || process.cwd(), outPath);
1639
+ },
1640
+ get size() {
1641
+ return contents2.length;
1642
+ }
1643
+ });
1644
+ }
1645
+ }));
1646
+ for (const plugin of this.plugins) {
1647
+ if (plugin.buildEnd) {
1648
+ await plugin.buildEnd.call(this.getContext(), {
1649
+ writtenFiles
1650
+ });
1651
+ }
1652
+ }
1653
+ }
1654
+ };
1655
+ var getSourcemapComment = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (inline, map, filepath, isCssFile) => {
1656
+ if (!map) return "";
1657
+ const prefix = isCssFile ? "/*" : "//";
1658
+ const suffix = isCssFile ? " */" : "";
1659
+ const url = inline ? `data:application/json;base64,${Buffer.from(typeof map === "string" ? map : JSON.stringify(map)).toString("base64")}` : `${_path2.default.basename(filepath)}.map`;
1660
+ return `${prefix}# sourceMappingURL=${url}${suffix}`;
1661
+ }, "getSourcemapComment");
1662
+ var TARGETS = [
1663
+ "es5",
1664
+ "es3"
1665
+ ];
1666
+ var swcTarget = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1667
+ let enabled = false;
1668
+ let target;
1669
+ return {
1670
+ name: "swc-target",
1671
+ esbuildOptions(options1) {
1672
+ if (typeof options1.target === "string" && TARGETS.includes(options1.target)) {
1673
+ target = options1.target;
1674
+ options1.target = "es2020";
1675
+ enabled = true;
1676
+ }
1677
+ },
1678
+ async renderChunk(code, info) {
1679
+ if (!enabled || !/\.(cjs|mjs|js)$/.test(info.path)) {
1680
+ return;
1681
+ }
1682
+ const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
1683
+ if (!swc) {
1684
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`@swc/core is required for ${target} target. Please install it with \`npm install @swc/core -D\``);
1685
+ }
1686
+ const result = await swc.transform(code, {
1687
+ filename: info.path,
1688
+ sourceMaps: this.options.sourcemap,
1689
+ minify: Boolean(this.options.minify),
1690
+ jsc: {
1691
+ target,
1692
+ parser: {
1693
+ syntax: "ecmascript"
1694
+ },
1695
+ minify: this.options.minify === true ? {
1696
+ compress: false,
1697
+ mangle: {
1698
+ reserved: this.options.globalName ? [
1699
+ this.options.globalName
1700
+ ] : []
1701
+ }
1702
+ } : void 0
1703
+ },
1704
+ module: {
1705
+ type: this.format === "cjs" ? "commonjs" : "es6"
1706
+ }
1707
+ });
1708
+ return {
1709
+ code: result.code,
1710
+ map: result.map
1711
+ };
1712
+ }
1713
+ };
1714
+ }, "swcTarget");
1715
+ var sizeReporter = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1716
+ return {
1717
+ name: "size-reporter",
1718
+ buildEnd({ writtenFiles }) {
1719
+ _chunkVGC3FXLUjs.reportSize.call(void 0, this.logger, this.format, writtenFiles.reduce((res, file) => {
1720
+ return {
1721
+ ...res,
1722
+ [file.name]: file.size
1723
+ };
1724
+ }, {}));
1725
+ }
1726
+ };
1727
+ }, "sizeReporter");
1728
+ var _rollup = _chunkB4CUDMY2cjs.__require.call(void 0, "rollup");
1729
+ var treeShakingPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ treeshake, name, silent }) => {
1730
+ return {
1731
+ name: "tree-shaking",
1732
+ async renderChunk(code, info) {
1733
+ if (!treeshake || !/\.(cjs|js|mjs)$/.test(info.path)) return;
1734
+ const bundle = await _rollup.rollup.call(void 0, {
1735
+ input: [
1736
+ info.path
1737
+ ],
1738
+ plugins: [
1739
+ {
1740
+ name: "tsup",
1741
+ resolveId(source) {
1742
+ if (source === info.path) return source;
1743
+ return false;
1744
+ },
1745
+ load(id) {
1746
+ if (id === info.path) return {
1747
+ code,
1748
+ map: info.map
1749
+ };
1750
+ }
1751
+ }
1752
+ ],
1753
+ treeshake,
1754
+ makeAbsoluteExternalsRelative: false,
1755
+ preserveEntrySignatures: "exports-only",
1756
+ onwarn: silent ? () => {
1757
+ } : void 0
1758
+ });
1759
+ const result = await bundle.generate({
1760
+ interop: "auto",
1761
+ format: this.format,
1762
+ file: info.path,
1763
+ sourcemap: !!this.options.sourcemap,
1764
+ compact: !!this.options.minify,
1765
+ name
1766
+ });
1767
+ for (const file of result.output) {
1768
+ if (file.type === "chunk" && file.fileName === _path2.default.basename(info.path)) {
1769
+ return {
1770
+ code: file.code,
1771
+ map: file.map
1772
+ };
1773
+ }
1774
+ }
1775
+ }
1776
+ };
1777
+ }, "treeShakingPlugin");
1778
+ var copyPublicDir = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (publicDir, outDir) => {
1779
+ if (!publicDir) return;
1780
+ copyDirSync(_path2.default.resolve(publicDir === true ? "public" : publicDir), outDir);
1781
+ }, "copyPublicDir");
1782
+ var isInPublicDir = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (publicDir, filePath) => {
1783
+ if (!publicDir) return false;
1784
+ const publicPath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.resolve(publicDir === true ? "public" : publicDir));
1785
+ return _chunkTWFEYLU4js.slash.call(void 0, _path2.default.resolve(filePath)).startsWith(`${publicPath}/`);
1786
+ }, "isInPublicDir");
1787
+ var terserPlugin = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ minifyOptions, format, terserOptions = {}, globalName, logger: logger3 }) => {
1788
+ return {
1789
+ name: "terser",
1790
+ async renderChunk(code, info) {
1791
+ if (minifyOptions !== "terser" || !/\.(cjs|js|mjs)$/.test(info.path)) return;
1792
+ const terser = _chunkTWFEYLU4js.localRequire.call(void 0, "terser");
1793
+ if (!terser) {
1794
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)("terser is required for terser minification. Please install it with `npm install terser -D`");
1795
+ }
1796
+ const { minify } = terser;
1797
+ const defaultOptions = {};
1798
+ if (format === "esm") {
1799
+ defaultOptions.module = true;
1800
+ } else if (!(format === "iife" && globalName !== void 0)) {
1801
+ defaultOptions.toplevel = true;
1802
+ }
1803
+ try {
1804
+ const minifiedOutput = await minify({
1805
+ [info.path]: code
1806
+ }, {
1807
+ ...defaultOptions,
1808
+ ...terserOptions
1809
+ });
1810
+ logger3.info("TERSER", "Minifying with Terser");
1811
+ if (!minifiedOutput.code) {
1812
+ logger3.error("TERSER", "Failed to minify with terser");
1813
+ }
1814
+ logger3.success("TERSER", "Terser Minification success");
1815
+ return {
1816
+ code: minifiedOutput.code,
1817
+ map: minifiedOutput.map
1818
+ };
1819
+ } catch (error) {
1820
+ logger3.error("TERSER", "Failed to minify with terser");
1821
+ logger3.error("TERSER", error);
1822
+ }
1823
+ return {
1824
+ code,
1825
+ map: info.map
1826
+ };
1827
+ }
1828
+ };
1829
+ }, "terserPlugin");
1830
+ var _typescript = _chunkB4CUDMY2cjs.__require.call(void 0, "typescript");
1831
+ var _typescript2 = _interopRequireDefault(_typescript);
1832
+ var logger = _chunkVGC3FXLUjs.createLogger.call(void 0);
1833
+ var AliasPool = (_class = class {
1834
+ static {
1835
+ _chunkB4CUDMY2cjs.__name.call(void 0, this, "_class");
1836
+ }
1837
+ constructor() {
1838
+ _class.prototype.__init.call(this);
1839
+ }
1840
+ __init() {
1841
+ this.seen = /* @__PURE__ */ new Set();
1842
+ }
1843
+ assign(name) {
1844
+ let suffix = 0;
1845
+ let alias = name === "default" ? "default_alias" : name;
1846
+ while (this.seen.has(alias)) {
1847
+ alias = `${name}_alias_${++suffix}`;
1848
+ if (suffix >= 1e3) {
1849
+ throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
1850
+ }
1851
+ }
1852
+ this.seen.add(alias);
1853
+ return alias;
1854
+ }
1855
+ }, _class);
1856
+ function getExports(program, fileMapping) {
1857
+ const checker = program.getTypeChecker();
1858
+ const aliasPool = new AliasPool();
1859
+ const assignAlias = aliasPool.assign.bind(aliasPool);
1860
+ function extractExports(sourceFileName) {
1861
+ const cwd = program.getCurrentDirectory();
1862
+ sourceFileName = _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd);
1863
+ const sourceFile = program.getSourceFile(sourceFileName);
1864
+ if (!sourceFile) {
1865
+ return [];
1866
+ }
1867
+ const destFileName = fileMapping.get(sourceFileName);
1868
+ if (!destFileName) {
1869
+ return [];
1870
+ }
1871
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
1872
+ if (!moduleSymbol) {
1873
+ return [];
1874
+ }
1875
+ const exports1 = [];
1876
+ const exportSymbols = checker.getExportsOfModule(moduleSymbol);
1877
+ exportSymbols.forEach((symbol) => {
1878
+ const name = symbol.getName();
1879
+ exports1.push({
1880
+ kind: "named",
1881
+ sourceFileName,
1882
+ destFileName,
1883
+ name,
1884
+ alias: assignAlias(name),
1885
+ isTypeOnly: false
1886
+ });
1887
+ });
1888
+ return exports1;
1889
+ }
1890
+ _chunkB4CUDMY2cjs.__name.call(void 0, extractExports, "extractExports");
1891
+ return program.getRootFileNames().flatMap(extractExports);
1892
+ }
1893
+ _chunkB4CUDMY2cjs.__name.call(void 0, getExports, "getExports");
1894
+ function emitDtsFiles(program, host) {
1895
+ const fileMapping = /* @__PURE__ */ new Map();
1896
+ const writeFile = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
1897
+ const sourceFile = _optionalChain([
1898
+ sourceFiles,
1899
+ "optionalAccess",
1900
+ (_14) => _14[0]
1901
+ ]);
1902
+ const sourceFileName = _optionalChain([
1903
+ sourceFile,
1904
+ "optionalAccess",
1905
+ (_15) => _15.fileName
1906
+ ]);
1907
+ if (sourceFileName && !fileName.endsWith(".map")) {
1908
+ const cwd = program.getCurrentDirectory();
1909
+ fileMapping.set(_chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd), _chunkTWFEYLU4js.toAbsolutePath.call(void 0, fileName, cwd));
1910
+ }
1911
+ return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
1912
+ }, "writeFile");
1913
+ const emitResult = program.emit(void 0, writeFile, void 0, true);
1914
+ const diagnostics = _typescript2.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
1915
+ const diagnosticMessages = [];
1916
+ diagnostics.forEach((diagnostic) => {
1917
+ if (diagnostic.file) {
1918
+ const { line, character } = _typescript2.default.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
1919
+ const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
1920
+ diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
1921
+ } else {
1922
+ const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
1923
+ diagnosticMessages.push(message);
1924
+ }
1925
+ });
1926
+ const diagnosticMessage = diagnosticMessages.join("\n");
1927
+ if (diagnosticMessage) {
1928
+ logger.error("TSC", `Failed to emit declaration files.
1929
+
1930
+ ${diagnosticMessage}`);
1931
+ throw new Error("TypeScript compilation failed");
1932
+ }
1933
+ return fileMapping;
1934
+ }
1935
+ _chunkB4CUDMY2cjs.__name.call(void 0, emitDtsFiles, "emitDtsFiles");
1936
+ function emit(compilerOptions, tsconfig, _options) {
1937
+ const cwd = _optionalChain2([_options, 'access', _62 => _62.workspaceConfig, 'optionalAccess', _63 => _63.workspaceRoot]) || process.cwd();
1938
+ let rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, cwd, tsconfig);
1939
+ if (!rawTsconfig) {
1940
+ rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, process.cwd(), tsconfig);
1941
+ if (!rawTsconfig) {
1942
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${cwd}`);
1943
+ }
1944
+ }
1945
+ const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, _options);
1946
+ const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent({
1947
+ ...rawTsconfig.data,
1948
+ compilerOptions: {
1949
+ ..._optionalChain([
1950
+ rawTsconfig,
1951
+ "access",
1952
+ (_16) => _16.data,
1953
+ "optionalAccess",
1954
+ (_17) => _17.compilerOptions
1955
+ ]),
1956
+ ...compilerOptions,
1957
+ // Enable declaration emit and disable javascript emit
1958
+ noEmit: false,
1959
+ declaration: true,
1960
+ declarationMap: true,
1961
+ declarationDir,
1962
+ emitDeclarationOnly: true
1963
+ }
1964
+ }, _typescript2.default.sys, tsconfig ? _path.dirname.call(void 0, tsconfig) : "./");
1965
+ const options1 = parsedTsconfig.options;
1966
+ const host = _typescript2.default.createCompilerHost(options1);
1967
+ const program = _typescript2.default.createProgram(parsedTsconfig.fileNames, options1, host);
1968
+ const fileMapping = emitDtsFiles(program, host);
1969
+ return getExports(program, fileMapping);
1970
+ }
1971
+ _chunkB4CUDMY2cjs.__name.call(void 0, emit, "emit");
1972
+ function runTypeScriptCompiler(options1) {
1973
+ try {
1974
+ const start = Date.now();
1975
+ const getDuration = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
1976
+ return `${Math.floor(Date.now() - start)}ms`;
1977
+ }, "getDuration");
1978
+ logger.info("tsc", "Build start");
1979
+ const dtsOptions = options1.experimentalDts;
1980
+ const exports1 = emit(dtsOptions.compilerOptions, options1.tsconfig, options1);
1981
+ logger.success("tsc", `\u26A1\uFE0F Build success in ${getDuration()}`);
1982
+ return exports1;
1983
+ } catch (error) {
1984
+ _chunkJZ25TPTYjs.handleError.call(void 0, error);
1985
+ logger.error("tsc", "Build error");
1986
+ }
1987
+ }
1988
+ _chunkB4CUDMY2cjs.__name.call(void 0, runTypeScriptCompiler, "runTypeScriptCompiler");
1989
+ function formatAggregationExports(exports1, declarationDirPath) {
1990
+ const lines = exports1.map((declaration) => formatAggregationExport(declaration, declarationDirPath)).filter(_chunkTWFEYLU4js.truthy);
1991
+ if (lines.length === 0) {
1992
+ lines.push("export {};");
1993
+ }
1994
+ return `${lines.join("\n")}
1995
+ `;
1996
+ }
1997
+ _chunkB4CUDMY2cjs.__name.call(void 0, formatAggregationExports, "formatAggregationExports");
1998
+ function formatAggregationExport(declaration, declarationDirPath) {
1999
+ const dest = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(void 0, `./${_path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(declarationDirPath, declaration.destFileName)))}`);
2000
+ if (declaration.kind === "module") {
2001
+ return "";
2002
+ } else if (declaration.kind === "named") {
2003
+ return [
2004
+ "export",
2005
+ declaration.isTypeOnly ? "type" : "",
2006
+ "{",
2007
+ declaration.name,
2008
+ declaration.name === declaration.alias ? "" : `as ${declaration.alias}`,
2009
+ "} from",
2010
+ `'${dest}';`
2011
+ ].filter(_chunkTWFEYLU4js.truthy).join(" ");
2012
+ } else {
2013
+ throw new Error("Unknown declaration");
2014
+ }
2015
+ }
2016
+ _chunkB4CUDMY2cjs.__name.call(void 0, formatAggregationExport, "formatAggregationExport");
2017
+ function formatDistributionExports(exports1, fromFilePath, toFilePath) {
2018
+ let importPath = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(void 0, _path2.default.posix.relative(_path2.default.posix.dirname(_path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, fromFilePath))), _path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, toFilePath))));
2019
+ if (!/^\.+\//.test(importPath)) {
2020
+ importPath = `./${importPath}`;
2021
+ }
2022
+ const seen = {
2023
+ named: /* @__PURE__ */ new Set(),
2024
+ module: /* @__PURE__ */ new Set()
2025
+ };
2026
+ const lines = exports1.filter((declaration) => {
2027
+ if (declaration.kind === "module") {
2028
+ if (seen.module.has(declaration.moduleName)) {
2029
+ return false;
2030
+ }
2031
+ seen.module.add(declaration.moduleName);
2032
+ return true;
2033
+ } else if (declaration.kind === "named") {
2034
+ if (seen.named.has(declaration.name)) {
2035
+ return false;
2036
+ }
2037
+ seen.named.add(declaration.name);
2038
+ return true;
2039
+ } else {
2040
+ return false;
2041
+ }
2042
+ }).map((declaration) => formatDistributionExport(declaration, importPath)).filter(_chunkTWFEYLU4js.truthy);
2043
+ if (lines.length === 0) {
2044
+ lines.push("export {};");
2045
+ }
2046
+ return `${lines.join("\n")}
2047
+ `;
2048
+ }
2049
+ _chunkB4CUDMY2cjs.__name.call(void 0, formatDistributionExports, "formatDistributionExports");
2050
+ function formatDistributionExport(declaration, dest) {
2051
+ if (declaration.kind === "named") {
2052
+ return [
2053
+ "export",
2054
+ declaration.isTypeOnly ? "type" : "",
2055
+ "{",
2056
+ declaration.alias,
2057
+ declaration.name === declaration.alias ? "" : `as ${declaration.name}`,
2058
+ "} from",
2059
+ `'${dest}';`
2060
+ ].filter(_chunkTWFEYLU4js.truthy).join(" ");
2061
+ } else if (declaration.kind === "module") {
2062
+ return `export * from '${declaration.moduleName}';`;
2063
+ }
2064
+ return "";
2065
+ }
2066
+ _chunkB4CUDMY2cjs.__name.call(void 0, formatDistributionExport, "formatDistributionExport");
2067
+ var logger2 = _chunkVGC3FXLUjs.createLogger.call(void 0);
2068
+ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath, options1) {
2069
+ const cwd = _optionalChain2([options1, 'access', _64 => _64.workspaceConfig, 'optionalAccess', _65 => _65.workspaceRoot]) || process.cwd();
2070
+ const packageJsonFullPath = _path2.default.join(cwd, "package.json");
2071
+ const configObject = {
2072
+ mainEntryPointFilePath: inputFilePath,
2073
+ apiReport: {
2074
+ enabled: false,
2075
+ // `reportFileName` is not been used. It's just to fit the requirement of API Extractor.
2076
+ reportFileName: "tsup-report.api.md"
2077
+ },
2078
+ docModel: {
2079
+ enabled: false
2080
+ },
2081
+ dtsRollup: {
2082
+ enabled: true,
2083
+ untrimmedFilePath: outputFilePath
2084
+ },
2085
+ tsdocMetadata: {
2086
+ enabled: false
2087
+ },
2088
+ compiler: {
2089
+ tsconfigFilePath
2090
+ },
2091
+ projectFolder: cwd,
2092
+ newlineKind: "lf"
2093
+ };
2094
+ const prepareOptions = {
2095
+ configObject,
2096
+ configObjectFullPath: void 0,
2097
+ packageJsonFullPath
2098
+ };
2099
+ const imported = _chunkTWFEYLU4js.getApiExtractor.call(void 0);
2100
+ if (!imported) {
2101
+ throw new Error(`@microsoft/api-extractor is not installed. Please install it first.`);
2102
+ }
2103
+ const { ExtractorConfig, Extractor } = imported;
2104
+ const extractorConfig = ExtractorConfig.prepare(prepareOptions);
2105
+ const extractorResult = Extractor.invoke(extractorConfig, {
2106
+ // Equivalent to the "--local" command-line parameter
2107
+ localBuild: true,
2108
+ // Equivalent to the "--verbose" command-line parameter
2109
+ showVerboseMessages: true
2110
+ });
2111
+ if (!extractorResult.succeeded) {
2112
+ throw new Error(`API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings when processing ${inputFilePath}`);
2113
+ }
2114
+ }
2115
+ _chunkB4CUDMY2cjs.__name.call(void 0, rollupDtsFile, "rollupDtsFile");
2116
+ async function rollupDtsFiles(options1, exports1, format) {
2117
+ if (!options1.experimentalDts || !_optionalChain([
2118
+ options1,
2119
+ "access",
2120
+ (_18) => _18.experimentalDts,
2121
+ "optionalAccess",
2122
+ (_19) => _19.entry
2123
+ ])) {
2124
+ return;
2125
+ }
2126
+ const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, options1);
2127
+ const outDir = options1.outDir || "dist";
2128
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, _optionalChain2([options1, 'access', _66 => _66.workspaceConfig, 'optionalAccess', _67 => _67.workspaceRoot]) || process.cwd());
2129
+ const dtsExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, {
2130
+ format,
2131
+ pkgType: pkg.type
2132
+ }).dts;
2133
+ const tsconfig = options1.tsconfig || "tsconfig.json";
2134
+ let dtsInputFilePath = _path2.default.join(declarationDir, `_tsup-dts-aggregation${dtsExtension}`);
2135
+ dtsInputFilePath = dtsInputFilePath.replace(/\.d\.mts$/, ".dmts.d.ts").replace(/\.d\.cts$/, ".dcts.d.ts");
2136
+ const dtsOutputFilePath = _path2.default.join(outDir, `_tsup-dts-rollup${dtsExtension}`);
2137
+ _chunkTWFEYLU4js.writeFileSync.call(void 0, dtsInputFilePath, formatAggregationExports(exports1, declarationDir, options1));
2138
+ rollupDtsFile(dtsInputFilePath, dtsOutputFilePath, tsconfig, options1);
2139
+ for (let [out, sourceFileName] of Object.entries(options1.experimentalDts.entry)) {
2140
+ sourceFileName = _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName);
2141
+ const outFileName = _path2.default.join(outDir, out + dtsExtension);
2142
+ const currentExports = exports1.filter((declaration) => declaration.sourceFileName === sourceFileName);
2143
+ _chunkTWFEYLU4js.writeFileSync.call(void 0, outFileName, formatDistributionExports(currentExports, outFileName, dtsOutputFilePath));
2144
+ }
2145
+ }
2146
+ _chunkB4CUDMY2cjs.__name.call(void 0, rollupDtsFiles, "rollupDtsFiles");
2147
+ async function cleanDtsFiles(options1) {
2148
+ if (options1.clean) {
2149
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, [
2150
+ "**/*.d.{ts,mts,cts}"
2151
+ ], options1.outDir);
2152
+ }
2153
+ }
2154
+ _chunkB4CUDMY2cjs.__name.call(void 0, cleanDtsFiles, "cleanDtsFiles");
2155
+ async function runDtsRollup(options1, exports1) {
2156
+ try {
2157
+ const start = Date.now();
2158
+ const getDuration = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
2159
+ return `${Math.floor(Date.now() - start)}ms`;
2160
+ }, "getDuration");
2161
+ logger2.info("dts", "Build start");
2162
+ if (!exports1) {
2163
+ throw new Error("Unexpected internal error: dts exports is not define");
2164
+ }
2165
+ await cleanDtsFiles(options1);
2166
+ for (const format of options1.format) {
2167
+ await rollupDtsFiles(options1, exports1, format);
2168
+ }
2169
+ logger2.success("dts", `\u26A1\uFE0F Build success in ${getDuration()}`);
2170
+ } catch (error) {
2171
+ _chunkJZ25TPTYjs.handleError.call(void 0, error);
2172
+ logger2.error("dts", "Build error");
2173
+ }
2174
+ }
2175
+ _chunkB4CUDMY2cjs.__name.call(void 0, runDtsRollup, "runDtsRollup");
2176
+ var cjsInterop = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
2177
+ return {
2178
+ name: "cjs-interop",
2179
+ renderChunk(code, info) {
2180
+ if (!this.options.cjsInterop || this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path) || !info.entryPoint || _optionalChain([
2181
+ info,
2182
+ "access",
2183
+ (_20) => _20.exports,
2184
+ "optionalAccess",
2185
+ (_21) => _21.length
2186
+ ]) !== 1 || info.exports[0] !== "default") {
2187
+ return;
2188
+ }
2189
+ return {
2190
+ code: `${code}
2191
+ module.exports = exports.default;
2192
+ `,
2193
+ map: info.map
2194
+ };
2195
+ }
2196
+ };
2197
+ }, "cjsInterop");
2198
+ var defineConfig = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (options1) => options1, "defineConfig");
2199
+ var isTaskkillCmdProcessNotFoundError = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (err) => {
2200
+ return process.platform === "win32" && "cmd" in err && "code" in err && typeof err.cmd === "string" && err.cmd.startsWith("taskkill") && err.code === 128;
2201
+ }, "isTaskkillCmdProcessNotFoundError");
2202
+ var killProcess = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, ({ pid, signal }) => new Promise((resolve, reject) => {
2203
+ _treekill2.default.call(void 0, pid, signal, (err) => {
2204
+ if (err && !isTaskkillCmdProcessNotFoundError(err)) return reject(err);
2205
+ resolve();
2206
+ });
2207
+ }), "killProcess");
2208
+ var normalizeOptions = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async (logger3, optionsFromConfigFile, optionsOverride) => {
2209
+ const _options = {
2210
+ ...optionsFromConfigFile,
2211
+ ...optionsOverride
2212
+ };
2213
+ const options1 = {
2214
+ outDir: "dist",
2215
+ removeNodeProtocol: true,
2216
+ ..._options,
2217
+ format: typeof _options.format === "string" ? [
2218
+ _options.format
2219
+ ] : _options.format || [
2220
+ "cjs"
2221
+ ],
2222
+ dts: typeof _options.dts === "boolean" ? _options.dts ? {} : void 0 : typeof _options.dts === "string" ? {
2223
+ entry: _options.dts
2224
+ } : _options.dts,
2225
+ experimentalDts: await _chunkTWFEYLU4js.resolveInitialExperimentalDtsConfig.call(void 0, _options.experimentalDts)
2226
+ };
2227
+ if (!options1.workspaceConfig) options1.workspaceConfig = {};
2228
+ if (!options1.workspaceConfig.workspaceRoot) options1.workspaceConfig.workspaceRoot = process.cwd();
2229
+ _chunkVGC3FXLUjs.setSilent.call(void 0, options1.silent);
2230
+ const entry = options1.entry || options1.entryPoints;
2231
+ if (!entry || Object.keys(entry).length === 0) {
2232
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`No input files, try "tsup <your-file>" instead`);
2233
+ }
2234
+ if (Array.isArray(entry)) {
2235
+ options1.entry = await _tinyglobby.glob.call(void 0, entry);
2236
+ if (!options1.entry || options1.entry.length === 0) {
2237
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${entry}`);
2238
+ } else {
2239
+ logger3.info("CLI", `Building entry: ${options1.entry.join(", ")}`);
2240
+ }
2241
+ } else {
2242
+ Object.keys(entry).forEach((alias) => {
2243
+ const filename = entry[alias];
2244
+ if (!_fs2.default.existsSync(filename)) {
2245
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${alias}: ${filename}`);
2246
+ }
2247
+ });
2248
+ options1.entry = entry;
2249
+ logger3.info("CLI", `Building entry: ${JSON.stringify(entry)}`);
2250
+ }
2251
+ const tsconfig = _bundlerequire.loadTsConfig.call(void 0, _optionalChain2([options1, 'access', _68 => _68.workspaceConfig, 'optionalAccess', _69 => _69.workspaceRoot]) || process.cwd(), options1.tsconfig);
2252
+ if (tsconfig) {
2253
+ logger3.info("CLI", `Using tsconfig: ${_path2.default.relative(_optionalChain2([options1, 'access', _70 => _70.workspaceConfig, 'optionalAccess', _71 => _71.workspaceRoot]) || process.cwd(), tsconfig.path)}`);
2254
+ options1.tsconfig = tsconfig.path;
2255
+ options1.tsconfigResolvePaths = _optionalChain([
2256
+ tsconfig,
2257
+ "access",
2258
+ (_22) => _22.data,
2259
+ "optionalAccess",
2260
+ (_23) => _23.compilerOptions,
2261
+ "optionalAccess",
2262
+ (_24) => _24.paths
2263
+ ]) || {};
2264
+ options1.tsconfigDecoratorMetadata = _optionalChain([
2265
+ tsconfig,
2266
+ "access",
2267
+ (_25) => _25.data,
2268
+ "optionalAccess",
2269
+ (_26) => _26.compilerOptions,
2270
+ "optionalAccess",
2271
+ (_27) => _27.emitDecoratorMetadata
2272
+ ]);
2273
+ if (options1.dts) {
2274
+ options1.dts.compilerOptions = {
2275
+ ...tsconfig.data.compilerOptions || {},
2276
+ ...options1.dts.compilerOptions || {}
2277
+ };
2278
+ }
2279
+ if (options1.experimentalDts) {
2280
+ options1.experimentalDts = await _chunkTWFEYLU4js.resolveExperimentalDtsConfig.call(void 0, options1, tsconfig);
2281
+ }
2282
+ if (!options1.target) {
2283
+ options1.target = _optionalChain([
2284
+ tsconfig,
2285
+ "access",
2286
+ (_28) => _28.data,
2287
+ "optionalAccess",
2288
+ (_29) => _29.compilerOptions,
2289
+ "optionalAccess",
2290
+ (_30) => _30.target,
2291
+ "optionalAccess",
2292
+ (_31) => _31.toLowerCase,
2293
+ "call",
2294
+ (_32) => _32()
2295
+ ]);
2296
+ }
2297
+ } else if (options1.tsconfig) {
2298
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find tsconfig: ${options1.tsconfig}`);
2299
+ }
2300
+ if (!options1.target) {
2301
+ options1.target = "node16";
2302
+ }
2303
+ return options1;
2304
+ }, "normalizeOptions");
2305
+ async function build3(_options) {
2306
+ const config = _options.config === false ? {} : await _chunkVGC3FXLUjs.loadTsupConfig.call(void 0, _optionalChain2([_options, 'access', _72 => _72.workspaceConfig, 'optionalAccess', _73 => _73.workspaceRoot]) || process.cwd(), _options.config === true ? void 0 : _options.config);
2307
+ const configData = typeof config.data === "function" ? await config.data(_options) : config.data;
2308
+ await Promise.all([
2309
+ ...Array.isArray(configData) ? configData : [
2310
+ configData
2311
+ ]
2312
+ ].map(async (item) => {
2313
+ const logger3 = _chunkVGC3FXLUjs.createLogger.call(void 0, _optionalChain([
2314
+ item,
2315
+ "optionalAccess",
2316
+ (_33) => _33.name
2317
+ ]));
2318
+ const options1 = await normalizeOptions(logger3, item, _options);
2319
+ logger3.info("CLI", `tsup v${_chunkBYH4XDRHjs.version}`);
2320
+ if (config.path) {
2321
+ logger3.info("CLI", `Using tsup config: ${config.path}`);
2322
+ }
2323
+ if (options1.watch) {
2324
+ logger3.info("CLI", "Running in watch mode");
2325
+ }
2326
+ const experimentalDtsTask = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2327
+ if (!options1.dts && options1.experimentalDts) {
2328
+ const exports1 = runTypeScriptCompiler(options1);
2329
+ await runDtsRollup(options1, exports1);
2330
+ }
2331
+ }, "experimentalDtsTask");
2332
+ const dtsTask = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2333
+ if (options1.dts && options1.experimentalDts) {
2334
+ throw new Error("You can't use both `dts` and `experimentalDts` at the same time");
2335
+ }
2336
+ await experimentalDtsTask();
2337
+ if (options1.dts) {
2338
+ await new Promise((resolve, reject) => {
2339
+ const worker = new (0, _worker_threads.Worker)(_path2.default.join(__dirname, "./rollup.js"));
2340
+ const terminateWorker = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, () => {
2341
+ if (options1.watch) return;
2342
+ worker.terminate();
2343
+ }, "terminateWorker");
2344
+ worker.postMessage({
2345
+ configName: _optionalChain([
2346
+ item,
2347
+ "optionalAccess",
2348
+ (_34) => _34.name
2349
+ ]),
2350
+ options: {
2351
+ ...options1,
2352
+ // functions cannot be cloned
2353
+ injectStyle: typeof options1.injectStyle === "function" ? void 0 : options1.injectStyle,
2354
+ banner: void 0,
2355
+ footer: void 0,
2356
+ esbuildPlugins: void 0,
2357
+ esbuildOptions: void 0,
2358
+ plugins: void 0,
2359
+ treeshake: void 0,
2360
+ onSuccess: void 0,
2361
+ outExtension: void 0
2362
+ }
2363
+ });
2364
+ worker.on("message", (data) => {
2365
+ if (data === "error") {
2366
+ terminateWorker();
2367
+ reject(new Error("error occurred in dts build"));
2368
+ } else if (data === "success") {
2369
+ terminateWorker();
2370
+ resolve();
2371
+ } else {
2372
+ const { type, text } = data;
2373
+ if (type === "log") {
2374
+ console.log(text);
2375
+ } else if (type === "error") {
2376
+ console.error(text);
2377
+ }
2378
+ }
2379
+ });
2380
+ });
2381
+ }
2382
+ }, "dtsTask");
2383
+ const mainTasks = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2384
+ if (!_optionalChain([
2385
+ options1,
2386
+ "access",
2387
+ (_35) => _35.dts,
2388
+ "optionalAccess",
2389
+ (_36) => _36.only
2390
+ ])) {
2391
+ let onSuccessProcess;
2392
+ let onSuccessCleanup;
2393
+ const buildDependencies = /* @__PURE__ */ new Set();
2394
+ let depsHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, _optionalChain2([options1, 'access', _74 => _74.workspaceConfig, 'optionalAccess', _75 => _75.workspaceRoot]) || process.cwd());
2395
+ const doOnSuccessCleanup = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2396
+ if (onSuccessProcess) {
2397
+ await killProcess({
2398
+ pid: onSuccessProcess.pid,
2399
+ signal: options1.killSignal || "SIGTERM"
2400
+ });
2401
+ } else if (onSuccessCleanup) {
2402
+ await onSuccessCleanup();
2403
+ }
2404
+ onSuccessProcess = void 0;
2405
+ onSuccessCleanup = void 0;
2406
+ }, "doOnSuccessCleanup");
2407
+ const debouncedBuildAll = _chunkTWFEYLU4js.debouncePromise.call(void 0, () => {
2408
+ return buildAll();
2409
+ }, 100, _chunkJZ25TPTYjs.handleError);
2410
+ const buildAll = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2411
+ await doOnSuccessCleanup();
2412
+ const previousBuildDependencies = new Set(buildDependencies);
2413
+ buildDependencies.clear();
2414
+ if (options1.clean) {
2415
+ const extraPatterns = Array.isArray(options1.clean) ? options1.clean : [];
2416
+ if (options1.dts || options1.experimentalDts) {
2417
+ extraPatterns.unshift("!**/*.d.{ts,cts,mts}");
2418
+ }
2419
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, [
2420
+ "**/*",
2421
+ ...extraPatterns
2422
+ ], options1.outDir);
2423
+ logger3.info("CLI", "Cleaning output folder");
2424
+ }
2425
+ const css = /* @__PURE__ */ new Map();
2426
+ await Promise.all([
2427
+ ...options1.format.map(async (format, index) => {
2428
+ const pluginContainer = new PluginContainer([
2429
+ shebang(),
2430
+ ...options1.plugins || [],
2431
+ treeShakingPlugin({
2432
+ treeshake: options1.treeshake,
2433
+ name: options1.globalName,
2434
+ silent: options1.silent
2435
+ }),
2436
+ cjsSplitting(),
2437
+ cjsInterop(),
2438
+ swcTarget(),
2439
+ sizeReporter(),
2440
+ terserPlugin({
2441
+ minifyOptions: options1.minify,
2442
+ format,
2443
+ terserOptions: options1.terserOptions,
2444
+ globalName: options1.globalName,
2445
+ logger: logger3
2446
+ })
2447
+ ]);
2448
+ await runEsbuild(options1, {
2449
+ pluginContainer,
2450
+ format,
2451
+ css: index === 0 || options1.injectStyle ? css : void 0,
2452
+ logger: logger3,
2453
+ buildDependencies
2454
+ }).catch((error) => {
2455
+ previousBuildDependencies.forEach((v) => buildDependencies.add(v));
2456
+ throw error;
2457
+ });
2458
+ })
2459
+ ]);
2460
+ if (options1.onSuccess) {
2461
+ if (typeof options1.onSuccess === "function") {
2462
+ onSuccessCleanup = await options1.onSuccess();
2463
+ } else {
2464
+ onSuccessProcess = _tinyexec.exec.call(void 0, options1.onSuccess, [], {
2465
+ nodeOptions: {
2466
+ shell: true,
2467
+ stdio: "inherit"
2468
+ }
2469
+ });
2470
+ _optionalChain([
2471
+ onSuccessProcess,
2472
+ "access",
2473
+ (_37) => _37.process,
2474
+ "optionalAccess",
2475
+ (_38) => _38.on,
2476
+ "call",
2477
+ (_39) => _39("exit", (code) => {
2478
+ if (code && code !== 0) {
2479
+ process.exitCode = code;
2480
+ }
2481
+ })
2482
+ ]);
2483
+ }
2484
+ }
2485
+ }, "buildAll");
2486
+ const startWatcher = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, async () => {
2487
+ if (!options1.watch) return;
2488
+ const { watch: watch2 } = await Promise.resolve().then(() => _interopRequireWildcard(_chunkB4CUDMY2cjs.__require.call(void 0, "chokidar")));
2489
+ const customIgnores = options1.ignoreWatch ? Array.isArray(options1.ignoreWatch) ? options1.ignoreWatch : [
2490
+ options1.ignoreWatch
2491
+ ] : [];
2492
+ const ignored = [
2493
+ "**/{.git,node_modules}/**",
2494
+ options1.outDir,
2495
+ ...customIgnores
2496
+ ];
2497
+ const watchPaths = typeof options1.watch === "boolean" ? "." : Array.isArray(options1.watch) ? options1.watch.filter((path12) => typeof path12 === "string") : options1.watch;
2498
+ logger3.info("CLI", `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => `"${v}"`).join(" | ") : `"${watchPaths}"`}`);
2499
+ logger3.info("CLI", `Ignoring changes in ${ignored.map((v) => `"${v}"`).join(" | ")}`);
2500
+ const watcher = watch2(await _tinyglobby.glob.call(void 0, watchPaths), {
2501
+ ignoreInitial: true,
2502
+ ignorePermissionErrors: true,
2503
+ ignored: /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (p) => _tinyglobby.globSync.call(void 0, p, {
2504
+ ignore: ignored
2505
+ }).length === 0, "ignored")
2506
+ });
2507
+ watcher.on("all", async (type, file) => {
2508
+ file = _chunkTWFEYLU4js.slash.call(void 0, file);
2509
+ if (options1.publicDir && isInPublicDir(options1.publicDir, file)) {
2510
+ logger3.info("CLI", `Change in public dir: ${file}`);
2511
+ copyPublicDir(options1.publicDir, options1.outDir);
2512
+ return;
2513
+ }
2514
+ let shouldSkipChange = false;
2515
+ if (options1.watch === true) {
2516
+ if (file === "package.json" && !buildDependencies.has(file)) {
2517
+ const currentHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, _optionalChain2([options1, 'access', _76 => _76.workspaceConfig, 'optionalAccess', _77 => _77.workspaceRoot]) || process.cwd());
2518
+ shouldSkipChange = currentHash === depsHash;
2519
+ depsHash = currentHash;
2520
+ } else if (!buildDependencies.has(file)) {
2521
+ shouldSkipChange = true;
2522
+ }
2523
+ }
2524
+ if (shouldSkipChange) {
2525
+ return;
2526
+ }
2527
+ logger3.info("CLI", `Change detected: ${type} ${file}`);
2528
+ debouncedBuildAll();
2529
+ });
2530
+ }, "startWatcher");
2531
+ logger3.info("CLI", `Target: ${options1.target}`);
2532
+ await buildAll();
2533
+ copyPublicDir(options1.publicDir, options1.outDir);
2534
+ startWatcher();
2535
+ }
2536
+ }, "mainTasks");
2537
+ await Promise.all([
2538
+ dtsTask(),
2539
+ mainTasks()
2540
+ ]);
2541
+ }));
2542
+ }
2543
+ _chunkB4CUDMY2cjs.__name.call(void 0, build3, "build");
2544
+ exports.build = build3;
2545
+ exports.defineConfig = defineConfig;
2546
+ }
2547
+ });
2548
+
2549
+ // src/build.ts
2550
+ var _devkit = require('@nx/devkit');
2551
+ var import_tsup = _chunkB4CUDMY2cjs.__toESM.call(void 0, require_dist(), 1);
2552
+ var _chokidar = require('chokidar');
2553
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault2(_defu);
2554
+ var _estoolkit = require('es-toolkit');
2555
+ var _esbuild2 = require('esbuild'); var esbuild = _interopRequireWildcard2(_esbuild2);
2556
+ var _globby = require('globby');
2557
+ var _fs3 = require('fs');
2558
+ var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault2(_promises);
2559
+ var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
2560
+
2561
+ // src/utilities/helpers.ts
2562
+ function handleSync(fn) {
2563
+ try {
2564
+ return fn();
2565
+ } catch (error_) {
2566
+ return error_;
2567
+ }
2568
+ }
2569
+ _chunkB4CUDMY2cjs.__name.call(void 0, handleSync, "handleSync");
2570
+ async function handleAsync(fn) {
2571
+ try {
2572
+ return await fn();
2573
+ } catch (error_) {
2574
+ return error_;
2575
+ }
2576
+ }
2577
+ _chunkB4CUDMY2cjs.__name.call(void 0, handleAsync, "handleAsync");
2578
+ var handle = handleSync;
2579
+ handle.async = handleAsync;
2580
+ var skip = Symbol("skip");
2581
+ function transduceSync(list, transformer) {
2582
+ const transduced = [];
2583
+ for (const [i, element_] of list.entries()) {
2584
+ const transformed = transformer(element_, i);
2585
+ if (transformed !== skip) {
2586
+ transduced[transduced.length] = transformed;
2587
+ }
2588
+ }
2589
+ return transduced;
2590
+ }
2591
+ _chunkB4CUDMY2cjs.__name.call(void 0, transduceSync, "transduceSync");
2592
+ async function transduceAsync(list, transformer) {
2593
+ const transduced = [];
2594
+ await Promise.all(list.entries().map(async ([i, element_]) => {
2595
+ const transformed = await transformer(element_, i);
2596
+ if (transformed !== skip) {
2597
+ transduced[transduced.length] = transformed;
2598
+ }
2599
+ }));
2600
+ return transduced;
2601
+ }
2602
+ _chunkB4CUDMY2cjs.__name.call(void 0, transduceAsync, "transduceAsync");
2603
+ var Filter = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (filter) => (item) => {
2604
+ return filter(item) ? item : skip;
2605
+ }, "Filter");
2606
+ var Mapper = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (mapper) => (item) => {
2607
+ return mapper(item);
2608
+ }, "Mapper");
2609
+ var transduce = transduceSync;
2610
+ transduce.async = transduceAsync;
2611
+ function pipeSync(fn, ...fns) {
2612
+ return (...args) => {
2613
+ let result = fn(...args);
2614
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
2615
+ result = _optionalChain2([fns, 'access', _78 => _78[i], 'optionalCall', _79 => _79(result)]);
2616
+ }
2617
+ return result;
2618
+ };
2619
+ }
2620
+ _chunkB4CUDMY2cjs.__name.call(void 0, pipeSync, "pipeSync");
2621
+ function pipeAsync(fn, ...fns) {
2622
+ return async (...args) => {
2623
+ let result = await fn(...args);
2624
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
2625
+ result = await _optionalChain2([fns, 'access', _80 => _80[i], 'optionalCall', _81 => _81(result)]);
2626
+ }
2627
+ return result;
2628
+ };
2629
+ }
2630
+ _chunkB4CUDMY2cjs.__name.call(void 0, pipeAsync, "pipeAsync");
2631
+ var pipe = pipeSync;
2632
+ pipe.async = pipeAsync;
2633
+
2634
+ // src/build.ts
2635
+ async function resolveContext(userOptions) {
2636
+ const projectRoot = userOptions.projectRoot;
2637
+ const workspaceRoot = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot);
2638
+ if (!workspaceRoot) {
2639
+ throw new Error("Cannot find Nx workspace root");
2640
+ }
2641
+ const workspaceConfig = await _chunkTDBBRZTCcjs.getWorkspaceConfig.call(void 0, true, {
2642
+ workspaceRoot: workspaceRoot.dir
2643
+ });
2644
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", workspaceConfig);
2645
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, "Build options resolution");
2646
+ const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, {
2647
+ exitOnError: true
2648
+ });
2649
+ const projectJsonPath = _chunkVPTKC3UKcjs.joinPaths.call(void 0, workspaceRoot.dir, projectRoot, "project.json");
2650
+ if (!_fs3.existsSync.call(void 0, projectJsonPath)) {
2651
+ throw new Error("Cannot find project.json configuration");
2652
+ }
2653
+ const projectJsonFile = await _promises2.default.readFile(projectJsonPath, "utf8");
2654
+ const projectJson = JSON.parse(projectJsonFile);
2655
+ const projectName = projectJson.name || userOptions.name;
2656
+ const projectConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
2657
+ if (!_optionalChain2([projectConfigurations, 'optionalAccess', _82 => _82.projects, 'optionalAccess', _83 => _83[projectName]])) {
2658
+ throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
2659
+ }
2660
+ const options2 = _defu2.default.call(void 0, userOptions, _chunkTDBBRZTCcjs.DEFAULT_BUILD_OPTIONS);
2661
+ options2.name ??= projectName;
2662
+ const packageJsonPath = _chunkVPTKC3UKcjs.joinPaths.call(void 0, workspaceRoot.dir, options2.projectRoot, "package.json");
2663
+ if (!_fs3.existsSync.call(void 0, packageJsonPath)) {
2664
+ throw new Error("Cannot find package.json configuration");
2665
+ }
2666
+ const env = _chunkTDBBRZTCcjs.getEnv.call(void 0, "esbuild", options2);
2667
+ const define = _defu2.default.call(void 0, _nullishCoalesce2(options2.define, () => ( {})), _nullishCoalesce2(env, () => ( {})));
2668
+ const resolvedOptions = {
2669
+ ...options2,
2670
+ tsconfig: _chunkVPTKC3UKcjs.joinPaths.call(void 0, projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
2671
+ metafile: userOptions.mode === "development",
2672
+ clean: false,
2673
+ env,
2674
+ define: {
2675
+ STORM_FORMAT: JSON.stringify(options2.format),
2676
+ ...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
2677
+ const value = JSON.stringify(define[key]);
2678
+ const safeKey = key.replaceAll("(", "").replaceAll(")", "");
2679
+ return {
2680
+ ...res,
2681
+ [`process.env.${safeKey}`]: value,
2682
+ [`import.meta.env.${safeKey}`]: value
2683
+ };
2684
+ }, {})
2685
+ }
2686
+ };
2687
+ stopwatch();
2688
+ return {
2689
+ options: resolvedOptions,
2690
+ clean: userOptions.clean !== false,
2691
+ workspaceConfig,
2692
+ projectConfigurations,
2693
+ projectName,
2694
+ projectGraph,
2695
+ sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || _chunkVPTKC3UKcjs.joinPaths.call(void 0, resolvedOptions.projectRoot, "src"),
2696
+ outputPath: resolvedOptions.outputPath || _chunkVPTKC3UKcjs.joinPaths.call(void 0, workspaceConfig.workspaceRoot, "dist", resolvedOptions.projectRoot),
2697
+ minify: resolvedOptions.minify || resolvedOptions.mode === "production"
2698
+ };
2699
+ }
2700
+ _chunkB4CUDMY2cjs.__name.call(void 0, resolveContext, "resolveContext");
2701
+ async function generatePackageJson(context) {
2702
+ if (context.options.generatePackageJson !== false && _fs3.existsSync.call(void 0, _chunkVPTKC3UKcjs.joinPaths.call(void 0, context.options.projectRoot, "package.json"))) {
2703
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", context.workspaceConfig);
2704
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, "Write package.json file");
2705
+ const packageJsonPath = _chunkVPTKC3UKcjs.joinPaths.call(void 0, context.options.projectRoot, "project.json");
2706
+ if (!_fs3.existsSync.call(void 0, packageJsonPath)) {
2707
+ throw new Error("Cannot find package.json configuration");
2708
+ }
2709
+ const packageJsonFile = await _promises2.default.readFile(_chunkVPTKC3UKcjs.joinPaths.call(void 0, context.workspaceConfig.workspaceRoot, context.options.projectRoot, "package.json"), "utf8");
2710
+ let packageJson = JSON.parse(packageJsonFile);
2711
+ if (!packageJson) {
2712
+ throw new Error("Cannot find package.json configuration file");
2713
+ }
2714
+ packageJson = await _chunkTDBBRZTCcjs.addPackageDependencies.call(void 0, context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
2715
+ packageJson = await _chunkTDBBRZTCcjs.addWorkspacePackageJsonFields.call(void 0, context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
2716
+ if (context.options.entry) {
2717
+ packageJson.exports ??= {};
2718
+ packageJson.exports["./package.json"] ??= "./package.json";
2719
+ const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
2720
+ if (entryPoints.length > 0) {
2721
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
2722
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
2723
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
2724
+ const isDts = context.options.dts || context.options.experimentalDts;
2725
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
2726
+ for (const entryPoint of entryPoints) {
2727
+ packageJson.exports[`./${entryPoint}`] ??= {};
2728
+ if (isEsm) {
2729
+ if (isDts) {
2730
+ packageJson.exports[`./${entryPoint}`].import = {
2731
+ types: `./dist/${entryPoint}.d.mts`,
2732
+ default: `./dist/${entryPoint}.mjs`
2733
+ };
2734
+ } else {
2735
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
2736
+ }
2737
+ if (isDts) {
2738
+ packageJson.exports[`./${entryPoint}`].default = {
2739
+ types: `./dist/${entryPoint}.d.mts`,
2740
+ default: `./dist/${entryPoint}.mjs`
2741
+ };
2742
+ } else {
2743
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
2744
+ }
2745
+ }
2746
+ if (isCjs) {
2747
+ if (isDts) {
2748
+ packageJson.exports[`./${entryPoint}`].require = {
2749
+ types: `./dist/${entryPoint}.d.cts`,
2750
+ default: `./dist/${entryPoint}.cjs`
2751
+ };
2752
+ } else {
2753
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
2754
+ }
2755
+ if (!isEsm) {
2756
+ if (isDts) {
2757
+ packageJson.exports[`./${entryPoint}`].default = {
2758
+ types: `./dist/${entryPoint}.d.cts`,
2759
+ default: `./dist/${entryPoint}.cjs`
2760
+ };
2761
+ } else {
2762
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
2763
+ }
2764
+ }
2765
+ }
2766
+ if (!isEsm && !isCjs) {
2767
+ if (isDts) {
2768
+ packageJson.exports[`./${entryPoint}`].default = {
2769
+ types: `./dist/${entryPoint}.d.ts`,
2770
+ default: `./dist/${entryPoint}.js`
2771
+ };
2772
+ } else {
2773
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
2774
+ }
2775
+ }
2776
+ }
2777
+ if (isEsm) {
2778
+ packageJson.module = `${defaultEntry}.mjs`;
2779
+ } else {
2780
+ packageJson.main = `${defaultEntry}.cjs`;
2781
+ }
2782
+ if (isDts) {
2783
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
2784
+ }
2785
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
2786
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
2787
+ ret[key.replace("/index", "")] = packageJson.exports[key];
2788
+ }
2789
+ return ret;
2790
+ }, packageJson.exports);
2791
+ }
2792
+ }
2793
+ await _devkit.writeJsonFile.call(void 0, _chunkVPTKC3UKcjs.joinPaths.call(void 0, context.outputPath, "package.json"), packageJson);
2794
+ stopwatch();
2795
+ }
2796
+ return context;
2797
+ }
2798
+ _chunkB4CUDMY2cjs.__name.call(void 0, generatePackageJson, "generatePackageJson");
2799
+ async function executeTsup(context) {
2800
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, ` \u{1F680} Running ${context.options.name} build`, context.workspaceConfig);
2801
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, `${context.options.name} build`);
2802
+ await (0, import_tsup.build)({
2803
+ ...context.options,
2804
+ outDir: context.options.distDir ? _chunkVPTKC3UKcjs.joinPaths.call(void 0, context.outputPath, context.options.distDir) : context.outputPath,
2805
+ workspaceConfig: context.workspaceConfig
2806
+ });
2807
+ stopwatch();
2808
+ return context;
2809
+ }
2810
+ _chunkB4CUDMY2cjs.__name.call(void 0, executeTsup, "executeTsup");
2811
+ async function copyBuildAssets(context) {
2812
+ if (_optionalChain2([context, 'access', _84 => _84.result, 'optionalAccess', _85 => _85.errors, 'access', _86 => _86.length]) === 0) {
2813
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
2814
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, `${context.options.name} asset copy`);
2815
+ await _chunkTDBBRZTCcjs.copyAssets.call(void 0, context.workspaceConfig, _nullishCoalesce2(context.options.assets, () => ( [])), context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
2816
+ stopwatch();
2817
+ }
2818
+ return context;
2819
+ }
2820
+ _chunkB4CUDMY2cjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
2821
+ async function reportResults(context) {
2822
+ if (_optionalChain2([context, 'access', _87 => _87.result, 'optionalAccess', _88 => _88.errors, 'access', _89 => _89.length]) === 0) {
2823
+ if (context.result.warnings.length > 0) {
2824
+ _chunkGJHRTQAScjs.writeWarning.call(void 0, ` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`, context.workspaceConfig);
2825
+ }
2826
+ _chunkGJHRTQAScjs.writeSuccess.call(void 0, ` \u{1F4E6} The ${context.options.name} build completed successfully`, context.workspaceConfig);
2827
+ } else if (_optionalChain2([context, 'access', _90 => _90.result, 'optionalAccess', _91 => _91.errors]) && _optionalChain2([context, 'access', _92 => _92.result, 'optionalAccess', _93 => _93.errors, 'access', _94 => _94.length]) > 0) {
2828
+ _chunkGJHRTQAScjs.writeError.call(void 0, ` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`, context.workspaceConfig);
2829
+ throw new Error(`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`);
2830
+ }
2831
+ }
2832
+ _chunkB4CUDMY2cjs.__name.call(void 0, reportResults, "reportResults");
2833
+ async function dependencyCheck(options2) {
2834
+ if (process.env.DEV === "true") {
2835
+ return void 0;
2836
+ }
2837
+ if (process.env.CI && !process.env.BUILDKITE) {
2838
+ return void 0;
2839
+ }
2840
+ const buildPromise = esbuild.build({
2841
+ entryPoints: _globby.globbySync.call(void 0, "**/*.{j,t}s", {
2842
+ // We don't check dependencies in ecosystem tests because tests are isolated from the build.
2843
+ ignore: [
2844
+ "./src/__tests__/**/*",
2845
+ "./tests/e2e/**/*",
2846
+ "./dist/**/*"
2847
+ ],
2848
+ gitignore: true
2849
+ }),
2850
+ logLevel: "silent",
2851
+ bundle: true,
2852
+ write: false,
2853
+ outdir: "out",
2854
+ plugins: [
2855
+ _chunkBNPCRQK4cjs.depsCheckPlugin.call(void 0, options2.bundle)
2856
+ ]
2857
+ });
2858
+ await buildPromise.catch(() => {
2859
+ });
2860
+ return void 0;
2861
+ }
2862
+ _chunkB4CUDMY2cjs.__name.call(void 0, dependencyCheck, "dependencyCheck");
2863
+ async function cleanOutputPath(context) {
2864
+ if (context.clean !== false && context.outputPath) {
2865
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, ` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`, context.workspaceConfig);
2866
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, `${context.options.name} output clean`);
2867
+ await _chunkTH2QFJHIcjs.cleanDirectories.call(void 0, context.outputPath);
2868
+ stopwatch();
2869
+ }
2870
+ return context;
2871
+ }
2872
+ _chunkB4CUDMY2cjs.__name.call(void 0, cleanOutputPath, "cleanOutputPath");
2873
+ async function build2(options2) {
2874
+ _chunkGJHRTQAScjs.writeDebug.call(void 0, ` \u26A1 Executing Storm ESBuild pipeline`);
2875
+ const stopwatch = _chunkGJHRTQAScjs.getStopwatch.call(void 0, "ESBuild pipeline");
2876
+ try {
2877
+ const opts = Array.isArray(options2) ? options2 : [
2878
+ options2
2879
+ ];
2880
+ if (opts.length === 0) {
2881
+ throw new Error("No build options were provided");
2882
+ }
2883
+ const context = await resolveContext(options2);
2884
+ await cleanOutputPath(context);
2885
+ await Promise.all([
2886
+ dependencyCheck(context.options),
2887
+ generatePackageJson(context),
2888
+ copyBuildAssets(context),
2889
+ executeTsup(context)
2890
+ ]);
2891
+ await reportResults(context);
2892
+ _chunkGJHRTQAScjs.writeSuccess.call(void 0, " \u{1F3C1} ESBuild pipeline build completed successfully");
2893
+ } catch (error) {
2894
+ _chunkGJHRTQAScjs.writeFatal.call(void 0, "Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
2895
+ throw error;
2896
+ } finally {
2897
+ stopwatch();
2898
+ }
2899
+ }
2900
+ _chunkB4CUDMY2cjs.__name.call(void 0, build2, "build");
2901
+ var watch = /* @__PURE__ */ _chunkB4CUDMY2cjs.__name.call(void 0, (context, options2) => {
2902
+ if (!options2.watch) {
2903
+ return context;
2904
+ }
2905
+ const config = {
2906
+ ignoreInitial: true,
2907
+ useFsEvents: true,
2908
+ ignored: [
2909
+ "./src/__tests__/**/*",
2910
+ "./package.json"
2911
+ ]
2912
+ };
2913
+ const changeWatcher = _chokidar.watch.call(void 0, [
2914
+ "./src/**/*"
2915
+ ], config);
2916
+ const fastRebuild = _estoolkit.debounce.call(void 0, async () => {
2917
+ const timeBefore = Date.now();
2918
+ const rebuildResult = await handle.async(() => {
2919
+ return context.rebuild();
2920
+ });
2921
+ if (rebuildResult instanceof Error) {
2922
+ _chunkGJHRTQAScjs.writeError.call(void 0, rebuildResult.message);
2923
+ }
2924
+ _chunkGJHRTQAScjs.writeTrace.call(void 0, `${Date.now() - timeBefore}ms [${_nullishCoalesce2(options2.name, () => ( ""))}]`);
2925
+ }, 10);
2926
+ changeWatcher.on("change", fastRebuild);
2927
+ return void 0;
2928
+ }, "watch");
2929
+
2930
+
2931
+
2932
+
2933
+
2934
+
2935
+
2936
+
2937
+
2938
+
2939
+ exports.handle = handle; exports.skip = skip; exports.Filter = Filter; exports.Mapper = Mapper; exports.transduce = transduce; exports.pipe = pipe; exports.build = build2; exports.watch = watch;