@storm-software/esbuild 0.35.3 → 0.35.5

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 (56) hide show
  1. package/README.md +1 -2
  2. package/dist/assets.cjs +6 -5
  3. package/dist/assets.js +5 -4
  4. package/dist/build.cjs +14 -13
  5. package/dist/build.js +13 -12
  6. package/dist/{chunk-FQQYNAPT.cjs → chunk-2DAVPJ7D.cjs} +126 -82
  7. package/dist/{chunk-EVDNG72R.cjs → chunk-2SU3HI5Q.cjs} +65 -35
  8. package/dist/{chunk-4D6ICA75.js → chunk-347I4FKJ.js} +5 -36
  9. package/dist/{chunk-VTBMJYSM.cjs → chunk-6WPLL2C2.cjs} +8 -6
  10. package/dist/{chunk-TSQT5MWW.js → chunk-6YDZYQLV.js} +32 -2
  11. package/dist/{chunk-G66JI4BS.cjs → chunk-AEHXBLG2.cjs} +9 -5
  12. package/dist/{chunk-SLSBBNRF.cjs → chunk-C23H24WU.cjs} +7 -3
  13. package/dist/{chunk-CVOQEYHW.cjs → chunk-CQGBWOR4.cjs} +29 -27
  14. package/dist/{chunk-NJJBR57W.js → chunk-DK7FJ3YJ.js} +47 -3
  15. package/dist/{chunk-2CM3VAO5.cjs → chunk-EP4M3VJ3.cjs} +16 -12
  16. package/dist/{chunk-PTHYT3U2.cjs → chunk-FBR7AR6F.cjs} +463 -372
  17. package/dist/{chunk-ABRK5MYP.js → chunk-FWIPARM7.js} +6 -2
  18. package/dist/{chunk-WXURMFT7.js → chunk-IGG5GIIV.js} +5 -1
  19. package/dist/{chunk-R2KKGNQL.js → chunk-MFZUNTR7.js} +8 -4
  20. package/dist/chunk-N3AYB46G.cjs +6 -0
  21. package/dist/{chunk-RK34D7S5.cjs → chunk-N5MGZ2YM.cjs} +8 -6
  22. package/dist/{chunk-EBTMX5WL.js → chunk-ODOBFGX6.js} +11 -9
  23. package/dist/{chunk-WLJT52I3.cjs → chunk-POL6NUTY.cjs} +21 -17
  24. package/dist/{chunk-EDLA3ZZN.js → chunk-QNVXA3GL.js} +6 -4
  25. package/dist/{chunk-YHMM6RY5.cjs → chunk-RIGD2PFD.cjs} +11 -42
  26. package/dist/{chunk-QWTKBUQW.js → chunk-RT5QOWTF.js} +1024 -1022
  27. package/dist/chunk-SJESTPEC.cjs +49 -0
  28. package/dist/{chunk-QVMJLFU5.cjs → chunk-T2DBJGI2.cjs} +9 -7
  29. package/dist/chunk-V5SXPYDB.js +56 -0
  30. package/dist/{chunk-OCDIIBBZ.js → chunk-VW5VOVX7.js} +5 -3
  31. package/dist/{chunk-DNZNN5SK.js → chunk-WCXP7IBU.js} +5 -3
  32. package/dist/chunk-X3XWFR6F.js +6 -0
  33. package/dist/{chunk-ECCVVXNX.js → chunk-XWGV6MFZ.js} +10 -6
  34. package/dist/clean.cjs +5 -4
  35. package/dist/clean.js +4 -3
  36. package/dist/config.cjs +6 -5
  37. package/dist/config.js +5 -4
  38. package/dist/context.cjs +8 -7
  39. package/dist/context.js +7 -6
  40. package/dist/index.cjs +20 -14
  41. package/dist/index.js +19 -13
  42. package/dist/package-json.cjs +6 -5
  43. package/dist/package-json.js +5 -4
  44. package/dist/plugins/deps-check.cjs +5 -4
  45. package/dist/plugins/deps-check.js +4 -3
  46. package/dist/plugins/resolve-paths.cjs +4 -3
  47. package/dist/plugins/resolve-paths.js +3 -2
  48. package/dist/tsup.cjs +5 -4
  49. package/dist/tsup.js +4 -3
  50. package/dist/types.cjs +2 -1
  51. package/dist/types.js +2 -1
  52. package/dist/watch.cjs +15 -11
  53. package/dist/watch.js +7 -3
  54. package/package.json +4 -4
  55. package/dist/chunk-GGNOJ77I.js +0 -0
  56. package/dist/chunk-SFZRYJZ2.cjs +0 -1
@@ -1,19 +1,24 @@
1
1
  import {
2
2
  getStopwatch,
3
3
  writeDebug
4
- } from "./chunk-TSQT5MWW.js";
4
+ } from "./chunk-6YDZYQLV.js";
5
+ import {
6
+ joinPaths
7
+ } from "./chunk-347I4FKJ.js";
5
8
  import {
6
9
  __commonJS,
10
+ __dirname,
7
11
  __name,
8
12
  __require,
9
13
  __toESM,
10
- joinPaths
11
- } from "./chunk-4D6ICA75.js";
14
+ init_esm_shims
15
+ } from "./chunk-V5SXPYDB.js";
12
16
 
13
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-BYH4XDRH.js
17
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-BYH4XDRH.js
14
18
  var require_chunk_BYH4XDRH = __commonJS({
15
- "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-BYH4XDRH.js"(exports) {
19
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-BYH4XDRH.js"(exports) {
16
20
  "use strict";
21
+ init_esm_shims();
17
22
  Object.defineProperty(exports, "__esModule", {
18
23
  value: true
19
24
  });
@@ -22,17 +27,18 @@ var require_chunk_BYH4XDRH = __commonJS({
22
27
  }
23
28
  });
24
29
 
25
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-TWFEYLU4.js
30
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-TWFEYLU4.js
31
+ import __import_fs from "fs";
32
+ import __import_path from "path";
33
+ import __import_resolveFrom from "resolve-from";
34
+ import __import_tinyglobby from "tinyglobby";
26
35
  var require_chunk_TWFEYLU4 = __commonJS({
27
- "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-TWFEYLU4.js"(exports) {
28
- "use strict";
29
- Object.defineProperty(exports, "__esModule", {
30
- value: true
31
- });
36
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-TWFEYLU4.js"(exports, module) {
37
+ init_esm_shims();
38
+ module.exports;
39
+ Object.defineProperty(exports, "__esModule", { value: true });
32
40
  function _interopRequireDefault(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
41
+ return obj && obj.__esModule ? obj : { default: obj };
36
42
  }
37
43
  __name(_interopRequireDefault, "_interopRequireDefault");
38
44
  function _optionalChain(ops) {
@@ -50,7 +56,7 @@ var require_chunk_TWFEYLU4 = __commonJS({
50
56
  lastAccessLHS = value;
51
57
  value = fn(value);
52
58
  } else if (op === "call" || op === "optionalCall") {
53
- value = fn((...args) => value.call(lastAccessLHS, ...args));
59
+ value = fn((...args2) => value.call(lastAccessLHS, ...args2));
54
60
  lastAccessLHS = void 0;
55
61
  }
56
62
  }
@@ -70,16 +76,13 @@ var require_chunk_TWFEYLU4 = __commonJS({
70
76
  throw Error('Dynamic require of "' + x + '" is not supported');
71
77
  });
72
78
  var __commonJS2 = /* @__PURE__ */ __name((cb, mod) => /* @__PURE__ */ __name(function __require22() {
73
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
74
- exports: {}
75
- }).exports, mod), mod.exports;
79
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
76
80
  }, "__require2"), "__commonJS");
77
81
  var __copyProps = /* @__PURE__ */ __name((to, from, except, desc) => {
78
82
  if (from && typeof from === "object" || typeof from === "function") {
79
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
80
- get: /* @__PURE__ */ __name(() => from[key], "get"),
81
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
82
- });
83
+ for (let key of __getOwnPropNames(from))
84
+ if (!__hasOwnProp.call(to, key) && key !== except)
85
+ __defProp(to, key, { get: /* @__PURE__ */ __name(() => from[key], "get"), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
83
86
  }
84
87
  return to;
85
88
  }, "__copyProps");
@@ -88,17 +91,14 @@ var require_chunk_TWFEYLU4 = __commonJS({
88
91
  // file that has been converted to a CommonJS file using a Babel-
89
92
  // compatible transform (i.e. "__esModule" has not been set), then set
90
93
  // "default" to the CommonJS "module.exports" for node compatibility.
91
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
92
- value: mod,
93
- enumerable: true
94
- }) : target,
94
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
95
95
  mod
96
96
  )), "__toESM");
97
- var _fs = __require("fs");
97
+ var _fs = __import_fs;
98
98
  var _fs2 = _interopRequireDefault(_fs);
99
- var _path = __require("path");
99
+ var _path = __import_path;
100
100
  var _path2 = _interopRequireDefault(_path);
101
- var _resolvefrom = __require("resolve-from");
101
+ var _resolvefrom = __import_resolveFrom;
102
102
  var _resolvefrom2 = _interopRequireDefault(_resolvefrom);
103
103
  var singleComment = Symbol("singleComment");
104
104
  var multiComment = Symbol("multiComment");
@@ -120,7 +120,7 @@ var require_chunk_TWFEYLU4 = __commonJS({
120
120
  const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
121
121
  let isInsideString = false;
122
122
  let isInsideComment = false;
123
- let offset = 0;
123
+ let offset2 = 0;
124
124
  let buffer = "";
125
125
  let result = "";
126
126
  let commaIndex = -1;
@@ -137,57 +137,57 @@ var require_chunk_TWFEYLU4 = __commonJS({
137
137
  continue;
138
138
  }
139
139
  if (!isInsideComment && currentCharacter + nextCharacter === "//") {
140
- buffer += jsonString.slice(offset, index);
141
- offset = index;
140
+ buffer += jsonString.slice(offset2, index);
141
+ offset2 = index;
142
142
  isInsideComment = singleComment;
143
143
  index++;
144
144
  } else if (isInsideComment === singleComment && currentCharacter + nextCharacter === "\r\n") {
145
145
  index++;
146
146
  isInsideComment = false;
147
- buffer += strip(jsonString, offset, index);
148
- offset = index;
147
+ buffer += strip(jsonString, offset2, index);
148
+ offset2 = index;
149
149
  continue;
150
150
  } else if (isInsideComment === singleComment && currentCharacter === "\n") {
151
151
  isInsideComment = false;
152
- buffer += strip(jsonString, offset, index);
153
- offset = index;
152
+ buffer += strip(jsonString, offset2, index);
153
+ offset2 = index;
154
154
  } else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
155
- buffer += jsonString.slice(offset, index);
156
- offset = index;
155
+ buffer += jsonString.slice(offset2, index);
156
+ offset2 = index;
157
157
  isInsideComment = multiComment;
158
158
  index++;
159
159
  continue;
160
160
  } else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
161
161
  index++;
162
162
  isInsideComment = false;
163
- buffer += strip(jsonString, offset, index + 1);
164
- offset = index + 1;
163
+ buffer += strip(jsonString, offset2, index + 1);
164
+ offset2 = index + 1;
165
165
  continue;
166
166
  } else if (trailingCommas && !isInsideComment) {
167
167
  if (commaIndex !== -1) {
168
168
  if (currentCharacter === "}" || currentCharacter === "]") {
169
- buffer += jsonString.slice(offset, index);
169
+ buffer += jsonString.slice(offset2, index);
170
170
  result += strip(buffer, 0, 1) + buffer.slice(1);
171
171
  buffer = "";
172
- offset = index;
172
+ offset2 = index;
173
173
  commaIndex = -1;
174
174
  } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
175
- buffer += jsonString.slice(offset, index);
176
- offset = index;
175
+ buffer += jsonString.slice(offset2, index);
176
+ offset2 = index;
177
177
  commaIndex = -1;
178
178
  }
179
179
  } else if (currentCharacter === ",") {
180
- result += buffer + jsonString.slice(offset, index);
180
+ result += buffer + jsonString.slice(offset2, index);
181
181
  buffer = "";
182
- offset = index;
182
+ offset2 = index;
183
183
  commaIndex = index;
184
184
  }
185
185
  }
186
186
  }
187
- return result + buffer + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
187
+ return result + buffer + (isInsideComment ? strip(jsonString.slice(offset2)) : jsonString.slice(offset2));
188
188
  }
189
189
  __name(stripJsonComments, "stripJsonComments");
190
- var _tinyglobby = __require("tinyglobby");
190
+ var _tinyglobby = __import_tinyglobby;
191
191
  function getPostcss() {
192
192
  return localRequire("postcss");
193
193
  }
@@ -213,17 +213,17 @@ var require_chunk_TWFEYLU4 = __commonJS({
213
213
  let timeout;
214
214
  let promiseInFly;
215
215
  let callbackPending;
216
- return /* @__PURE__ */ __name(function debounced(...args) {
216
+ return /* @__PURE__ */ __name(function debounced(...args2) {
217
217
  if (promiseInFly) {
218
218
  callbackPending = /* @__PURE__ */ __name(() => {
219
- debounced(...args);
219
+ debounced(...args2);
220
220
  callbackPending = void 0;
221
221
  }, "callbackPending");
222
222
  } else {
223
223
  if (timeout != null) clearTimeout(timeout);
224
224
  timeout = setTimeout(() => {
225
225
  timeout = void 0;
226
- promiseInFly = fn(...args).catch(onError).finally(() => {
226
+ promiseInFly = fn(...args2).catch(onError).finally(() => {
227
227
  promiseInFly = void 0;
228
228
  if (callbackPending) callbackPending();
229
229
  });
@@ -252,7 +252,10 @@ var require_chunk_TWFEYLU4 = __commonJS({
252
252
  }
253
253
  }
254
254
  __name(jsoncParse, "jsoncParse");
255
- function defaultOutExtension({ format, pkgType }) {
255
+ function defaultOutExtension({
256
+ format,
257
+ pkgType
258
+ }) {
256
259
  let jsExtension = ".js";
257
260
  let dtsExtension = ".d.ts";
258
261
  const isModule = pkgType === "module";
@@ -279,9 +282,7 @@ var require_chunk_TWFEYLU4 = __commonJS({
279
282
  if (_fs2.default.existsSync(dirPath)) {
280
283
  return dirPath;
281
284
  }
282
- _fs2.default.mkdirSync(dirPath, {
283
- recursive: true
284
- });
285
+ _fs2.default.mkdirSync(dirPath, { recursive: true });
285
286
  const gitIgnorePath = _path2.default.join(cwd, ".tsup", ".gitignore");
286
287
  writeFileSync(gitIgnorePath, "**/*\n");
287
288
  return dirPath;
@@ -289,22 +290,23 @@ var require_chunk_TWFEYLU4 = __commonJS({
289
290
  __name(ensureTempDeclarationDir, "ensureTempDeclarationDir");
290
291
  var toObjectEntry = /* @__PURE__ */ __name((entry) => {
291
292
  if (typeof entry === "string") {
292
- entry = [
293
- entry
294
- ];
293
+ entry = [entry];
295
294
  }
296
295
  if (!Array.isArray(entry)) {
297
296
  return entry;
298
297
  }
299
298
  entry = entry.map((e) => e.replace(/\\/g, "/"));
300
299
  const ancestor = findLowestCommonAncestor(entry);
301
- return entry.reduce((result, item) => {
302
- const key = item.replace(ancestor, "").replace(/^\//, "").replace(/\.[a-z]+$/, "");
303
- return {
304
- ...result,
305
- [key]: item
306
- };
307
- }, {});
300
+ return entry.reduce(
301
+ (result, item) => {
302
+ const key = item.replace(ancestor, "").replace(/^\//, "").replace(/\.[a-z]+$/, "");
303
+ return {
304
+ ...result,
305
+ [key]: item
306
+ };
307
+ },
308
+ {}
309
+ );
308
310
  }, "toObjectEntry");
309
311
  var findLowestCommonAncestor = /* @__PURE__ */ __name((filepaths) => {
310
312
  if (filepaths.length <= 1) return "";
@@ -333,32 +335,39 @@ var require_chunk_TWFEYLU4 = __commonJS({
333
335
  }
334
336
  __name(toAbsolutePath, "toAbsolutePath");
335
337
  function writeFileSync(filePath, content) {
336
- _fs2.default.mkdirSync(_path2.default.dirname(filePath), {
337
- recursive: true
338
- });
338
+ _fs2.default.mkdirSync(_path2.default.dirname(filePath), { recursive: true });
339
339
  _fs2.default.writeFileSync(filePath, content);
340
340
  }
341
341
  __name(writeFileSync, "writeFileSync");
342
342
  function replaceDtsWithJsExtensions(dtsFilePath) {
343
- return dtsFilePath.replace(/\.d\.(ts|mts|cts)$/, (_, fileExtension) => {
344
- switch (fileExtension) {
345
- case "ts":
346
- return ".js";
347
- case "mts":
348
- return ".mjs";
349
- case "cts":
350
- return ".cjs";
351
- default:
352
- return "";
343
+ return dtsFilePath.replace(
344
+ /\.d\.(ts|mts|cts)$/,
345
+ (_, fileExtension) => {
346
+ switch (fileExtension) {
347
+ case "ts":
348
+ return ".js";
349
+ case "mts":
350
+ return ".mjs";
351
+ case "cts":
352
+ return ".cjs";
353
+ default:
354
+ return "";
355
+ }
353
356
  }
354
- });
357
+ );
355
358
  }
356
359
  __name(replaceDtsWithJsExtensions, "replaceDtsWithJsExtensions");
357
360
  var convertArrayEntriesToObjectEntries = /* @__PURE__ */ __name((arrayOfEntries) => {
358
- const objectEntries = Object.fromEntries(arrayOfEntries.map((entry) => [
359
- _path2.default.posix.join(...entry.split(_path2.default.posix.sep).slice(1, -1).concat(_path2.default.parse(entry).name)),
360
- entry
361
- ]));
361
+ const objectEntries = Object.fromEntries(
362
+ arrayOfEntries.map(
363
+ (entry) => [
364
+ _path2.default.posix.join(
365
+ ...entry.split(_path2.default.posix.sep).slice(1, -1).concat(_path2.default.parse(entry).name)
366
+ ),
367
+ entry
368
+ ]
369
+ )
370
+ );
362
371
  return objectEntries;
363
372
  }, "convertArrayEntriesToObjectEntries");
364
373
  var resolveEntryPaths = /* @__PURE__ */ __name(async (entryPaths) => {
@@ -366,24 +375,14 @@ var require_chunk_TWFEYLU4 = __commonJS({
366
375
  return resolvedEntryPaths;
367
376
  }, "resolveEntryPaths");
368
377
  var resolveExperimentalDtsConfig = /* @__PURE__ */ __name(async (options2, tsconfig) => {
369
- const resolvedEntryPaths = await resolveEntryPaths(_optionalChain([
370
- options2,
371
- "access",
372
- (_2) => _2.experimentalDts,
373
- "optionalAccess",
374
- (_3) => _3.entry
375
- ]) || options2.entry);
378
+ const resolvedEntryPaths = await resolveEntryPaths(
379
+ _optionalChain([options2, "access", (_2) => _2.experimentalDts, "optionalAccess", (_3) => _3.entry]) || options2.entry
380
+ );
376
381
  const experimentalDtsObjectEntry = Object.keys(resolvedEntryPaths).length === 0 ? Array.isArray(options2.entry) ? convertArrayEntriesToObjectEntries(options2.entry) : options2.entry : resolvedEntryPaths;
377
382
  const normalizedExperimentalDtsConfig = {
378
383
  compilerOptions: {
379
384
  ...tsconfig.data.compilerOptions || {},
380
- ..._optionalChain([
381
- options2,
382
- "access",
383
- (_4) => _4.experimentalDts,
384
- "optionalAccess",
385
- (_5) => _5.compilerOptions
386
- ]) || {}
385
+ ..._optionalChain([options2, "access", (_4) => _4.experimentalDts, "optionalAccess", (_5) => _5.compilerOptions]) || {}
387
386
  },
388
387
  entry: experimentalDtsObjectEntry
389
388
  };
@@ -393,9 +392,8 @@ var require_chunk_TWFEYLU4 = __commonJS({
393
392
  if (experimentalDts == null) {
394
393
  return;
395
394
  }
396
- if (typeof experimentalDts === "boolean") return experimentalDts ? {
397
- entry: {}
398
- } : void 0;
395
+ if (typeof experimentalDts === "boolean")
396
+ return experimentalDts ? { entry: {} } : void 0;
399
397
  if (typeof experimentalDts === "string") {
400
398
  return {
401
399
  entry: convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, experimentalDts))
@@ -403,11 +401,7 @@ var require_chunk_TWFEYLU4 = __commonJS({
403
401
  }
404
402
  return {
405
403
  ...experimentalDts,
406
- entry: _optionalChain([
407
- experimentalDts,
408
- "optionalAccess",
409
- (_6) => _6.entry
410
- ]) == null ? {} : await resolveEntryPaths(experimentalDts.entry)
404
+ entry: _optionalChain([experimentalDts, "optionalAccess", (_6) => _6.entry]) == null ? {} : await resolveEntryPaths(experimentalDts.entry)
411
405
  };
412
406
  }, "resolveInitialExperimentalDtsConfig");
413
407
  exports.__require = __require2;
@@ -432,17 +426,22 @@ var require_chunk_TWFEYLU4 = __commonJS({
432
426
  }
433
427
  });
434
428
 
435
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-VGC3FXLU.js
429
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-VGC3FXLU.js
430
+ import __import_fs2 from "fs";
431
+ import __import_path2 from "path";
432
+ import __import_joycon from "joycon";
433
+ import __import_bundleRequire from "bundle-require";
434
+ import __import_util from "util";
435
+ import __import_worker_threads from "worker_threads";
436
+ import __import_picocolors from "picocolors";
436
437
  var require_chunk_VGC3FXLU = __commonJS({
437
- "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-VGC3FXLU.js"(exports) {
438
- "use strict";
439
- Object.defineProperty(exports, "__esModule", {
440
- value: true
441
- });
438
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-VGC3FXLU.js"(exports, module) {
439
+ init_esm_shims();
440
+ var import_chunk_TWFEYLU4 = __toESM(require_chunk_TWFEYLU4());
441
+ module.exports;
442
+ Object.defineProperty(exports, "__esModule", { value: true });
442
443
  function _interopRequireDefault(obj) {
443
- return obj && obj.__esModule ? obj : {
444
- default: obj
445
- };
444
+ return obj && obj.__esModule ? obj : { default: obj };
446
445
  }
447
446
  __name(_interopRequireDefault, "_interopRequireDefault");
448
447
  function _optionalChain(ops) {
@@ -460,28 +459,30 @@ var require_chunk_VGC3FXLU = __commonJS({
460
459
  lastAccessLHS = value;
461
460
  value = fn(value);
462
461
  } else if (op === "call" || op === "optionalCall") {
463
- value = fn((...args) => value.call(lastAccessLHS, ...args));
462
+ value = fn((...args2) => value.call(lastAccessLHS, ...args2));
464
463
  lastAccessLHS = void 0;
465
464
  }
466
465
  }
467
466
  return value;
468
467
  }
469
468
  __name(_optionalChain, "_optionalChain");
470
- var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
471
- var _fs = __require("fs");
469
+ var _chunkTWFEYLU4js = import_chunk_TWFEYLU4.default;
470
+ var _fs = __import_fs2;
472
471
  var _fs2 = _interopRequireDefault(_fs);
473
- var _path = __require("path");
472
+ var _path = __import_path2;
474
473
  var _path2 = _interopRequireDefault(_path);
475
- var _joycon = __require("joycon");
474
+ var _joycon = __import_joycon;
476
475
  var _joycon2 = _interopRequireDefault(_joycon);
477
- var _bundlerequire = __require("bundle-require");
476
+ var _bundlerequire = __import_bundleRequire;
478
477
  var joycon = new (0, _joycon2.default)();
479
478
  var loadJson = /* @__PURE__ */ __name(async (filepath, options2) => {
480
479
  try {
481
480
  return _chunkTWFEYLU4js.jsoncParse.call(void 0, await _fs2.default.promises.readFile(filepath, "utf8"));
482
481
  } catch (error) {
483
482
  if (error instanceof Error) {
484
- throw new Error(`Failed to parse ${_path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), filepath)}: ${error.message}`);
483
+ throw new Error(
484
+ `Failed to parse ${_path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), filepath)}: ${error.message}`
485
+ );
485
486
  } else {
486
487
  throw error;
487
488
  }
@@ -497,9 +498,7 @@ var require_chunk_VGC3FXLU = __commonJS({
497
498
  async function loadTsupConfig(cwd, configFile) {
498
499
  const configJoycon = new (0, _joycon2.default)();
499
500
  const configPath = await configJoycon.resolve({
500
- files: configFile ? [
501
- configFile
502
- ] : [
501
+ files: configFile ? [configFile] : [
503
502
  "tsup.config.ts",
504
503
  "tsup.config.cts",
505
504
  "tsup.config.mts",
@@ -520,10 +519,7 @@ var require_chunk_VGC3FXLU = __commonJS({
520
519
  data = data.tsup;
521
520
  }
522
521
  if (data) {
523
- return {
524
- path: configPath,
525
- data
526
- };
522
+ return { path: configPath, data };
527
523
  }
528
524
  return {};
529
525
  }
@@ -542,18 +538,18 @@ var require_chunk_VGC3FXLU = __commonJS({
542
538
  if (clearCache) {
543
539
  joycon.clearCache();
544
540
  }
545
- const { data } = await joycon.load([
546
- "package.json"
547
- ], cwd, _path2.default.dirname(cwd));
541
+ const { data } = await joycon.load(["package.json"], cwd, _path2.default.dirname(cwd));
548
542
  return data || {};
549
543
  }
550
544
  __name(loadPkg, "loadPkg");
551
545
  async function getProductionDeps(cwd, clearCache = false) {
552
546
  const data = await loadPkg(cwd, clearCache);
553
- const deps = Array.from(/* @__PURE__ */ new Set([
554
- ...Object.keys(data.dependencies || {}),
555
- ...Object.keys(data.peerDependencies || {})
556
- ]));
547
+ const deps = Array.from(
548
+ /* @__PURE__ */ new Set([
549
+ ...Object.keys(data.dependencies || {}),
550
+ ...Object.keys(data.peerDependencies || {})
551
+ ])
552
+ );
557
553
  return deps;
558
554
  }
559
555
  __name(getProductionDeps, "getProductionDeps");
@@ -566,19 +562,19 @@ var require_chunk_VGC3FXLU = __commonJS({
566
562
  });
567
563
  }
568
564
  __name(getAllDepsHash, "getAllDepsHash");
569
- var _util = __require("util");
565
+ var _util = __import_util;
570
566
  var _util2 = _interopRequireDefault(_util);
571
- var _worker_threads = __require("worker_threads");
572
- var _picocolors = __require("picocolors");
567
+ var _worker_threads = __import_worker_threads;
568
+ var _picocolors = __import_picocolors;
573
569
  var _picocolors2 = _interopRequireDefault(_picocolors);
574
570
  var colorize = /* @__PURE__ */ __name((type, data, onlyImportant = false) => {
575
571
  if (onlyImportant && (type === "info" || type === "success")) return data;
576
572
  const color = type === "info" ? "blue" : type === "error" ? "red" : type === "warn" ? "yellow" : "green";
577
573
  return _picocolors2.default[color](data);
578
574
  }, "colorize");
579
- var makeLabel = /* @__PURE__ */ __name((name, input, type) => {
575
+ var makeLabel = /* @__PURE__ */ __name((name2, input, type) => {
580
576
  return [
581
- name && `${_picocolors2.default.dim("[")}${name.toUpperCase()}${_picocolors2.default.dim("]")}`,
577
+ name2 && `${_picocolors2.default.dim("[")}${name2.toUpperCase()}${_picocolors2.default.dim("]")}`,
582
578
  colorize(type, input.toUpperCase())
583
579
  ].filter(Boolean).join(" ");
584
580
  }, "makeLabel");
@@ -591,78 +587,56 @@ var require_chunk_VGC3FXLU = __commonJS({
591
587
  return silent;
592
588
  }
593
589
  __name(getSilent, "getSilent");
594
- var createLogger = /* @__PURE__ */ __name((name) => {
590
+ var createLogger = /* @__PURE__ */ __name((name2) => {
595
591
  return {
596
592
  setName(_name) {
597
- name = _name;
593
+ name2 = _name;
598
594
  },
599
- success(label, ...args) {
600
- return this.log(label, "success", ...args);
595
+ success(label, ...args2) {
596
+ return this.log(label, "success", ...args2);
601
597
  },
602
- info(label, ...args) {
603
- return this.log(label, "info", ...args);
598
+ info(label, ...args2) {
599
+ return this.log(label, "info", ...args2);
604
600
  },
605
- error(label, ...args) {
606
- return this.log(label, "error", ...args);
601
+ error(label, ...args2) {
602
+ return this.log(label, "error", ...args2);
607
603
  },
608
- warn(label, ...args) {
609
- return this.log(label, "warn", ...args);
604
+ warn(label, ...args2) {
605
+ return this.log(label, "warn", ...args2);
610
606
  },
611
607
  log(label, type, ...data) {
612
- const args = [
613
- makeLabel(name, label, type),
608
+ const args2 = [
609
+ makeLabel(name2, label, type),
614
610
  ...data.map((item) => colorize(type, item, true))
615
611
  ];
616
612
  switch (type) {
617
613
  case "error": {
618
614
  if (!_worker_threads.isMainThread) {
619
- _optionalChain([
620
- _worker_threads.parentPort,
621
- "optionalAccess",
622
- (_) => _.postMessage,
623
- "call",
624
- (_2) => _2({
625
- type: "error",
626
- text: _util2.default.format(...args)
627
- })
628
- ]);
615
+ _optionalChain([_worker_threads.parentPort, "optionalAccess", (_) => _.postMessage, "call", (_2) => _2({
616
+ type: "error",
617
+ text: _util2.default.format(...args2)
618
+ })]);
629
619
  return;
630
620
  }
631
- return console.error(...args);
621
+ return console.error(...args2);
632
622
  }
633
623
  default:
634
624
  if (silent) return;
635
625
  if (!_worker_threads.isMainThread) {
636
- _optionalChain([
637
- _worker_threads.parentPort,
638
- "optionalAccess",
639
- (_3) => _3.postMessage,
640
- "call",
641
- (_4) => _4({
642
- type: "log",
643
- text: _util2.default.format(...args)
644
- })
645
- ]);
626
+ _optionalChain([_worker_threads.parentPort, "optionalAccess", (_3) => _3.postMessage, "call", (_4) => _4({
627
+ type: "log",
628
+ text: _util2.default.format(...args2)
629
+ })]);
646
630
  return;
647
631
  }
648
- console.log(...args);
632
+ console.log(...args2);
649
633
  }
650
634
  }
651
635
  };
652
636
  }, "createLogger");
653
637
  var prettyBytes = /* @__PURE__ */ __name((bytes) => {
654
638
  if (bytes === 0) return "0 B";
655
- const unit = [
656
- "B",
657
- "KB",
658
- "MB",
659
- "GB",
660
- "TB",
661
- "PB",
662
- "EB",
663
- "ZB",
664
- "YB"
665
- ];
639
+ const unit = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
666
640
  const exp = Math.floor(Math.log(bytes) / Math.log(1024));
667
641
  return `${(bytes / 1024 ** exp).toFixed(2)} ${unit[exp]}`;
668
642
  }, "prettyBytes");
@@ -677,8 +651,13 @@ var require_chunk_VGC3FXLU = __commonJS({
677
651
  var reportSize = /* @__PURE__ */ __name((logger, format, files) => {
678
652
  const filenames = Object.keys(files);
679
653
  const maxLength = getLengthOfLongestString(filenames) + 1;
680
- for (const name of filenames) {
681
- logger.success(format, `${_picocolors2.default.bold(padRight(name, maxLength))}${_picocolors2.default.green(prettyBytes(files[name]))}`);
654
+ for (const name2 of filenames) {
655
+ logger.success(
656
+ format,
657
+ `${_picocolors2.default.bold(padRight(name2, maxLength))}${_picocolors2.default.green(
658
+ prettyBytes(files[name2])
659
+ )}`
660
+ );
682
661
  }
683
662
  }, "reportSize");
684
663
  exports.loadTsupConfig = loadTsupConfig;
@@ -692,21 +671,20 @@ var require_chunk_VGC3FXLU = __commonJS({
692
671
  }
693
672
  });
694
673
 
695
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-JZ25TPTY.js
674
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-JZ25TPTY.js
675
+ import __import_worker_threads2 from "worker_threads";
676
+ import __import_picocolors2 from "picocolors";
696
677
  var require_chunk_JZ25TPTY = __commonJS({
697
- "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-JZ25TPTY.js"(exports) {
698
- "use strict";
699
- Object.defineProperty(exports, "__esModule", {
700
- value: true
701
- });
678
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/chunk-JZ25TPTY.js"(exports, module) {
679
+ init_esm_shims();
680
+ module.exports;
681
+ Object.defineProperty(exports, "__esModule", { value: true });
702
682
  function _interopRequireDefault(obj) {
703
- return obj && obj.__esModule ? obj : {
704
- default: obj
705
- };
683
+ return obj && obj.__esModule ? obj : { default: obj };
706
684
  }
707
685
  __name(_interopRequireDefault, "_interopRequireDefault");
708
- var _worker_threads = __require("worker_threads");
709
- var _picocolors = __require("picocolors");
686
+ var _worker_threads = __import_worker_threads2;
687
+ var _picocolors = __import_picocolors2;
710
688
  var _picocolors2 = _interopRequireDefault(_picocolors);
711
689
  var PrettyError = class extends Error {
712
690
  static {
@@ -724,7 +702,13 @@ var require_chunk_JZ25TPTY = __commonJS({
724
702
  };
725
703
  function handleError(error) {
726
704
  if (error.loc) {
727
- console.error(_picocolors2.default.bold(_picocolors2.default.red(`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`)));
705
+ console.error(
706
+ _picocolors2.default.bold(
707
+ _picocolors2.default.red(
708
+ `Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`
709
+ )
710
+ )
711
+ );
728
712
  }
729
713
  if (error.frame) {
730
714
  console.error(_picocolors2.default.red(error.message));
@@ -745,13 +729,30 @@ var require_chunk_JZ25TPTY = __commonJS({
745
729
  }
746
730
  });
747
731
 
748
- // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/index.js
732
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/index.js
733
+ import __import_path3 from "path";
734
+ import __import_fs3 from "fs";
735
+ import __import_worker_threads3 from "worker_threads";
736
+ import __import_bundleRequire2 from "bundle-require";
737
+ import __import_tinyexec from "tinyexec";
738
+ import __import_tinyglobby2 from "tinyglobby";
739
+ import __import_treeKill from "tree-kill";
740
+ import __import_esbuild from "esbuild";
741
+ import __import_consola from "consola";
742
+ import __import_sucrase from "sucrase";
743
+ import __import_sourceMap from "source-map";
744
+ import __import_rollup from "rollup";
745
+ import __import_typescript from "typescript";
746
+ import __import_chokidar from "chokidar";
749
747
  var require_dist = __commonJS({
750
- "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/index.js"(exports) {
751
- "use strict";
752
- Object.defineProperty(exports, "__esModule", {
753
- value: true
754
- });
748
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=d6d235bacb1b52781b6422127cf8179bf4fa7087e1b44c74b6d276e3935d9a55__7a3232d6d9fb61feedaa124fde7a8801/node_modules/tsup/dist/index.js"(exports, module) {
749
+ init_esm_shims();
750
+ var import_chunk_BYH4XDRH = __toESM(require_chunk_BYH4XDRH());
751
+ var import_chunk_VGC3FXLU = __toESM(require_chunk_VGC3FXLU());
752
+ var import_chunk_JZ25TPTY = __toESM(require_chunk_JZ25TPTY());
753
+ var import_chunk_TWFEYLU4 = __toESM(require_chunk_TWFEYLU4());
754
+ module.exports;
755
+ Object.defineProperty(exports, "__esModule", { value: true });
755
756
  function _interopRequireWildcard(obj) {
756
757
  if (obj && obj.__esModule) {
757
758
  return obj;
@@ -770,9 +771,7 @@ var require_dist = __commonJS({
770
771
  }
771
772
  __name(_interopRequireWildcard, "_interopRequireWildcard");
772
773
  function _interopRequireDefault(obj) {
773
- return obj && obj.__esModule ? obj : {
774
- default: obj
775
- };
774
+ return obj && obj.__esModule ? obj : { default: obj };
776
775
  }
777
776
  __name(_interopRequireDefault, "_interopRequireDefault");
778
777
  function _nullishCoalesce(lhs, rhsFn) {
@@ -798,7 +797,7 @@ var require_dist = __commonJS({
798
797
  lastAccessLHS = value;
799
798
  value = fn(value);
800
799
  } else if (op === "call" || op === "optionalCall") {
801
- value = fn((...args) => value.call(lastAccessLHS, ...args));
800
+ value = fn((...args2) => value.call(lastAccessLHS, ...args2));
802
801
  lastAccessLHS = void 0;
803
802
  }
804
803
  }
@@ -806,83 +805,154 @@ var require_dist = __commonJS({
806
805
  }
807
806
  __name(_optionalChain, "_optionalChain");
808
807
  var _class;
809
- var _chunkBYH4XDRHjs = require_chunk_BYH4XDRH();
810
- var _chunkVGC3FXLUjs = require_chunk_VGC3FXLU();
811
- var _chunkJZ25TPTYjs = require_chunk_JZ25TPTY();
812
- var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
813
- var _path = __require("path");
808
+ var _chunkBYH4XDRHjs = import_chunk_BYH4XDRH.default;
809
+ var _chunkVGC3FXLUjs = import_chunk_VGC3FXLU.default;
810
+ var _chunkJZ25TPTYjs = import_chunk_JZ25TPTY.default;
811
+ var _chunkTWFEYLU4js = import_chunk_TWFEYLU4.default;
812
+ var _path = __import_path3;
814
813
  var _path2 = _interopRequireDefault(_path);
815
- var _fs = __require("fs");
814
+ var _fs = __import_fs3;
816
815
  var _fs2 = _interopRequireDefault(_fs);
817
- var _worker_threads = __require("worker_threads");
818
- var _bundlerequire = __require("bundle-require");
819
- var _tinyexec = __require("tinyexec");
820
- var _tinyglobby = __require("tinyglobby");
821
- var _treekill = __require("tree-kill");
816
+ var _worker_threads = __import_worker_threads3;
817
+ var _bundlerequire = __import_bundleRequire2;
818
+ var _tinyexec = __import_tinyexec;
819
+ var _tinyglobby = __import_tinyglobby2;
820
+ var _treekill = __import_treeKill;
822
821
  var _treekill2 = _interopRequireDefault(_treekill);
823
- var _esbuild = __require("esbuild");
824
- var _consola = __require("consola");
822
+ var _esbuild = __import_esbuild;
823
+ var _consola = __import_consola;
825
824
  var _consola2 = _interopRequireDefault(_consola);
826
825
  var nodeProtocolPlugin = /* @__PURE__ */ __name(() => {
827
826
  const nodeProtocol = "node:";
828
827
  return {
829
828
  name: "node-protocol-plugin",
830
- setup({ onResolve }) {
831
- onResolve({
832
- filter: /^node:/
833
- }, ({ path: path12 }) => ({
834
- path: path12.slice(nodeProtocol.length),
835
- external: true
836
- }));
829
+ setup({ onResolve: onResolve2 }) {
830
+ onResolve2(
831
+ {
832
+ filter: /^node:/
833
+ },
834
+ ({ path: path12 }) => ({
835
+ path: path12.slice(nodeProtocol.length),
836
+ external: true
837
+ })
838
+ );
837
839
  }
838
840
  };
839
841
  }, "nodeProtocolPlugin");
842
+ var requireToImportPlugin = /* @__PURE__ */ __name(() => {
843
+ return {
844
+ name: "require-to-import",
845
+ setup({ onResolve, onLoad, esbuild }) {
846
+ function matchBrace(text, from) {
847
+ if (!(text[from] === "(")) return -1;
848
+ let i, k = 1;
849
+ for (i = from + 1; i < text.length && k > 0; ++i) {
850
+ if (text[i] === "(") k++;
851
+ if (text[i] === ")") k--;
852
+ }
853
+ let to = i - 1;
854
+ if (!(text[to] === ")") || k !== 0) return -1;
855
+ return to;
856
+ }
857
+ __name(matchBrace, "matchBrace");
858
+ function makeName(path2) {
859
+ return path2.replace(/-(\w)/g, (_, x) => x.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
860
+ }
861
+ __name(makeName, "makeName");
862
+ onLoad({ filter: /\.c?js/ }, async (args) => {
863
+ let contents = await _fs2.default.promises.readFile(args.path, "utf8");
864
+ let warnings;
865
+ try {
866
+ ({ warnings } = await esbuild.transform(contents, { format: "esm", logLevel: "silent" }));
867
+ } catch (err) {
868
+ ({ warnings } = err);
869
+ }
870
+ let lines = contents.split("\n");
871
+ if (warnings && warnings.some((e) => e.text.includes('"require" to "esm"'))) {
872
+ let modifications = [], imports = [];
873
+ for (const { location: { line, lineText, column, length } } of warnings) {
874
+ let left = column + length;
875
+ let right = matchBrace(lineText, left);
876
+ if (right === -1) continue;
877
+ let raw = lineText.slice(left + 1, right);
878
+ let path;
879
+ try {
880
+ path = eval(raw);
881
+ if (typeof path !== "string") continue;
882
+ } catch (e) {
883
+ continue;
884
+ }
885
+ let name = `__import_${makeName(path)}`;
886
+ let import_statement = `import ${name} from ${raw};`;
887
+ let offset = lines.slice(0, line - 1).map((line2) => line2.length).reduce((a, b) => a + 1 + b, 0);
888
+ modifications.push([offset + column, offset + right + 1, name]);
889
+ imports.push(import_statement);
890
+ }
891
+ if (imports.length === 0) return null;
892
+ imports = [...new Set(imports)];
893
+ let offset = 0;
894
+ for (const [start, end, name2] of modifications) {
895
+ contents = contents.slice(0, start + offset) + name2 + contents.slice(end + offset);
896
+ offset += name2.length - (end - start);
897
+ }
898
+ contents = [...imports, "module.exports", contents].join(";");
899
+ return { contents };
900
+ }
901
+ });
902
+ }
903
+ };
904
+ }, "requireToImportPlugin");
840
905
  var NON_NODE_MODULE_RE = /^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/;
841
- var externalPlugin = /* @__PURE__ */ __name(({ external, noExternal, skipNodeModulesBundle, tsconfigResolvePaths }) => {
906
+ var externalPlugin = /* @__PURE__ */ __name(({
907
+ external,
908
+ noExternal,
909
+ skipNodeModulesBundle,
910
+ tsconfigResolvePaths
911
+ }) => {
842
912
  return {
843
913
  name: `external`,
844
914
  setup(build2) {
845
915
  if (skipNodeModulesBundle) {
846
- const resolvePatterns = _bundlerequire.tsconfigPathsToRegExp.call(void 0, tsconfigResolvePaths || {});
847
- build2.onResolve({
848
- filter: /.*/
849
- }, (args) => {
850
- if (_bundlerequire.match.call(void 0, args.path, resolvePatterns)) {
916
+ const resolvePatterns = _bundlerequire.tsconfigPathsToRegExp.call(
917
+ void 0,
918
+ tsconfigResolvePaths || {}
919
+ );
920
+ build2.onResolve({ filter: /.*/ }, (args2) => {
921
+ if (_bundlerequire.match.call(void 0, args2.path, resolvePatterns)) {
851
922
  return;
852
923
  }
853
- if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
924
+ if (_bundlerequire.match.call(void 0, args2.path, noExternal)) {
854
925
  return;
855
926
  }
856
- if (_bundlerequire.match.call(void 0, args.path, external)) {
857
- return {
858
- external: true
859
- };
927
+ if (_bundlerequire.match.call(void 0, args2.path, external)) {
928
+ return { external: true };
860
929
  }
861
- if (!NON_NODE_MODULE_RE.test(args.path)) {
930
+ if (!NON_NODE_MODULE_RE.test(args2.path)) {
862
931
  return {
863
- path: args.path,
932
+ path: args2.path,
864
933
  external: true
865
934
  };
866
935
  }
867
936
  });
868
937
  } else {
869
- build2.onResolve({
870
- filter: /.*/
871
- }, (args) => {
872
- if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
938
+ build2.onResolve({ filter: /.*/ }, (args2) => {
939
+ if (_bundlerequire.match.call(void 0, args2.path, noExternal)) {
873
940
  return;
874
941
  }
875
- if (_bundlerequire.match.call(void 0, args.path, external)) {
876
- return {
877
- external: true
878
- };
942
+ if (_bundlerequire.match.call(void 0, args2.path, external)) {
943
+ return { external: true };
879
944
  }
880
945
  });
881
946
  }
882
947
  }
883
948
  };
884
949
  }, "externalPlugin");
885
- var postcssPlugin = /* @__PURE__ */ __name(({ options: options1, css, inject, cssLoader }) => {
950
+ var postcssPlugin = /* @__PURE__ */ __name(({
951
+ options: options2,
952
+ css,
953
+ inject,
954
+ cssLoader
955
+ }) => {
886
956
  return {
887
957
  name: "postcss",
888
958
  setup(build2) {
@@ -893,35 +963,26 @@ var require_dist = __commonJS({
893
963
  return configCache;
894
964
  }
895
965
  try {
896
- const result = await loadConfig({}, options1.workspaceConfig?.workspaceRoot || process.cwd());
966
+ const result = await loadConfig({}, options2.workspaceConfig?.workspaceRoot || process.cwd());
897
967
  configCache = result;
898
968
  return result;
899
969
  } catch (error) {
900
970
  if (error.message.includes("No PostCSS Config found in")) {
901
- const result = {
902
- plugins: [],
903
- options: {}
904
- };
971
+ const result = { plugins: [], options: {} };
905
972
  return result;
906
973
  }
907
974
  throw error;
908
975
  }
909
976
  }, "getPostcssConfig");
910
- build2.onResolve({
911
- filter: /^#style-inject$/
912
- }, () => {
913
- return {
914
- path: "#style-inject",
915
- namespace: "#style-inject"
916
- };
977
+ build2.onResolve({ filter: /^#style-inject$/ }, () => {
978
+ return { path: "#style-inject", namespace: "#style-inject" };
917
979
  });
918
- build2.onLoad({
919
- filter: /^#style-inject$/,
920
- namespace: "#style-inject"
921
- }, () => {
922
- return {
923
- // Taken from https://github.com/egoist/style-inject/blob/master/src/index.js (MIT)
924
- contents: `
980
+ build2.onLoad(
981
+ { filter: /^#style-inject$/, namespace: "#style-inject" },
982
+ () => {
983
+ return {
984
+ // Taken from https://github.com/egoist/style-inject/blob/master/src/index.js (MIT)
985
+ contents: `
925
986
  export default function styleInject(css, { insertAt } = {}) {
926
987
  if (!css || typeof document === 'undefined') return
927
988
 
@@ -946,19 +1007,18 @@ var require_dist = __commonJS({
946
1007
  }
947
1008
  }
948
1009
  `,
949
- loader: "js"
950
- };
951
- });
952
- build2.onLoad({
953
- filter: /\.css$/
954
- }, async (args) => {
955
- let contents;
956
- if (css && args.path.endsWith(".svelte.css")) {
957
- contents = css.get(args.path);
1010
+ loader: "js"
1011
+ };
1012
+ }
1013
+ );
1014
+ build2.onLoad({ filter: /\.css$/ }, async (args2) => {
1015
+ let contents2;
1016
+ if (css && args2.path.endsWith(".svelte.css")) {
1017
+ contents2 = css.get(args2.path);
958
1018
  } else {
959
- contents = await _fs2.default.promises.readFile(args.path, "utf8");
1019
+ contents2 = await _fs2.default.promises.readFile(args2.path, "utf8");
960
1020
  }
961
- const { plugins, options: options12 } = await getPostcssConfig();
1021
+ const { plugins, options: options3 } = await getPostcssConfig();
962
1022
  if (plugins && plugins.length > 0) {
963
1023
  const postcss = _chunkTWFEYLU4js.getPostcss.call(void 0);
964
1024
  if (!postcss) {
@@ -970,24 +1030,11 @@ var require_dist = __commonJS({
970
1030
  ]
971
1031
  };
972
1032
  }
973
- const result = await _optionalChain([
974
- postcss,
975
- "optionalAccess",
976
- (_2) => _2.default,
977
- "call",
978
- (_3) => _3(plugins),
979
- "access",
980
- (_4) => _4.process,
981
- "call",
982
- (_5) => _5(contents, {
983
- ...options12,
984
- from: args.path
985
- })
986
- ]);
987
- contents = result.css;
1033
+ const result = await _optionalChain([postcss, "optionalAccess", (_2) => _2.default, "call", (_3) => _3(plugins), "access", (_4) => _4.process, "call", (_5) => _5(contents2, { ...options3, from: args2.path })]);
1034
+ contents2 = result.css;
988
1035
  }
989
1036
  if (inject) {
990
- contents = (await _esbuild.transform.call(void 0, contents, {
1037
+ contents2 = (await _esbuild.transform.call(void 0, contents2, {
991
1038
  minify: build2.initialOptions.minify,
992
1039
  minifyIdentifiers: build2.initialOptions.minifyIdentifiers,
993
1040
  minifySyntax: build2.initialOptions.minifySyntax,
@@ -995,14 +1042,16 @@ var require_dist = __commonJS({
995
1042
  logLevel: build2.initialOptions.logLevel,
996
1043
  loader: "css"
997
1044
  })).code;
998
- contents = typeof inject === "function" ? await inject(JSON.stringify(contents), args.path) : `import styleInject from '#style-inject';styleInject(${JSON.stringify(contents)})`;
1045
+ contents2 = typeof inject === "function" ? await inject(JSON.stringify(contents2), args2.path) : `import styleInject from '#style-inject';styleInject(${JSON.stringify(
1046
+ contents2
1047
+ )})`;
999
1048
  return {
1000
- contents,
1049
+ contents: contents2,
1001
1050
  loader: "js"
1002
1051
  };
1003
1052
  }
1004
1053
  return {
1005
- contents,
1054
+ contents: contents2,
1006
1055
  loader: _nullishCoalesce(cssLoader, () => "css")
1007
1056
  };
1008
1057
  });
@@ -1010,106 +1059,96 @@ var require_dist = __commonJS({
1010
1059
  };
1011
1060
  }, "postcssPlugin");
1012
1061
  var useSvelteCssExtension = /* @__PURE__ */ __name((p) => p.replace(/\.svelte$/, ".svelte.css"), "useSvelteCssExtension");
1013
- var sveltePlugin = /* @__PURE__ */ __name(({ css, options: options1 }) => {
1062
+ var sveltePlugin = /* @__PURE__ */ __name(({
1063
+ css,
1064
+ options: options2
1065
+ }) => {
1014
1066
  return {
1015
1067
  name: "svelte",
1016
1068
  setup(build2) {
1017
1069
  let svelte;
1018
1070
  let sveltePreprocessor;
1019
- build2.onResolve({
1020
- filter: /\.svelte\.css$/
1021
- }, (args) => {
1071
+ build2.onResolve({ filter: /\.svelte\.css$/ }, (args2) => {
1022
1072
  return {
1023
- path: _path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), _path2.default.join(args.resolveDir, args.path)),
1073
+ path: _path2.default.relative(
1074
+ options2.workspaceConfig?.workspaceRoot || process.cwd(),
1075
+ _path2.default.join(args2.resolveDir, args2.path)
1076
+ ),
1024
1077
  namespace: "svelte-css"
1025
1078
  };
1026
1079
  });
1027
- build2.onLoad({
1028
- filter: /\.svelte$/
1029
- }, async (args) => {
1080
+ build2.onLoad({ filter: /\.svelte$/ }, async (args2) => {
1030
1081
  svelte = svelte || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte/compiler");
1031
1082
  sveltePreprocessor = sveltePreprocessor || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte-preprocess");
1032
1083
  if (!svelte) {
1033
1084
  return {
1034
- errors: [
1035
- {
1036
- text: `You need to install "svelte" in your project`
1037
- }
1038
- ]
1085
+ errors: [{ text: `You need to install "svelte" in your project` }]
1039
1086
  };
1040
1087
  }
1041
1088
  const convertMessage = /* @__PURE__ */ __name(({ message, start, end }) => {
1042
1089
  let location;
1043
1090
  if (start && end) {
1044
- const lineText = source.split(/\r\n|\r|\n/g)[start.line - 1];
1045
- const lineEnd = start.line === end.line ? end.column : lineText.length;
1091
+ const lineText2 = source.split(/\r\n|\r|\n/g)[start.line - 1];
1092
+ const lineEnd = start.line === end.line ? end.column : lineText2.length;
1046
1093
  location = {
1047
1094
  file: filename,
1048
1095
  line: start.line,
1049
1096
  column: start.column,
1050
1097
  length: lineEnd - start.column,
1051
- lineText
1098
+ lineText: lineText2
1052
1099
  };
1053
1100
  }
1054
- return {
1055
- text: message,
1056
- location
1057
- };
1101
+ return { text: message, location };
1058
1102
  }, "convertMessage");
1059
- const source = await _fs2.default.promises.readFile(args.path, "utf8");
1060
- const filename = _path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), args.path);
1103
+ const source = await _fs2.default.promises.readFile(args2.path, "utf8");
1104
+ const filename = _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), args2.path);
1061
1105
  try {
1062
- const preprocess = await svelte.preprocess(source, sveltePreprocessor ? sveltePreprocessor({
1063
- sourceMap: true,
1064
- typescript: {
1065
- compilerOptions: {
1066
- verbatimModuleSyntax: true
1106
+ const preprocess = await svelte.preprocess(
1107
+ source,
1108
+ sveltePreprocessor ? sveltePreprocessor({
1109
+ sourceMap: true,
1110
+ typescript: {
1111
+ compilerOptions: {
1112
+ verbatimModuleSyntax: true
1113
+ }
1067
1114
  }
1115
+ }) : {
1116
+ async script({ content, attributes }) {
1117
+ if (attributes.lang !== "ts") return { code: content };
1118
+ const { code, map } = await _esbuild.transform.call(void 0, content, {
1119
+ sourcefile: args2.path,
1120
+ loader: "ts",
1121
+ sourcemap: true,
1122
+ tsconfigRaw: {
1123
+ compilerOptions: {
1124
+ verbatimModuleSyntax: true
1125
+ }
1126
+ },
1127
+ logLevel: build2.initialOptions.logLevel
1128
+ });
1129
+ return {
1130
+ code,
1131
+ map
1132
+ };
1133
+ }
1134
+ },
1135
+ {
1136
+ filename: args2.path
1068
1137
  }
1069
- }) : {
1070
- async script({ content, attributes }) {
1071
- if (attributes.lang !== "ts") return {
1072
- code: content
1073
- };
1074
- const { code, map } = await _esbuild.transform.call(void 0, content, {
1075
- sourcefile: args.path,
1076
- loader: "ts",
1077
- sourcemap: true,
1078
- tsconfigRaw: {
1079
- compilerOptions: {
1080
- verbatimModuleSyntax: true
1081
- }
1082
- },
1083
- logLevel: build2.initialOptions.logLevel
1084
- });
1085
- return {
1086
- code,
1087
- map
1088
- };
1089
- }
1090
- }, {
1091
- filename: args.path
1092
- });
1138
+ );
1093
1139
  const result = svelte.compile(preprocess.code, {
1094
1140
  filename,
1095
1141
  css: "external"
1096
1142
  });
1097
- let contents = result.js.code;
1143
+ let contents2 = result.js.code;
1098
1144
  if (css && result.css && result.css.code) {
1099
1145
  const cssPath = useSvelteCssExtension(filename);
1100
1146
  css.set(cssPath, result.css.code);
1101
- contents = `import '${useSvelteCssExtension(_path2.default.basename(args.path))}';${contents}`;
1147
+ contents2 = `import '${useSvelteCssExtension(_path2.default.basename(args2.path))}';${contents2}`;
1102
1148
  }
1103
- return {
1104
- contents,
1105
- warnings: result.warnings.map(convertMessage)
1106
- };
1149
+ return { contents: contents2, warnings: result.warnings.map(convertMessage) };
1107
1150
  } catch (error) {
1108
- return {
1109
- errors: [
1110
- convertMessage(error)
1111
- ]
1112
- };
1151
+ return { errors: [convertMessage(error)] };
1113
1152
  }
1114
1153
  });
1115
1154
  }
@@ -1121,14 +1160,15 @@ var require_dist = __commonJS({
1121
1160
  setup(build2) {
1122
1161
  const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
1123
1162
  if (!swc) {
1124
- logger3.warn(build2.initialOptions.format, `You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin`);
1163
+ logger3.warn(
1164
+ build2.initialOptions.format,
1165
+ `You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin`
1166
+ );
1125
1167
  return;
1126
1168
  }
1127
1169
  build2.initialOptions.keepNames = true;
1128
- build2.onLoad({
1129
- filter: /\.[jt]sx?$/
1130
- }, async (args) => {
1131
- const isTs = /\.tsx?$/.test(args.path);
1170
+ build2.onLoad({ filter: /\.[jt]sx?$/ }, async (args2) => {
1171
+ const isTs = /\.tsx?$/.test(args2.path);
1132
1172
  const jsc = {
1133
1173
  parser: {
1134
1174
  syntax: isTs ? "typescript" : "ecmascript",
@@ -1141,7 +1181,7 @@ var require_dist = __commonJS({
1141
1181
  keepClassNames: true,
1142
1182
  target: "es2022"
1143
1183
  };
1144
- const result = await swc.transformFile(args.path, {
1184
+ const result = await swc.transformFile(args2.path, {
1145
1185
  jsc,
1146
1186
  sourceMaps: true,
1147
1187
  configFile: false,
@@ -1151,9 +1191,11 @@ var require_dist = __commonJS({
1151
1191
  if (result.map) {
1152
1192
  const map = JSON.parse(result.map);
1153
1193
  map.sources = map.sources.map((source) => {
1154
- return _path2.default.isAbsolute(source) ? _path2.default.relative(_path2.default.dirname(args.path), source) : source;
1194
+ return _path2.default.isAbsolute(source) ? _path2.default.relative(_path2.default.dirname(args2.path), source) : source;
1155
1195
  });
1156
- code += `//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(map)).toString("base64")}`;
1196
+ code += `//# sourceMappingURL=data:application/json;base64,${Buffer.from(
1197
+ JSON.stringify(map)
1198
+ ).toString("base64")}`;
1157
1199
  }
1158
1200
  return {
1159
1201
  contents: code
@@ -1166,14 +1208,9 @@ var require_dist = __commonJS({
1166
1208
  return {
1167
1209
  name: "native-node-modules",
1168
1210
  setup(build2) {
1169
- build2.onResolve({
1170
- filter: /\.node$/,
1171
- namespace: "file"
1172
- }, (args) => {
1173
- const resolvedId = _chunkTWFEYLU4js.__require.resolve(args.path, {
1174
- paths: [
1175
- args.resolveDir
1176
- ]
1211
+ build2.onResolve({ filter: /\.node$/, namespace: "file" }, (args2) => {
1212
+ const resolvedId = _chunkTWFEYLU4js.__require.resolve(args2.path, {
1213
+ paths: [args2.resolveDir]
1177
1214
  });
1178
1215
  if (resolvedId.endsWith(".node")) {
1179
1216
  return {
@@ -1185,43 +1222,33 @@ var require_dist = __commonJS({
1185
1222
  path: resolvedId
1186
1223
  };
1187
1224
  });
1188
- build2.onLoad({
1189
- filter: /.*/,
1190
- namespace: "node-file"
1191
- }, (args) => {
1225
+ build2.onLoad({ filter: /.*/, namespace: "node-file" }, (args2) => {
1192
1226
  return {
1193
1227
  contents: `
1194
- import path from ${JSON.stringify(args.path)}
1228
+ import path from ${JSON.stringify(args2.path)}
1195
1229
  try { module.exports = require(path) }
1196
1230
  catch {}
1197
1231
  `,
1198
- resolveDir: _path2.default.dirname(args.path)
1232
+ resolveDir: _path2.default.dirname(args2.path)
1199
1233
  };
1200
1234
  });
1201
- build2.onResolve({
1202
- filter: /\.node$/,
1203
- namespace: "node-file"
1204
- }, (args) => ({
1205
- path: args.path,
1206
- namespace: "file"
1207
- }));
1235
+ build2.onResolve(
1236
+ { filter: /\.node$/, namespace: "node-file" },
1237
+ (args2) => ({
1238
+ path: args2.path,
1239
+ namespace: "file"
1240
+ })
1241
+ );
1208
1242
  const opts = build2.initialOptions;
1209
1243
  opts.loader = opts.loader || {};
1210
1244
  opts.loader[".node"] = "file";
1211
1245
  }
1212
1246
  };
1213
1247
  }, "nativeNodeModulesPlugin");
1214
- var getOutputExtensionMap = /* @__PURE__ */ __name((options1, format, pkgType) => {
1215
- const outExtension = options1.outExtension || _chunkTWFEYLU4js.defaultOutExtension;
1216
- const defaultExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, {
1217
- format,
1218
- pkgType
1219
- });
1220
- const extension = outExtension({
1221
- options: options1,
1222
- format,
1223
- pkgType
1224
- });
1248
+ var getOutputExtensionMap = /* @__PURE__ */ __name((options2, format, pkgType) => {
1249
+ const outExtension = options2.outExtension || _chunkTWFEYLU4js.defaultOutExtension;
1250
+ const defaultExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, { format, pkgType });
1251
+ const extension = outExtension({ options: options2, format, pkgType });
1225
1252
  return {
1226
1253
  ".js": extension.js || defaultExtension.js
1227
1254
  };
@@ -1239,46 +1266,52 @@ var require_dist = __commonJS({
1239
1266
  }
1240
1267
  return result;
1241
1268
  }, "generateExternal");
1242
- async function runEsbuild(options1, { format, css, logger: logger3, buildDependencies, pluginContainer }) {
1243
- const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd());
1244
- const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd());
1269
+ async function runEsbuild(options2, {
1270
+ format,
1271
+ css,
1272
+ logger: logger3,
1273
+ buildDependencies,
1274
+ pluginContainer
1275
+ }) {
1276
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
1277
+ const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
1245
1278
  const external = [
1246
1279
  // Exclude dependencies, e.g. `lodash`, `lodash/get`
1247
1280
  ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
1248
- ...await generateExternal(options1.external || [])
1281
+ ...await generateExternal(options2.external || [])
1249
1282
  ];
1250
- const outDir = options1.outDir;
1251
- const outExtension = getOutputExtensionMap(options1, format, pkg.type);
1283
+ const outDir = options2.outDir;
1284
+ const outExtension = getOutputExtensionMap(options2, format, pkg.type);
1252
1285
  const env = {
1253
- ...options1.env
1286
+ ...options2.env
1254
1287
  };
1255
- if (options1.replaceNodeEnv) {
1256
- env.NODE_ENV = options1.minify || options1.minifyWhitespace ? "production" : "development";
1288
+ if (options2.replaceNodeEnv) {
1289
+ env.NODE_ENV = options2.minify || options2.minifyWhitespace ? "production" : "development";
1257
1290
  }
1258
1291
  logger3.info(format, "Build start");
1259
1292
  const startTime = Date.now();
1260
1293
  let result;
1261
- const splitting = format === "iife" ? false : typeof options1.splitting === "boolean" ? options1.splitting : format === "esm";
1262
- const platform = options1.platform || "node";
1263
- const loader = options1.loader || {};
1264
- const injectShims = options1.shims;
1294
+ const splitting = format === "iife" ? false : typeof options2.splitting === "boolean" ? options2.splitting : format === "esm";
1295
+ const platform = options2.platform || "node";
1296
+ const loader = options2.loader || {};
1297
+ const injectShims = options2.shims;
1298
+ const bundle = typeof options2.bundle === "undefined" ? true : options2.bundle;
1265
1299
  pluginContainer.setContext({
1266
1300
  format,
1267
1301
  splitting,
1268
- options: options1,
1302
+ options: options2,
1269
1303
  logger: logger3
1270
1304
  });
1271
1305
  await pluginContainer.buildStarted();
1272
1306
  const esbuildPlugins = [
1273
- format === "cjs" && options1.removeNodeProtocol && nodeProtocolPlugin(),
1307
+ format === "cjs" && options2.removeNodeProtocol && nodeProtocolPlugin(),
1308
+ format === "esm" && bundle && options2.requireToImport && requireToImportPlugin(),
1274
1309
  {
1275
1310
  name: "modify-options",
1276
1311
  setup(build2) {
1277
1312
  pluginContainer.modifyEsbuildOptions(build2.initialOptions);
1278
- if (options1.esbuildOptions) {
1279
- options1.esbuildOptions(build2.initialOptions, {
1280
- format
1281
- });
1313
+ if (options2.esbuildOptions) {
1314
+ options2.esbuildOptions(build2.initialOptions, { format });
1282
1315
  }
1283
1316
  }
1284
1317
  },
@@ -1286,46 +1319,37 @@ var require_dist = __commonJS({
1286
1319
  // So here we use a custom plugin to implement it
1287
1320
  format !== "iife" && externalPlugin({
1288
1321
  external,
1289
- noExternal: options1.noExternal,
1290
- skipNodeModulesBundle: options1.skipNodeModulesBundle,
1291
- tsconfigResolvePaths: options1.tsconfigResolvePaths
1292
- }),
1293
- options1.tsconfigDecoratorMetadata && swcPlugin({
1294
- logger: logger3
1322
+ noExternal: options2.noExternal,
1323
+ skipNodeModulesBundle: options2.skipNodeModulesBundle,
1324
+ tsconfigResolvePaths: options2.tsconfigResolvePaths
1295
1325
  }),
1326
+ options2.tsconfigDecoratorMetadata && swcPlugin({ logger: logger3 }),
1296
1327
  nativeNodeModulesPlugin(),
1297
1328
  postcssPlugin({
1298
- options: options1,
1329
+ options: options2,
1299
1330
  css,
1300
- inject: options1.injectStyle,
1331
+ inject: options2.injectStyle,
1301
1332
  cssLoader: loader[".css"]
1302
1333
  }),
1303
- sveltePlugin({
1304
- css,
1305
- options: options1
1306
- }),
1307
- ...options1.esbuildPlugins || []
1334
+ sveltePlugin({ css, options: options2 }),
1335
+ ...options2.esbuildPlugins || []
1308
1336
  ];
1309
- const banner = typeof options1.banner === "function" ? options1.banner({
1310
- format
1311
- }) : options1.banner;
1312
- const footer = typeof options1.footer === "function" ? options1.footer({
1313
- format
1314
- }) : options1.footer;
1337
+ const banner = typeof options2.banner === "function" ? options2.banner({ format }) : options2.banner;
1338
+ const footer = typeof options2.footer === "function" ? options2.footer({ format }) : options2.footer;
1315
1339
  try {
1316
1340
  result = await _esbuild.build.call(void 0, {
1317
- entryPoints: options1.entry,
1318
- format: format === "cjs" && splitting || options1.treeshake ? "esm" : format,
1319
- bundle: typeof options1.bundle === "undefined" ? true : options1.bundle,
1341
+ entryPoints: options2.entry,
1342
+ format: format === "cjs" && splitting || options2.treeshake ? "esm" : format,
1343
+ bundle,
1320
1344
  platform,
1321
- globalName: options1.globalName,
1322
- jsxFactory: options1.jsxFactory,
1323
- jsxFragment: options1.jsxFragment,
1324
- sourcemap: options1.sourcemap ? "external" : false,
1325
- target: options1.target,
1345
+ globalName: options2.globalName,
1346
+ jsxFactory: options2.jsxFactory,
1347
+ jsxFragment: options2.jsxFragment,
1348
+ sourcemap: options2.sourcemap ? "external" : false,
1349
+ target: options2.target,
1326
1350
  banner,
1327
1351
  footer,
1328
- tsconfig: options1.tsconfig,
1352
+ tsconfig: options2.tsconfig,
1329
1353
  loader: {
1330
1354
  ".aac": "file",
1331
1355
  ".css": "file",
@@ -1348,21 +1372,14 @@ var require_dist = __commonJS({
1348
1372
  ".woff2": "file",
1349
1373
  ...loader
1350
1374
  },
1351
- mainFields: platform === "node" ? [
1352
- "module",
1353
- "main"
1354
- ] : [
1355
- "browser",
1356
- "module",
1357
- "main"
1358
- ],
1375
+ mainFields: platform === "node" ? ["module", "main"] : ["browser", "module", "main"],
1359
1376
  plugins: esbuildPlugins.filter(_chunkTWFEYLU4js.truthy),
1360
1377
  define: {
1361
1378
  TSUP_FORMAT: JSON.stringify(format),
1362
1379
  ...format === "cjs" && injectShims ? {
1363
1380
  "import.meta.url": "importMetaUrl"
1364
1381
  } : {},
1365
- ...options1.define,
1382
+ ...options2.define,
1366
1383
  ...Object.keys(env).reduce((res, key) => {
1367
1384
  const value = JSON.stringify(env[key]);
1368
1385
  return {
@@ -1375,21 +1392,19 @@ var require_dist = __commonJS({
1375
1392
  inject: [
1376
1393
  format === "cjs" && injectShims ? _path2.default.join(__dirname, "../assets/cjs_shims.js") : "",
1377
1394
  format === "esm" && injectShims && platform === "node" ? _path2.default.join(__dirname, "../assets/esm_shims.js") : "",
1378
- ...options1.inject || []
1395
+ ...options2.inject || []
1379
1396
  ].filter(Boolean),
1380
- outdir: options1.legacyOutput && format !== "cjs" ? _path2.default.join(outDir, format) : outDir,
1381
- outExtension: options1.legacyOutput ? void 0 : outExtension,
1397
+ outdir: options2.legacyOutput && format !== "cjs" ? _path2.default.join(outDir, format) : outDir,
1398
+ outExtension: options2.legacyOutput ? void 0 : outExtension,
1382
1399
  write: false,
1383
1400
  splitting,
1384
1401
  logLevel: "error",
1385
- minify: options1.minify === "terser" ? false : options1.minify,
1386
- minifyWhitespace: options1.minifyWhitespace,
1387
- minifyIdentifiers: options1.minifyIdentifiers,
1388
- minifySyntax: options1.minifySyntax,
1389
- keepNames: options1.keepNames,
1390
- pure: typeof options1.pure === "string" ? [
1391
- options1.pure
1392
- ] : options1.pure,
1402
+ minify: options2.minify === "terser" ? false : options2.minify,
1403
+ minifyWhitespace: options2.minifyWhitespace,
1404
+ minifyIdentifiers: options2.minifyIdentifiers,
1405
+ minifySyntax: options2.minifySyntax,
1406
+ keepNames: options2.keepNames,
1407
+ pure: typeof options2.pure === "string" ? [options2.pure] : options2.pure,
1393
1408
  metafile: true
1394
1409
  });
1395
1410
  } catch (error) {
@@ -1398,7 +1413,10 @@ var require_dist = __commonJS({
1398
1413
  }
1399
1414
  if (result && result.warnings && !_chunkVGC3FXLUjs.getSilent.call(void 0)) {
1400
1415
  const messages = result.warnings.filter((warning) => {
1401
- 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;
1416
+ if (warning.text.includes(
1417
+ `This call to "require" will not be bundled because`
1418
+ ) || warning.text.includes(`Indirect calls to "require" will not be bundled`))
1419
+ return false;
1402
1420
  return true;
1403
1421
  });
1404
1422
  const formatted = await _esbuild.formatMessages.call(void 0, messages, {
@@ -1411,7 +1429,7 @@ var require_dist = __commonJS({
1411
1429
  }
1412
1430
  if (result && result.outputFiles) {
1413
1431
  await pluginContainer.buildFinished({
1414
- options: options1,
1432
+ options: options2,
1415
1433
  outputFiles: result.outputFiles,
1416
1434
  metafile: result.metafile
1417
1435
  });
@@ -1422,12 +1440,14 @@ var require_dist = __commonJS({
1422
1440
  for (const file of Object.keys(result.metafile.inputs)) {
1423
1441
  buildDependencies.add(file);
1424
1442
  }
1425
- if (options1.metafile) {
1443
+ if (options2.metafile) {
1426
1444
  const outPath = _path2.default.resolve(outDir, `metafile-${format}.json`);
1427
- await _fs2.default.promises.mkdir(_path2.default.dirname(outPath), {
1428
- recursive: true
1429
- });
1430
- await _fs2.default.promises.writeFile(outPath, JSON.stringify(result.metafile), "utf8");
1445
+ await _fs2.default.promises.mkdir(_path2.default.dirname(outPath), { recursive: true });
1446
+ await _fs2.default.promises.writeFile(
1447
+ outPath,
1448
+ JSON.stringify(result.metafile),
1449
+ "utf8"
1450
+ );
1431
1451
  }
1432
1452
  }
1433
1453
  }
@@ -1450,12 +1470,10 @@ var require_dist = __commonJS({
1450
1470
  this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path)) {
1451
1471
  return;
1452
1472
  }
1453
- const { transform: transform3 } = await Promise.resolve().then(() => _interopRequireWildcard(__require("sucrase")));
1473
+ const { transform: transform3 } = await Promise.resolve().then(() => _interopRequireWildcard(__import_sucrase));
1454
1474
  const result = transform3(code, {
1455
1475
  filePath: info.path,
1456
- transforms: [
1457
- "imports"
1458
- ],
1476
+ transforms: ["imports"],
1459
1477
  sourceMapOptions: this.options.sourcemap ? {
1460
1478
  compiledFilename: info.path
1461
1479
  } : void 0
@@ -1467,18 +1485,14 @@ var require_dist = __commonJS({
1467
1485
  }
1468
1486
  };
1469
1487
  }, "cjsSplitting");
1470
- var _sourcemap = __require("source-map");
1471
- var outputFile = /* @__PURE__ */ __name(async (filepath, data, options1) => {
1472
- await _fs2.default.promises.mkdir(_path2.default.dirname(filepath), {
1473
- recursive: true
1474
- });
1475
- await _fs2.default.promises.writeFile(filepath, data, options1);
1488
+ var _sourcemap = __import_sourceMap;
1489
+ var outputFile = /* @__PURE__ */ __name(async (filepath, data, options2) => {
1490
+ await _fs2.default.promises.mkdir(_path2.default.dirname(filepath), { recursive: true });
1491
+ await _fs2.default.promises.writeFile(filepath, data, options2);
1476
1492
  }, "outputFile");
1477
1493
  function copyDirSync(srcDir, destDir) {
1478
1494
  if (!_fs2.default.existsSync(srcDir)) return;
1479
- _fs2.default.mkdirSync(destDir, {
1480
- recursive: true
1481
- });
1495
+ _fs2.default.mkdirSync(destDir, { recursive: true });
1482
1496
  for (const file of _fs2.default.readdirSync(srcDir)) {
1483
1497
  const srcFile = _path2.default.resolve(srcDir, file);
1484
1498
  if (srcFile === destDir) {
@@ -1513,10 +1527,10 @@ var require_dist = __commonJS({
1513
1527
  if (!this.context) throw new Error(`Plugin context is not set`);
1514
1528
  return this.context;
1515
1529
  }
1516
- modifyEsbuildOptions(options1) {
1530
+ modifyEsbuildOptions(options2) {
1517
1531
  for (const plugin of this.plugins) {
1518
1532
  if (plugin.esbuildOptions) {
1519
- plugin.esbuildOptions.call(this.getContext(), options1);
1533
+ plugin.esbuildOptions.call(this.getContext(), options2);
1520
1534
  }
1521
1535
  }
1522
1536
  }
@@ -1527,106 +1541,93 @@ var require_dist = __commonJS({
1527
1541
  }
1528
1542
  }
1529
1543
  }
1530
- async buildFinished({ options: options1, outputFiles, metafile }) {
1544
+ async buildFinished({
1545
+ options: options2,
1546
+ outputFiles,
1547
+ metafile
1548
+ }) {
1531
1549
  const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
1532
1550
  if (isJS(file.path) || isCSS(file.path)) {
1533
- const relativePath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), file.path));
1534
- const meta = _optionalChain([
1535
- metafile,
1536
- "optionalAccess",
1537
- (_6) => _6.outputs,
1538
- "access",
1539
- (_7) => _7[relativePath]
1540
- ]);
1551
+ const relativePath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), file.path));
1552
+ const meta = _optionalChain([metafile, "optionalAccess", (_6) => _6.outputs, "access", (_7) => _7[relativePath]]);
1541
1553
  return {
1542
1554
  type: "chunk",
1543
1555
  path: file.path,
1544
1556
  code: file.text,
1545
- map: _optionalChain([
1546
- outputFiles,
1547
- "access",
1548
- (_8) => _8.find,
1549
- "call",
1550
- (_9) => _9((f) => f.path === `${file.path}.map`),
1551
- "optionalAccess",
1552
- (_10) => _10.text
1553
- ]),
1554
- entryPoint: _optionalChain([
1555
- meta,
1556
- "optionalAccess",
1557
- (_11) => _11.entryPoint
1558
- ]),
1559
- exports: _optionalChain([
1560
- meta,
1561
- "optionalAccess",
1562
- (_12) => _12.exports
1563
- ]),
1564
- imports: _optionalChain([
1565
- meta,
1566
- "optionalAccess",
1567
- (_13) => _13.imports
1568
- ])
1557
+ map: _optionalChain([outputFiles, "access", (_8) => _8.find, "call", (_9) => _9((f) => f.path === `${file.path}.map`), "optionalAccess", (_10) => _10.text]),
1558
+ entryPoint: _optionalChain([meta, "optionalAccess", (_11) => _11.entryPoint]),
1559
+ exports: _optionalChain([meta, "optionalAccess", (_12) => _12.exports]),
1560
+ imports: _optionalChain([meta, "optionalAccess", (_13) => _13.imports])
1569
1561
  };
1570
1562
  } else {
1571
- return {
1572
- type: "asset",
1573
- path: file.path,
1574
- contents: file.contents
1575
- };
1563
+ return { type: "asset", path: file.path, contents: file.contents };
1576
1564
  }
1577
1565
  });
1578
1566
  const writtenFiles = [];
1579
- await Promise.all(files.map(async (info) => {
1580
- for (const plugin of this.plugins) {
1581
- if (info.type === "chunk" && plugin.renderChunk) {
1582
- const result = await plugin.renderChunk.call(this.getContext(), info.code, info);
1583
- if (result) {
1584
- info.code = result.code;
1585
- if (result.map) {
1586
- const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(info.map));
1587
- const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(result.map));
1588
- const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer);
1589
- generator.applySourceMap(originalConsumer, info.path);
1590
- info.map = generator.toJSON();
1591
- originalConsumer.destroy();
1592
- newConsumer.destroy();
1567
+ await Promise.all(
1568
+ files.map(async (info) => {
1569
+ for (const plugin of this.plugins) {
1570
+ if (info.type === "chunk" && plugin.renderChunk) {
1571
+ const result = await plugin.renderChunk.call(
1572
+ this.getContext(),
1573
+ info.code,
1574
+ info
1575
+ );
1576
+ if (result) {
1577
+ info.code = result.code;
1578
+ if (result.map) {
1579
+ const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(
1580
+ parseSourceMap(info.map)
1581
+ );
1582
+ const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(
1583
+ parseSourceMap(result.map)
1584
+ );
1585
+ const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer);
1586
+ generator.applySourceMap(originalConsumer, info.path);
1587
+ info.map = generator.toJSON();
1588
+ originalConsumer.destroy();
1589
+ newConsumer.destroy();
1590
+ }
1593
1591
  }
1594
1592
  }
1595
1593
  }
1596
- }
1597
- const inlineSourceMap = this.context.options.sourcemap === "inline";
1598
- const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents;
1599
- await outputFile(info.path, contents, {
1600
- mode: info.type === "chunk" ? info.mode : void 0
1601
- });
1602
- writtenFiles.push({
1603
- get name() {
1604
- return _path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), info.path);
1605
- },
1606
- get size() {
1607
- return contents.length;
1608
- }
1609
- });
1610
- if (info.type === "chunk" && info.map && !inlineSourceMap) {
1611
- const map = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
1612
- const outPath = `${info.path}.map`;
1613
- const contents2 = JSON.stringify(map);
1614
- await outputFile(outPath, contents2);
1594
+ const inlineSourceMap = this.context.options.sourcemap === "inline";
1595
+ const contents2 = info.type === "chunk" ? info.code + getSourcemapComment(
1596
+ inlineSourceMap,
1597
+ info.map,
1598
+ info.path,
1599
+ isCSS(info.path)
1600
+ ) : info.contents;
1601
+ await outputFile(info.path, contents2, {
1602
+ mode: info.type === "chunk" ? info.mode : void 0
1603
+ });
1615
1604
  writtenFiles.push({
1616
1605
  get name() {
1617
- return _path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), outPath);
1606
+ return _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), info.path);
1618
1607
  },
1619
1608
  get size() {
1620
1609
  return contents2.length;
1621
1610
  }
1622
1611
  });
1623
- }
1624
- }));
1612
+ if (info.type === "chunk" && info.map && !inlineSourceMap) {
1613
+ const map = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
1614
+ const outPath = `${info.path}.map`;
1615
+ const contents22 = JSON.stringify(map);
1616
+ await outputFile(outPath, contents22);
1617
+ writtenFiles.push({
1618
+ get name() {
1619
+ return _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), outPath);
1620
+ },
1621
+ get size() {
1622
+ return contents22.length;
1623
+ }
1624
+ });
1625
+ }
1626
+ })
1627
+ );
1625
1628
  for (const plugin of this.plugins) {
1626
1629
  if (plugin.buildEnd) {
1627
- await plugin.buildEnd.call(this.getContext(), {
1628
- writtenFiles
1629
- });
1630
+ await plugin.buildEnd.call(this.getContext(), { writtenFiles });
1630
1631
  }
1631
1632
  }
1632
1633
  }
@@ -1635,22 +1636,21 @@ var require_dist = __commonJS({
1635
1636
  if (!map) return "";
1636
1637
  const prefix = isCssFile ? "/*" : "//";
1637
1638
  const suffix = isCssFile ? " */" : "";
1638
- const url = inline ? `data:application/json;base64,${Buffer.from(typeof map === "string" ? map : JSON.stringify(map)).toString("base64")}` : `${_path2.default.basename(filepath)}.map`;
1639
+ const url = inline ? `data:application/json;base64,${Buffer.from(
1640
+ typeof map === "string" ? map : JSON.stringify(map)
1641
+ ).toString("base64")}` : `${_path2.default.basename(filepath)}.map`;
1639
1642
  return `${prefix}# sourceMappingURL=${url}${suffix}`;
1640
1643
  }, "getSourcemapComment");
1641
- var TARGETS = [
1642
- "es5",
1643
- "es3"
1644
- ];
1644
+ var TARGETS = ["es5", "es3"];
1645
1645
  var swcTarget = /* @__PURE__ */ __name(() => {
1646
1646
  let enabled = false;
1647
1647
  let target;
1648
1648
  return {
1649
1649
  name: "swc-target",
1650
- esbuildOptions(options1) {
1651
- if (typeof options1.target === "string" && TARGETS.includes(options1.target)) {
1652
- target = options1.target;
1653
- options1.target = "es2020";
1650
+ esbuildOptions(options2) {
1651
+ if (typeof options2.target === "string" && TARGETS.includes(options2.target)) {
1652
+ target = options2.target;
1653
+ options2.target = "es2020";
1654
1654
  enabled = true;
1655
1655
  }
1656
1656
  },
@@ -1660,7 +1660,9 @@ var require_dist = __commonJS({
1660
1660
  }
1661
1661
  const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
1662
1662
  if (!swc) {
1663
- throw new (0, _chunkJZ25TPTYjs.PrettyError)(`@swc/core is required for ${target} target. Please install it with \`npm install @swc/core -D\``);
1663
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(
1664
+ `@swc/core is required for ${target} target. Please install it with \`npm install @swc/core -D\``
1665
+ );
1664
1666
  }
1665
1667
  const result = await swc.transform(code, {
1666
1668
  filename: info.path,
@@ -1674,9 +1676,7 @@ var require_dist = __commonJS({
1674
1676
  minify: this.options.minify === true ? {
1675
1677
  compress: false,
1676
1678
  mangle: {
1677
- reserved: this.options.globalName ? [
1678
- this.options.globalName
1679
- ] : []
1679
+ reserved: this.options.globalName ? [this.options.globalName] : []
1680
1680
  }
1681
1681
  } : void 0
1682
1682
  },
@@ -1695,25 +1695,32 @@ var require_dist = __commonJS({
1695
1695
  return {
1696
1696
  name: "size-reporter",
1697
1697
  buildEnd({ writtenFiles }) {
1698
- _chunkVGC3FXLUjs.reportSize.call(void 0, this.logger, this.format, writtenFiles.reduce((res, file) => {
1699
- return {
1700
- ...res,
1701
- [file.name]: file.size
1702
- };
1703
- }, {}));
1698
+ _chunkVGC3FXLUjs.reportSize.call(
1699
+ void 0,
1700
+ this.logger,
1701
+ this.format,
1702
+ writtenFiles.reduce((res, file) => {
1703
+ return {
1704
+ ...res,
1705
+ [file.name]: file.size
1706
+ };
1707
+ }, {})
1708
+ );
1704
1709
  }
1705
1710
  };
1706
1711
  }, "sizeReporter");
1707
- var _rollup = __require("rollup");
1708
- var treeShakingPlugin = /* @__PURE__ */ __name(({ treeshake, name, silent }) => {
1712
+ var _rollup = __import_rollup;
1713
+ var treeShakingPlugin = /* @__PURE__ */ __name(({
1714
+ treeshake,
1715
+ name: name2,
1716
+ silent
1717
+ }) => {
1709
1718
  return {
1710
1719
  name: "tree-shaking",
1711
1720
  async renderChunk(code, info) {
1712
1721
  if (!treeshake || !/\.(cjs|js|mjs)$/.test(info.path)) return;
1713
1722
  const bundle = await _rollup.rollup.call(void 0, {
1714
- input: [
1715
- info.path
1716
- ],
1723
+ input: [info.path],
1717
1724
  plugins: [
1718
1725
  {
1719
1726
  name: "tsup",
@@ -1722,10 +1729,7 @@ var require_dist = __commonJS({
1722
1729
  return false;
1723
1730
  },
1724
1731
  load(id) {
1725
- if (id === info.path) return {
1726
- code,
1727
- map: info.map
1728
- };
1732
+ if (id === info.path) return { code, map: info.map };
1729
1733
  }
1730
1734
  }
1731
1735
  ],
@@ -1741,7 +1745,7 @@ var require_dist = __commonJS({
1741
1745
  file: info.path,
1742
1746
  sourcemap: !!this.options.sourcemap,
1743
1747
  compact: !!this.options.minify,
1744
- name
1748
+ name: name2
1745
1749
  });
1746
1750
  for (const file of result.output) {
1747
1751
  if (file.type === "chunk" && file.fileName === _path2.default.basename(info.path)) {
@@ -1760,17 +1764,29 @@ var require_dist = __commonJS({
1760
1764
  }, "copyPublicDir");
1761
1765
  var isInPublicDir = /* @__PURE__ */ __name((publicDir, filePath) => {
1762
1766
  if (!publicDir) return false;
1763
- const publicPath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.resolve(publicDir === true ? "public" : publicDir));
1767
+ const publicPath = _chunkTWFEYLU4js.slash.call(
1768
+ void 0,
1769
+ _path2.default.resolve(publicDir === true ? "public" : publicDir)
1770
+ );
1764
1771
  return _chunkTWFEYLU4js.slash.call(void 0, _path2.default.resolve(filePath)).startsWith(`${publicPath}/`);
1765
1772
  }, "isInPublicDir");
1766
- var terserPlugin = /* @__PURE__ */ __name(({ minifyOptions, format, terserOptions = {}, globalName, logger: logger3 }) => {
1773
+ var terserPlugin = /* @__PURE__ */ __name(({
1774
+ minifyOptions,
1775
+ format,
1776
+ terserOptions = {},
1777
+ globalName,
1778
+ logger: logger3
1779
+ }) => {
1767
1780
  return {
1768
1781
  name: "terser",
1769
1782
  async renderChunk(code, info) {
1770
- if (minifyOptions !== "terser" || !/\.(cjs|js|mjs)$/.test(info.path)) return;
1783
+ if (minifyOptions !== "terser" || !/\.(cjs|js|mjs)$/.test(info.path))
1784
+ return;
1771
1785
  const terser = _chunkTWFEYLU4js.localRequire.call(void 0, "terser");
1772
1786
  if (!terser) {
1773
- throw new (0, _chunkJZ25TPTYjs.PrettyError)("terser is required for terser minification. Please install it with `npm install terser -D`");
1787
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(
1788
+ "terser is required for terser minification. Please install it with `npm install terser -D`"
1789
+ );
1774
1790
  }
1775
1791
  const { minify } = terser;
1776
1792
  const defaultOptions = {};
@@ -1780,33 +1796,25 @@ var require_dist = __commonJS({
1780
1796
  defaultOptions.toplevel = true;
1781
1797
  }
1782
1798
  try {
1783
- const minifiedOutput = await minify({
1784
- [info.path]: code
1785
- }, {
1786
- ...defaultOptions,
1787
- ...terserOptions
1788
- });
1799
+ const minifiedOutput = await minify(
1800
+ { [info.path]: code },
1801
+ { ...defaultOptions, ...terserOptions }
1802
+ );
1789
1803
  logger3.info("TERSER", "Minifying with Terser");
1790
1804
  if (!minifiedOutput.code) {
1791
1805
  logger3.error("TERSER", "Failed to minify with terser");
1792
1806
  }
1793
1807
  logger3.success("TERSER", "Terser Minification success");
1794
- return {
1795
- code: minifiedOutput.code,
1796
- map: minifiedOutput.map
1797
- };
1808
+ return { code: minifiedOutput.code, map: minifiedOutput.map };
1798
1809
  } catch (error) {
1799
1810
  logger3.error("TERSER", "Failed to minify with terser");
1800
1811
  logger3.error("TERSER", error);
1801
1812
  }
1802
- return {
1803
- code,
1804
- map: info.map
1805
- };
1813
+ return { code, map: info.map };
1806
1814
  }
1807
1815
  };
1808
1816
  }, "terserPlugin");
1809
- var _typescript = __require("typescript");
1817
+ var _typescript = __import_typescript;
1810
1818
  var _typescript2 = _interopRequireDefault(_typescript);
1811
1819
  var logger = _chunkVGC3FXLUjs.createLogger.call(void 0);
1812
1820
  var AliasPool = (_class = class {
@@ -1819,13 +1827,15 @@ var require_dist = __commonJS({
1819
1827
  __init() {
1820
1828
  this.seen = /* @__PURE__ */ new Set();
1821
1829
  }
1822
- assign(name) {
1830
+ assign(name2) {
1823
1831
  let suffix = 0;
1824
- let alias = name === "default" ? "default_alias" : name;
1832
+ let alias = name2 === "default" ? "default_alias" : name2;
1825
1833
  while (this.seen.has(alias)) {
1826
- alias = `${name}_alias_${++suffix}`;
1834
+ alias = `${name2}_alias_${++suffix}`;
1827
1835
  if (suffix >= 1e3) {
1828
- throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
1836
+ throw new Error(
1837
+ "Alias generation exceeded limit. Possible infinite loop detected."
1838
+ );
1829
1839
  }
1830
1840
  }
1831
1841
  this.seen.add(alias);
@@ -1851,20 +1861,20 @@ var require_dist = __commonJS({
1851
1861
  if (!moduleSymbol) {
1852
1862
  return [];
1853
1863
  }
1854
- const exports1 = [];
1864
+ const exports2 = [];
1855
1865
  const exportSymbols = checker.getExportsOfModule(moduleSymbol);
1856
1866
  exportSymbols.forEach((symbol) => {
1857
- const name = symbol.getName();
1858
- exports1.push({
1867
+ const name2 = symbol.getName();
1868
+ exports2.push({
1859
1869
  kind: "named",
1860
1870
  sourceFileName,
1861
1871
  destFileName,
1862
- name,
1863
- alias: assignAlias(name),
1872
+ name: name2,
1873
+ alias: assignAlias(name2),
1864
1874
  isTypeOnly: false
1865
1875
  });
1866
1876
  });
1867
- return exports1;
1877
+ return exports2;
1868
1878
  }
1869
1879
  __name(extractExports, "extractExports");
1870
1880
  return program.getRootFileNames().flatMap(extractExports);
@@ -1873,40 +1883,56 @@ var require_dist = __commonJS({
1873
1883
  function emitDtsFiles(program, host) {
1874
1884
  const fileMapping = /* @__PURE__ */ new Map();
1875
1885
  const writeFile = /* @__PURE__ */ __name((fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
1876
- const sourceFile = _optionalChain([
1877
- sourceFiles,
1878
- "optionalAccess",
1879
- (_14) => _14[0]
1880
- ]);
1881
- const sourceFileName = _optionalChain([
1882
- sourceFile,
1883
- "optionalAccess",
1884
- (_15) => _15.fileName
1885
- ]);
1886
+ const sourceFile = _optionalChain([sourceFiles, "optionalAccess", (_14) => _14[0]]);
1887
+ const sourceFileName = _optionalChain([sourceFile, "optionalAccess", (_15) => _15.fileName]);
1886
1888
  if (sourceFileName && !fileName.endsWith(".map")) {
1887
1889
  const cwd = program.getCurrentDirectory();
1888
- fileMapping.set(_chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd), _chunkTWFEYLU4js.toAbsolutePath.call(void 0, fileName, cwd));
1890
+ fileMapping.set(
1891
+ _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd),
1892
+ _chunkTWFEYLU4js.toAbsolutePath.call(void 0, fileName, cwd)
1893
+ );
1889
1894
  }
1890
- return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
1895
+ return host.writeFile(
1896
+ fileName,
1897
+ text,
1898
+ writeByteOrderMark,
1899
+ onError,
1900
+ sourceFiles,
1901
+ data
1902
+ );
1891
1903
  }, "writeFile");
1892
1904
  const emitResult = program.emit(void 0, writeFile, void 0, true);
1893
1905
  const diagnostics = _typescript2.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
1894
1906
  const diagnosticMessages = [];
1895
1907
  diagnostics.forEach((diagnostic) => {
1896
1908
  if (diagnostic.file) {
1897
- const { line, character } = _typescript2.default.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
1898
- const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
1899
- diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
1909
+ const { line: line2, character } = _typescript2.default.getLineAndCharacterOfPosition(
1910
+ diagnostic.file,
1911
+ diagnostic.start
1912
+ );
1913
+ const message = _typescript2.default.flattenDiagnosticMessageText(
1914
+ diagnostic.messageText,
1915
+ "\n"
1916
+ );
1917
+ diagnosticMessages.push(
1918
+ `${diagnostic.file.fileName} (${line2 + 1},${character + 1}): ${message}`
1919
+ );
1900
1920
  } else {
1901
- const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
1921
+ const message = _typescript2.default.flattenDiagnosticMessageText(
1922
+ diagnostic.messageText,
1923
+ "\n"
1924
+ );
1902
1925
  diagnosticMessages.push(message);
1903
1926
  }
1904
1927
  });
1905
1928
  const diagnosticMessage = diagnosticMessages.join("\n");
1906
1929
  if (diagnosticMessage) {
1907
- logger.error("TSC", `Failed to emit declaration files.
1930
+ logger.error(
1931
+ "TSC",
1932
+ `Failed to emit declaration files.
1908
1933
 
1909
- ${diagnosticMessage}`);
1934
+ ${diagnosticMessage}`
1935
+ );
1910
1936
  throw new Error("TypeScript compilation failed");
1911
1937
  }
1912
1938
  return fileMapping;
@@ -1922,60 +1948,69 @@ ${diagnosticMessage}`);
1922
1948
  }
1923
1949
  }
1924
1950
  const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, _options);
1925
- const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent({
1926
- ...rawTsconfig.data,
1927
- compilerOptions: {
1928
- ..._optionalChain([
1929
- rawTsconfig,
1930
- "access",
1931
- (_16) => _16.data,
1932
- "optionalAccess",
1933
- (_17) => _17.compilerOptions
1934
- ]),
1935
- ...compilerOptions,
1936
- // Enable declaration emit and disable javascript emit
1937
- noEmit: false,
1938
- declaration: true,
1939
- declarationMap: true,
1940
- declarationDir,
1941
- emitDeclarationOnly: true
1942
- }
1943
- }, _typescript2.default.sys, tsconfig ? _path.dirname.call(void 0, tsconfig) : "./");
1944
- const options1 = parsedTsconfig.options;
1945
- const host = _typescript2.default.createCompilerHost(options1);
1946
- const program = _typescript2.default.createProgram(parsedTsconfig.fileNames, options1, host);
1951
+ const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent(
1952
+ {
1953
+ ...rawTsconfig.data,
1954
+ compilerOptions: {
1955
+ ..._optionalChain([rawTsconfig, "access", (_16) => _16.data, "optionalAccess", (_17) => _17.compilerOptions]),
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
+ },
1965
+ _typescript2.default.sys,
1966
+ tsconfig ? _path.dirname.call(void 0, tsconfig) : "./"
1967
+ );
1968
+ const options2 = parsedTsconfig.options;
1969
+ const host = _typescript2.default.createCompilerHost(options2);
1970
+ const program = _typescript2.default.createProgram(
1971
+ parsedTsconfig.fileNames,
1972
+ options2,
1973
+ host
1974
+ );
1947
1975
  const fileMapping = emitDtsFiles(program, host);
1948
1976
  return getExports(program, fileMapping);
1949
1977
  }
1950
1978
  __name(emit, "emit");
1951
- function runTypeScriptCompiler(options1) {
1979
+ function runTypeScriptCompiler(options2) {
1952
1980
  try {
1953
1981
  const start = Date.now();
1954
1982
  const getDuration = /* @__PURE__ */ __name(() => {
1955
1983
  return `${Math.floor(Date.now() - start)}ms`;
1956
1984
  }, "getDuration");
1957
1985
  logger.info("tsc", "Build start");
1958
- const dtsOptions = options1.experimentalDts;
1959
- const exports1 = emit(dtsOptions.compilerOptions, options1.tsconfig, options1);
1986
+ const dtsOptions = options2.experimentalDts;
1987
+ const exports2 = emit(dtsOptions.compilerOptions, options2.tsconfig, options2);
1960
1988
  logger.success("tsc", `\u26A1\uFE0F Build success in ${getDuration()}`);
1961
- return exports1;
1989
+ return exports2;
1962
1990
  } catch (error) {
1963
1991
  _chunkJZ25TPTYjs.handleError.call(void 0, error);
1964
1992
  logger.error("tsc", "Build error");
1965
1993
  }
1966
1994
  }
1967
1995
  __name(runTypeScriptCompiler, "runTypeScriptCompiler");
1968
- function formatAggregationExports(exports1, declarationDirPath) {
1969
- const lines = exports1.map((declaration) => formatAggregationExport(declaration, declarationDirPath)).filter(_chunkTWFEYLU4js.truthy);
1970
- if (lines.length === 0) {
1971
- lines.push("export {};");
1972
- }
1973
- return `${lines.join("\n")}
1996
+ function formatAggregationExports(exports2, declarationDirPath) {
1997
+ const lines2 = exports2.map(
1998
+ (declaration) => formatAggregationExport(declaration, declarationDirPath)
1999
+ ).filter(_chunkTWFEYLU4js.truthy);
2000
+ if (lines2.length === 0) {
2001
+ lines2.push("export {};");
2002
+ }
2003
+ return `${lines2.join("\n")}
1974
2004
  `;
1975
2005
  }
1976
2006
  __name(formatAggregationExports, "formatAggregationExports");
1977
2007
  function formatAggregationExport(declaration, declarationDirPath) {
1978
- const dest = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(void 0, `./${_path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(declarationDirPath, declaration.destFileName)))}`);
2008
+ const dest = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(
2009
+ void 0,
2010
+ `./${_path2.default.posix.normalize(
2011
+ _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(declarationDirPath, declaration.destFileName))
2012
+ )}`
2013
+ );
1979
2014
  if (declaration.kind === "module") {
1980
2015
  return "";
1981
2016
  } else if (declaration.kind === "named") {
@@ -1993,8 +2028,14 @@ ${diagnosticMessage}`);
1993
2028
  }
1994
2029
  }
1995
2030
  __name(formatAggregationExport, "formatAggregationExport");
1996
- function formatDistributionExports(exports1, fromFilePath, toFilePath) {
1997
- 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))));
2031
+ function formatDistributionExports(exports2, fromFilePath, toFilePath) {
2032
+ let importPath = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(
2033
+ void 0,
2034
+ _path2.default.posix.relative(
2035
+ _path2.default.posix.dirname(_path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, fromFilePath))),
2036
+ _path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, toFilePath))
2037
+ )
2038
+ );
1998
2039
  if (!/^\.+\//.test(importPath)) {
1999
2040
  importPath = `./${importPath}`;
2000
2041
  }
@@ -2002,7 +2043,7 @@ ${diagnosticMessage}`);
2002
2043
  named: /* @__PURE__ */ new Set(),
2003
2044
  module: /* @__PURE__ */ new Set()
2004
2045
  };
2005
- const lines = exports1.filter((declaration) => {
2046
+ const lines2 = exports2.filter((declaration) => {
2006
2047
  if (declaration.kind === "module") {
2007
2048
  if (seen.module.has(declaration.moduleName)) {
2008
2049
  return false;
@@ -2019,10 +2060,10 @@ ${diagnosticMessage}`);
2019
2060
  return false;
2020
2061
  }
2021
2062
  }).map((declaration) => formatDistributionExport(declaration, importPath)).filter(_chunkTWFEYLU4js.truthy);
2022
- if (lines.length === 0) {
2023
- lines.push("export {};");
2063
+ if (lines2.length === 0) {
2064
+ lines2.push("export {};");
2024
2065
  }
2025
- return `${lines.join("\n")}
2066
+ return `${lines2.join("\n")}
2026
2067
  `;
2027
2068
  }
2028
2069
  __name(formatDistributionExports, "formatDistributionExports");
@@ -2044,8 +2085,8 @@ ${diagnosticMessage}`);
2044
2085
  }
2045
2086
  __name(formatDistributionExport, "formatDistributionExport");
2046
2087
  var logger2 = _chunkVGC3FXLUjs.createLogger.call(void 0);
2047
- function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath, options1) {
2048
- const cwd = options1.workspaceConfig?.workspaceRoot || process.cwd();
2088
+ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath, options2) {
2089
+ const cwd = options2.workspaceConfig?.workspaceRoot || process.cwd();
2049
2090
  const packageJsonFullPath = _path2.default.join(cwd, "package.json");
2050
2091
  const configObject = {
2051
2092
  mainEntryPointFilePath: inputFilePath,
@@ -2054,16 +2095,12 @@ ${diagnosticMessage}`);
2054
2095
  // `reportFileName` is not been used. It's just to fit the requirement of API Extractor.
2055
2096
  reportFileName: "tsup-report.api.md"
2056
2097
  },
2057
- docModel: {
2058
- enabled: false
2059
- },
2098
+ docModel: { enabled: false },
2060
2099
  dtsRollup: {
2061
2100
  enabled: true,
2062
2101
  untrimmedFilePath: outputFilePath
2063
2102
  },
2064
- tsdocMetadata: {
2065
- enabled: false
2066
- },
2103
+ tsdocMetadata: { enabled: false },
2067
2104
  compiler: {
2068
2105
  tsconfigFilePath
2069
2106
  },
@@ -2077,7 +2114,9 @@ ${diagnosticMessage}`);
2077
2114
  };
2078
2115
  const imported = _chunkTWFEYLU4js.getApiExtractor.call(void 0);
2079
2116
  if (!imported) {
2080
- throw new Error(`@microsoft/api-extractor is not installed. Please install it first.`);
2117
+ throw new Error(
2118
+ `@microsoft/api-extractor is not installed. Please install it first.`
2119
+ );
2081
2120
  }
2082
2121
  const { ExtractorConfig, Extractor } = imported;
2083
2122
  const extractorConfig = ExtractorConfig.prepare(prepareOptions);
@@ -2088,62 +2127,68 @@ ${diagnosticMessage}`);
2088
2127
  showVerboseMessages: true
2089
2128
  });
2090
2129
  if (!extractorResult.succeeded) {
2091
- throw new Error(`API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings when processing ${inputFilePath}`);
2130
+ throw new Error(
2131
+ `API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings when processing ${inputFilePath}`
2132
+ );
2092
2133
  }
2093
2134
  }
2094
2135
  __name(rollupDtsFile, "rollupDtsFile");
2095
- async function rollupDtsFiles(options1, exports1, format) {
2096
- if (!options1.experimentalDts || !_optionalChain([
2097
- options1,
2098
- "access",
2099
- (_18) => _18.experimentalDts,
2100
- "optionalAccess",
2101
- (_19) => _19.entry
2102
- ])) {
2136
+ async function rollupDtsFiles(options2, exports2, format) {
2137
+ if (!options2.experimentalDts || !_optionalChain([options2, "access", (_18) => _18.experimentalDts, "optionalAccess", (_19) => _19.entry])) {
2103
2138
  return;
2104
2139
  }
2105
- const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, options1);
2106
- const outDir = options1.outDir || "dist";
2107
- const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd());
2108
- const dtsExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, {
2109
- format,
2110
- pkgType: pkg.type
2111
- }).dts;
2112
- const tsconfig = options1.tsconfig || "tsconfig.json";
2113
- let dtsInputFilePath = _path2.default.join(declarationDir, `_tsup-dts-aggregation${dtsExtension}`);
2140
+ const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, options2);
2141
+ const outDir = options2.outDir || "dist";
2142
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2143
+ const dtsExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, { format, pkgType: pkg.type }).dts;
2144
+ const tsconfig = options2.tsconfig || "tsconfig.json";
2145
+ let dtsInputFilePath = _path2.default.join(
2146
+ declarationDir,
2147
+ `_tsup-dts-aggregation${dtsExtension}`
2148
+ );
2114
2149
  dtsInputFilePath = dtsInputFilePath.replace(/\.d\.mts$/, ".dmts.d.ts").replace(/\.d\.cts$/, ".dcts.d.ts");
2115
2150
  const dtsOutputFilePath = _path2.default.join(outDir, `_tsup-dts-rollup${dtsExtension}`);
2116
- _chunkTWFEYLU4js.writeFileSync.call(void 0, dtsInputFilePath, formatAggregationExports(exports1, declarationDir, options1));
2117
- rollupDtsFile(dtsInputFilePath, dtsOutputFilePath, tsconfig, options1);
2118
- for (let [out, sourceFileName] of Object.entries(options1.experimentalDts.entry)) {
2151
+ _chunkTWFEYLU4js.writeFileSync.call(
2152
+ void 0,
2153
+ dtsInputFilePath,
2154
+ formatAggregationExports(exports2, declarationDir, options2)
2155
+ );
2156
+ rollupDtsFile(dtsInputFilePath, dtsOutputFilePath, tsconfig, options2);
2157
+ for (let [out, sourceFileName] of Object.entries(
2158
+ options2.experimentalDts.entry
2159
+ )) {
2119
2160
  sourceFileName = _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName);
2120
2161
  const outFileName = _path2.default.join(outDir, out + dtsExtension);
2121
- const currentExports = exports1.filter((declaration) => declaration.sourceFileName === sourceFileName);
2122
- _chunkTWFEYLU4js.writeFileSync.call(void 0, outFileName, formatDistributionExports(currentExports, outFileName, dtsOutputFilePath));
2162
+ const currentExports = exports2.filter(
2163
+ (declaration) => declaration.sourceFileName === sourceFileName
2164
+ );
2165
+ _chunkTWFEYLU4js.writeFileSync.call(
2166
+ void 0,
2167
+ outFileName,
2168
+ formatDistributionExports(currentExports, outFileName, dtsOutputFilePath)
2169
+ );
2123
2170
  }
2124
2171
  }
2125
2172
  __name(rollupDtsFiles, "rollupDtsFiles");
2126
- async function cleanDtsFiles(options1) {
2127
- if (options1.clean) {
2128
- await _chunkTWFEYLU4js.removeFiles.call(void 0, [
2129
- "**/*.d.{ts,mts,cts}"
2130
- ], options1.outDir);
2173
+ async function cleanDtsFiles(options2) {
2174
+ if (options2.clean) {
2175
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, ["**/*.d.{ts,mts,cts}"], options2.outDir);
2131
2176
  }
2132
2177
  }
2133
2178
  __name(cleanDtsFiles, "cleanDtsFiles");
2134
- async function runDtsRollup(options1, exports1) {
2179
+ async function runDtsRollup(options2, exports2) {
2135
2180
  try {
2136
2181
  const start = Date.now();
2137
2182
  const getDuration = /* @__PURE__ */ __name(() => {
2138
2183
  return `${Math.floor(Date.now() - start)}ms`;
2139
2184
  }, "getDuration");
2140
2185
  logger2.info("dts", "Build start");
2141
- if (!exports1) {
2186
+ if (!exports2) {
2142
2187
  throw new Error("Unexpected internal error: dts exports is not define");
2143
2188
  }
2144
- await cleanDtsFiles(options1);
2145
- for (const format of options1.format) {
2146
- await rollupDtsFiles(options1, exports1, format);
2189
+ await cleanDtsFiles(options2);
2190
+ for (const format of options2.format) {
2191
+ await rollupDtsFiles(options2, exports2, format);
2147
2192
  }
2148
2193
  logger2.success("dts", `\u26A1\uFE0F Build success in ${getDuration()}`);
2149
2194
  } catch (error) {
@@ -2156,13 +2201,7 @@ ${diagnosticMessage}`);
2156
2201
  return {
2157
2202
  name: "cjs-interop",
2158
2203
  renderChunk(code, info) {
2159
- if (!this.options.cjsInterop || this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path) || !info.entryPoint || _optionalChain([
2160
- info,
2161
- "access",
2162
- (_20) => _20.exports,
2163
- "optionalAccess",
2164
- (_21) => _21.length
2165
- ]) !== 1 || info.exports[0] !== "default") {
2204
+ if (!this.options.cjsInterop || this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path) || !info.entryPoint || _optionalChain([info, "access", (_20) => _20.exports, "optionalAccess", (_21) => _21.length]) !== 1 || info.exports[0] !== "default") {
2166
2205
  return;
2167
2206
  }
2168
2207
  return {
@@ -2174,7 +2213,7 @@ module.exports = exports.default;
2174
2213
  }
2175
2214
  };
2176
2215
  }, "cjsInterop");
2177
- var defineConfig = /* @__PURE__ */ __name((options1) => options1, "defineConfig");
2216
+ var defineConfig = /* @__PURE__ */ __name((options2) => options2, "defineConfig");
2178
2217
  var isTaskkillCmdProcessNotFoundError = /* @__PURE__ */ __name((err) => {
2179
2218
  return process.platform === "win32" && "cmd" in err && "code" in err && typeof err.cmd === "string" && err.cmd.startsWith("taskkill") && err.code === 128;
2180
2219
  }, "isTaskkillCmdProcessNotFoundError");
@@ -2189,33 +2228,32 @@ module.exports = exports.default;
2189
2228
  ...optionsFromConfigFile,
2190
2229
  ...optionsOverride
2191
2230
  };
2192
- const options1 = {
2231
+ const options2 = {
2193
2232
  outDir: "dist",
2194
2233
  removeNodeProtocol: true,
2195
2234
  ..._options,
2196
- format: typeof _options.format === "string" ? [
2197
- _options.format
2198
- ] : _options.format || [
2199
- "cjs"
2200
- ],
2201
- dts: typeof _options.dts === "boolean" ? _options.dts ? {} : void 0 : typeof _options.dts === "string" ? {
2202
- entry: _options.dts
2203
- } : _options.dts,
2204
- experimentalDts: await _chunkTWFEYLU4js.resolveInitialExperimentalDtsConfig.call(void 0, _options.experimentalDts)
2235
+ format: typeof _options.format === "string" ? [_options.format] : _options.format || ["cjs"],
2236
+ dts: typeof _options.dts === "boolean" ? _options.dts ? {} : void 0 : typeof _options.dts === "string" ? { entry: _options.dts } : _options.dts,
2237
+ experimentalDts: await _chunkTWFEYLU4js.resolveInitialExperimentalDtsConfig.call(
2238
+ void 0,
2239
+ _options.experimentalDts
2240
+ )
2205
2241
  };
2206
- if (!options1.workspaceConfig) options1.workspaceConfig = {};
2207
- if (!options1.workspaceConfig.workspaceRoot) options1.workspaceConfig.workspaceRoot = process.cwd();
2208
- _chunkVGC3FXLUjs.setSilent.call(void 0, options1.silent);
2209
- const entry = options1.entry || options1.entryPoints;
2242
+ if (!options2.workspaceConfig)
2243
+ options2.workspaceConfig = {};
2244
+ if (!options2.workspaceConfig.workspaceRoot)
2245
+ options2.workspaceConfig.workspaceRoot = process.cwd();
2246
+ _chunkVGC3FXLUjs.setSilent.call(void 0, options2.silent);
2247
+ const entry = options2.entry || options2.entryPoints;
2210
2248
  if (!entry || Object.keys(entry).length === 0) {
2211
2249
  throw new (0, _chunkJZ25TPTYjs.PrettyError)(`No input files, try "tsup <your-file>" instead`);
2212
2250
  }
2213
2251
  if (Array.isArray(entry)) {
2214
- options1.entry = await _tinyglobby.glob.call(void 0, entry);
2215
- if (!options1.entry || options1.entry.length === 0) {
2252
+ options2.entry = await _tinyglobby.glob.call(void 0, entry);
2253
+ if (!options2.entry || options2.entry.length === 0) {
2216
2254
  throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${entry}`);
2217
2255
  } else {
2218
- logger3.info("CLI", `Building entry: ${options1.entry.join(", ")}`);
2256
+ logger3.info("CLI", `Building entry: ${options2.entry.join(", ")}`);
2219
2257
  }
2220
2258
  } else {
2221
2259
  Object.keys(entry).forEach((alias) => {
@@ -2224,300 +2262,263 @@ module.exports = exports.default;
2224
2262
  throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${alias}: ${filename}`);
2225
2263
  }
2226
2264
  });
2227
- options1.entry = entry;
2265
+ options2.entry = entry;
2228
2266
  logger3.info("CLI", `Building entry: ${JSON.stringify(entry)}`);
2229
2267
  }
2230
- const tsconfig = _bundlerequire.loadTsConfig.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd(), options1.tsconfig);
2268
+ const tsconfig = _bundlerequire.loadTsConfig.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd(), options2.tsconfig);
2231
2269
  if (tsconfig) {
2232
- logger3.info("CLI", `Using tsconfig: ${_path2.default.relative(options1.workspaceConfig?.workspaceRoot || process.cwd(), tsconfig.path)}`);
2233
- options1.tsconfig = tsconfig.path;
2234
- options1.tsconfigResolvePaths = _optionalChain([
2235
- tsconfig,
2236
- "access",
2237
- (_22) => _22.data,
2238
- "optionalAccess",
2239
- (_23) => _23.compilerOptions,
2240
- "optionalAccess",
2241
- (_24) => _24.paths
2242
- ]) || {};
2243
- options1.tsconfigDecoratorMetadata = _optionalChain([
2244
- tsconfig,
2245
- "access",
2246
- (_25) => _25.data,
2247
- "optionalAccess",
2248
- (_26) => _26.compilerOptions,
2249
- "optionalAccess",
2250
- (_27) => _27.emitDecoratorMetadata
2251
- ]);
2252
- if (options1.dts) {
2253
- options1.dts.compilerOptions = {
2270
+ logger3.info(
2271
+ "CLI",
2272
+ `Using tsconfig: ${_path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), tsconfig.path)}`
2273
+ );
2274
+ options2.tsconfig = tsconfig.path;
2275
+ options2.tsconfigResolvePaths = _optionalChain([tsconfig, "access", (_22) => _22.data, "optionalAccess", (_23) => _23.compilerOptions, "optionalAccess", (_24) => _24.paths]) || {};
2276
+ options2.tsconfigDecoratorMetadata = _optionalChain([tsconfig, "access", (_25) => _25.data, "optionalAccess", (_26) => _26.compilerOptions, "optionalAccess", (_27) => _27.emitDecoratorMetadata]);
2277
+ if (options2.dts) {
2278
+ options2.dts.compilerOptions = {
2254
2279
  ...tsconfig.data.compilerOptions || {},
2255
- ...options1.dts.compilerOptions || {}
2280
+ ...options2.dts.compilerOptions || {}
2256
2281
  };
2257
2282
  }
2258
- if (options1.experimentalDts) {
2259
- options1.experimentalDts = await _chunkTWFEYLU4js.resolveExperimentalDtsConfig.call(void 0, options1, tsconfig);
2283
+ if (options2.experimentalDts) {
2284
+ options2.experimentalDts = await _chunkTWFEYLU4js.resolveExperimentalDtsConfig.call(
2285
+ void 0,
2286
+ options2,
2287
+ tsconfig
2288
+ );
2260
2289
  }
2261
- if (!options1.target) {
2262
- options1.target = _optionalChain([
2263
- tsconfig,
2264
- "access",
2265
- (_28) => _28.data,
2266
- "optionalAccess",
2267
- (_29) => _29.compilerOptions,
2268
- "optionalAccess",
2269
- (_30) => _30.target,
2270
- "optionalAccess",
2271
- (_31) => _31.toLowerCase,
2272
- "call",
2273
- (_32) => _32()
2274
- ]);
2290
+ if (!options2.target) {
2291
+ options2.target = _optionalChain([tsconfig, "access", (_28) => _28.data, "optionalAccess", (_29) => _29.compilerOptions, "optionalAccess", (_30) => _30.target, "optionalAccess", (_31) => _31.toLowerCase, "call", (_32) => _32()]);
2275
2292
  }
2276
- } else if (options1.tsconfig) {
2277
- throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find tsconfig: ${options1.tsconfig}`);
2293
+ } else if (options2.tsconfig) {
2294
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find tsconfig: ${options2.tsconfig}`);
2278
2295
  }
2279
- if (!options1.target) {
2280
- options1.target = "node16";
2296
+ if (!options2.target) {
2297
+ options2.target = "node16";
2281
2298
  }
2282
- return options1;
2299
+ return options2;
2283
2300
  }, "normalizeOptions");
2284
2301
  async function build(_options) {
2285
- const config = _options.config === false ? {} : await _chunkVGC3FXLUjs.loadTsupConfig.call(void 0, _options.workspaceConfig?.workspaceRoot || process.cwd(), _options.config === true ? void 0 : _options.config);
2302
+ const config = _options.config === false ? {} : await _chunkVGC3FXLUjs.loadTsupConfig.call(
2303
+ void 0,
2304
+ _options.workspaceConfig?.workspaceRoot || process.cwd(),
2305
+ _options.config === true ? void 0 : _options.config
2306
+ );
2286
2307
  const configData = typeof config.data === "function" ? await config.data(_options) : config.data;
2287
- await Promise.all([
2288
- ...Array.isArray(configData) ? configData : [
2289
- configData
2290
- ]
2291
- ].map(async (item) => {
2292
- const logger3 = _chunkVGC3FXLUjs.createLogger.call(void 0, _optionalChain([
2293
- item,
2294
- "optionalAccess",
2295
- (_33) => _33.name
2296
- ]));
2297
- const options1 = await normalizeOptions(logger3, item, _options);
2298
- logger3.info("CLI", `tsup v${_chunkBYH4XDRHjs.version}`);
2299
- if (config.path) {
2300
- logger3.info("CLI", `Using tsup config: ${config.path}`);
2301
- }
2302
- if (options1.watch) {
2303
- logger3.info("CLI", "Running in watch mode");
2304
- }
2305
- const experimentalDtsTask = /* @__PURE__ */ __name(async () => {
2306
- if (!options1.dts && options1.experimentalDts) {
2307
- const exports1 = runTypeScriptCompiler(options1);
2308
- await runDtsRollup(options1, exports1);
2309
- }
2310
- }, "experimentalDtsTask");
2311
- const dtsTask = /* @__PURE__ */ __name(async () => {
2312
- if (options1.dts && options1.experimentalDts) {
2313
- throw new Error("You can't use both `dts` and `experimentalDts` at the same time");
2314
- }
2315
- await experimentalDtsTask();
2316
- if (options1.dts) {
2317
- await new Promise((resolve, reject) => {
2318
- const worker = new (0, _worker_threads.Worker)(_path2.default.join(__dirname, "./rollup.js"));
2319
- const terminateWorker = /* @__PURE__ */ __name(() => {
2320
- if (options1.watch) return;
2321
- worker.terminate();
2322
- }, "terminateWorker");
2323
- worker.postMessage({
2324
- configName: _optionalChain([
2325
- item,
2326
- "optionalAccess",
2327
- (_34) => _34.name
2328
- ]),
2329
- options: {
2330
- ...options1,
2331
- // functions cannot be cloned
2332
- injectStyle: typeof options1.injectStyle === "function" ? void 0 : options1.injectStyle,
2333
- banner: void 0,
2334
- footer: void 0,
2335
- esbuildPlugins: void 0,
2336
- esbuildOptions: void 0,
2337
- plugins: void 0,
2338
- treeshake: void 0,
2339
- onSuccess: void 0,
2340
- outExtension: void 0
2341
- }
2342
- });
2343
- worker.on("message", (data) => {
2344
- if (data === "error") {
2345
- terminateWorker();
2346
- reject(new Error("error occurred in dts build"));
2347
- } else if (data === "success") {
2348
- terminateWorker();
2349
- resolve();
2350
- } else {
2351
- const { type, text } = data;
2352
- if (type === "log") {
2353
- console.log(text);
2354
- } else if (type === "error") {
2355
- console.error(text);
2356
- }
2357
- }
2358
- });
2359
- });
2360
- }
2361
- }, "dtsTask");
2362
- const mainTasks = /* @__PURE__ */ __name(async () => {
2363
- if (!_optionalChain([
2364
- options1,
2365
- "access",
2366
- (_35) => _35.dts,
2367
- "optionalAccess",
2368
- (_36) => _36.only
2369
- ])) {
2370
- let onSuccessProcess;
2371
- let onSuccessCleanup;
2372
- const buildDependencies = /* @__PURE__ */ new Set();
2373
- let depsHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd());
2374
- const doOnSuccessCleanup = /* @__PURE__ */ __name(async () => {
2375
- if (onSuccessProcess) {
2376
- await killProcess({
2377
- pid: onSuccessProcess.pid,
2378
- signal: options1.killSignal || "SIGTERM"
2379
- });
2380
- } else if (onSuccessCleanup) {
2381
- await onSuccessCleanup();
2308
+ await Promise.all(
2309
+ [...Array.isArray(configData) ? configData : [configData]].map(
2310
+ async (item) => {
2311
+ const logger3 = _chunkVGC3FXLUjs.createLogger.call(void 0, _optionalChain([item, "optionalAccess", (_33) => _33.name]));
2312
+ const options2 = await normalizeOptions(logger3, item, _options);
2313
+ logger3.info("CLI", `tsup v${_chunkBYH4XDRHjs.version}`);
2314
+ if (config.path) {
2315
+ logger3.info("CLI", `Using tsup config: ${config.path}`);
2316
+ }
2317
+ if (options2.watch) {
2318
+ logger3.info("CLI", "Running in watch mode");
2319
+ }
2320
+ const experimentalDtsTask = /* @__PURE__ */ __name(async () => {
2321
+ if (!options2.dts && options2.experimentalDts) {
2322
+ const exports2 = runTypeScriptCompiler(options2);
2323
+ await runDtsRollup(options2, exports2);
2382
2324
  }
2383
- onSuccessProcess = void 0;
2384
- onSuccessCleanup = void 0;
2385
- }, "doOnSuccessCleanup");
2386
- const debouncedBuildAll = _chunkTWFEYLU4js.debouncePromise.call(void 0, () => {
2387
- return buildAll();
2388
- }, 100, _chunkJZ25TPTYjs.handleError);
2389
- const buildAll = /* @__PURE__ */ __name(async () => {
2390
- await doOnSuccessCleanup();
2391
- const previousBuildDependencies = new Set(buildDependencies);
2392
- buildDependencies.clear();
2393
- if (options1.clean) {
2394
- const extraPatterns = Array.isArray(options1.clean) ? options1.clean : [];
2395
- if (options1.dts || options1.experimentalDts) {
2396
- extraPatterns.unshift("!**/*.d.{ts,cts,mts}");
2397
- }
2398
- await _chunkTWFEYLU4js.removeFiles.call(void 0, [
2399
- "**/*",
2400
- ...extraPatterns
2401
- ], options1.outDir);
2402
- logger3.info("CLI", "Cleaning output folder");
2325
+ }, "experimentalDtsTask");
2326
+ const dtsTask = /* @__PURE__ */ __name(async () => {
2327
+ if (options2.dts && options2.experimentalDts) {
2328
+ throw new Error(
2329
+ "You can't use both `dts` and `experimentalDts` at the same time"
2330
+ );
2403
2331
  }
2404
- const css = /* @__PURE__ */ new Map();
2405
- await Promise.all([
2406
- ...options1.format.map(async (format, index) => {
2407
- const pluginContainer = new PluginContainer([
2408
- shebang(),
2409
- ...options1.plugins || [],
2410
- treeShakingPlugin({
2411
- treeshake: options1.treeshake,
2412
- name: options1.globalName,
2413
- silent: options1.silent
2414
- }),
2415
- cjsSplitting(),
2416
- cjsInterop(),
2417
- swcTarget(),
2418
- sizeReporter(),
2419
- terserPlugin({
2420
- minifyOptions: options1.minify,
2421
- format,
2422
- terserOptions: options1.terserOptions,
2423
- globalName: options1.globalName,
2424
- logger: logger3
2425
- })
2426
- ]);
2427
- await runEsbuild(options1, {
2428
- pluginContainer,
2429
- format,
2430
- css: index === 0 || options1.injectStyle ? css : void 0,
2431
- logger: logger3,
2432
- buildDependencies
2433
- }).catch((error) => {
2434
- previousBuildDependencies.forEach((v) => buildDependencies.add(v));
2435
- throw error;
2436
- });
2437
- })
2438
- ]);
2439
- if (options1.onSuccess) {
2440
- if (typeof options1.onSuccess === "function") {
2441
- onSuccessCleanup = await options1.onSuccess();
2442
- } else {
2443
- onSuccessProcess = _tinyexec.exec.call(void 0, options1.onSuccess, [], {
2444
- nodeOptions: {
2445
- shell: true,
2446
- stdio: "inherit"
2332
+ await experimentalDtsTask();
2333
+ if (options2.dts) {
2334
+ await new Promise((resolve, reject) => {
2335
+ const worker = new (0, _worker_threads.Worker)(_path2.default.join(__dirname, "./rollup.js"));
2336
+ const terminateWorker = /* @__PURE__ */ __name(() => {
2337
+ if (options2.watch) return;
2338
+ worker.terminate();
2339
+ }, "terminateWorker");
2340
+ worker.postMessage({
2341
+ configName: _optionalChain([item, "optionalAccess", (_34) => _34.name]),
2342
+ options: {
2343
+ ...options2,
2344
+ // functions cannot be cloned
2345
+ injectStyle: typeof options2.injectStyle === "function" ? void 0 : options2.injectStyle,
2346
+ banner: void 0,
2347
+ footer: void 0,
2348
+ esbuildPlugins: void 0,
2349
+ esbuildOptions: void 0,
2350
+ plugins: void 0,
2351
+ treeshake: void 0,
2352
+ onSuccess: void 0,
2353
+ outExtension: void 0
2447
2354
  }
2448
2355
  });
2449
- _optionalChain([
2450
- onSuccessProcess,
2451
- "access",
2452
- (_37) => _37.process,
2453
- "optionalAccess",
2454
- (_38) => _38.on,
2455
- "call",
2456
- (_39) => _39("exit", (code) => {
2457
- if (code && code !== 0) {
2458
- process.exitCode = code;
2356
+ worker.on("message", (data) => {
2357
+ if (data === "error") {
2358
+ terminateWorker();
2359
+ reject(new Error("error occurred in dts build"));
2360
+ } else if (data === "success") {
2361
+ terminateWorker();
2362
+ resolve();
2363
+ } else {
2364
+ const { type, text } = data;
2365
+ if (type === "log") {
2366
+ console.log(text);
2367
+ } else if (type === "error") {
2368
+ console.error(text);
2459
2369
  }
2370
+ }
2371
+ });
2372
+ });
2373
+ }
2374
+ }, "dtsTask");
2375
+ const mainTasks = /* @__PURE__ */ __name(async () => {
2376
+ if (!_optionalChain([options2, "access", (_35) => _35.dts, "optionalAccess", (_36) => _36.only])) {
2377
+ let onSuccessProcess;
2378
+ let onSuccessCleanup;
2379
+ const buildDependencies = /* @__PURE__ */ new Set();
2380
+ let depsHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2381
+ const doOnSuccessCleanup = /* @__PURE__ */ __name(async () => {
2382
+ if (onSuccessProcess) {
2383
+ await killProcess({
2384
+ pid: onSuccessProcess.pid,
2385
+ signal: options2.killSignal || "SIGTERM"
2386
+ });
2387
+ } else if (onSuccessCleanup) {
2388
+ await onSuccessCleanup();
2389
+ }
2390
+ onSuccessProcess = void 0;
2391
+ onSuccessCleanup = void 0;
2392
+ }, "doOnSuccessCleanup");
2393
+ const debouncedBuildAll = _chunkTWFEYLU4js.debouncePromise.call(
2394
+ void 0,
2395
+ () => {
2396
+ return buildAll();
2397
+ },
2398
+ 100,
2399
+ _chunkJZ25TPTYjs.handleError
2400
+ );
2401
+ const buildAll = /* @__PURE__ */ __name(async () => {
2402
+ await doOnSuccessCleanup();
2403
+ const previousBuildDependencies = new Set(buildDependencies);
2404
+ buildDependencies.clear();
2405
+ if (options2.clean) {
2406
+ const extraPatterns = Array.isArray(options2.clean) ? options2.clean : [];
2407
+ if (options2.dts || options2.experimentalDts) {
2408
+ extraPatterns.unshift("!**/*.d.{ts,cts,mts}");
2409
+ }
2410
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, ["**/*", ...extraPatterns], options2.outDir);
2411
+ logger3.info("CLI", "Cleaning output folder");
2412
+ }
2413
+ const css = /* @__PURE__ */ new Map();
2414
+ await Promise.all([
2415
+ ...options2.format.map(async (format, index) => {
2416
+ const pluginContainer = new PluginContainer([
2417
+ shebang(),
2418
+ ...options2.plugins || [],
2419
+ treeShakingPlugin({
2420
+ treeshake: options2.treeshake,
2421
+ name: options2.globalName,
2422
+ silent: options2.silent
2423
+ }),
2424
+ cjsSplitting(),
2425
+ cjsInterop(),
2426
+ swcTarget(),
2427
+ sizeReporter(),
2428
+ terserPlugin({
2429
+ minifyOptions: options2.minify,
2430
+ format,
2431
+ terserOptions: options2.terserOptions,
2432
+ globalName: options2.globalName,
2433
+ logger: logger3
2434
+ })
2435
+ ]);
2436
+ await runEsbuild(options2, {
2437
+ pluginContainer,
2438
+ format,
2439
+ css: index === 0 || options2.injectStyle ? css : void 0,
2440
+ logger: logger3,
2441
+ buildDependencies
2442
+ }).catch((error) => {
2443
+ previousBuildDependencies.forEach(
2444
+ (v) => buildDependencies.add(v)
2445
+ );
2446
+ throw error;
2447
+ });
2460
2448
  })
2461
2449
  ]);
2462
- }
2463
- }
2464
- }, "buildAll");
2465
- const startWatcher = /* @__PURE__ */ __name(async () => {
2466
- if (!options1.watch) return;
2467
- const { watch } = await Promise.resolve().then(() => _interopRequireWildcard(__require("chokidar")));
2468
- const customIgnores = options1.ignoreWatch ? Array.isArray(options1.ignoreWatch) ? options1.ignoreWatch : [
2469
- options1.ignoreWatch
2470
- ] : [];
2471
- const ignored = [
2472
- "**/{.git,node_modules}/**",
2473
- options1.outDir,
2474
- ...customIgnores
2475
- ];
2476
- const watchPaths = typeof options1.watch === "boolean" ? "." : Array.isArray(options1.watch) ? options1.watch.filter((path12) => typeof path12 === "string") : options1.watch;
2477
- logger3.info("CLI", `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => `"${v}"`).join(" | ") : `"${watchPaths}"`}`);
2478
- logger3.info("CLI", `Ignoring changes in ${ignored.map((v) => `"${v}"`).join(" | ")}`);
2479
- const watcher = watch(await _tinyglobby.glob.call(void 0, watchPaths), {
2480
- ignoreInitial: true,
2481
- ignorePermissionErrors: true,
2482
- ignored: /* @__PURE__ */ __name((p) => _tinyglobby.globSync.call(void 0, p, {
2483
- ignore: ignored
2484
- }).length === 0, "ignored")
2485
- });
2486
- watcher.on("all", async (type, file) => {
2487
- file = _chunkTWFEYLU4js.slash.call(void 0, file);
2488
- if (options1.publicDir && isInPublicDir(options1.publicDir, file)) {
2489
- logger3.info("CLI", `Change in public dir: ${file}`);
2490
- copyPublicDir(options1.publicDir, options1.outDir);
2491
- return;
2492
- }
2493
- let shouldSkipChange = false;
2494
- if (options1.watch === true) {
2495
- if (file === "package.json" && !buildDependencies.has(file)) {
2496
- const currentHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options1.workspaceConfig?.workspaceRoot || process.cwd());
2497
- shouldSkipChange = currentHash === depsHash;
2498
- depsHash = currentHash;
2499
- } else if (!buildDependencies.has(file)) {
2500
- shouldSkipChange = true;
2450
+ if (options2.onSuccess) {
2451
+ if (typeof options2.onSuccess === "function") {
2452
+ onSuccessCleanup = await options2.onSuccess();
2453
+ } else {
2454
+ onSuccessProcess = _tinyexec.exec.call(void 0, options2.onSuccess, [], {
2455
+ nodeOptions: { shell: true, stdio: "inherit" }
2456
+ });
2457
+ _optionalChain([onSuccessProcess, "access", (_37) => _37.process, "optionalAccess", (_38) => _38.on, "call", (_39) => _39("exit", (code) => {
2458
+ if (code && code !== 0) {
2459
+ process.exitCode = code;
2460
+ }
2461
+ })]);
2462
+ }
2501
2463
  }
2502
- }
2503
- if (shouldSkipChange) {
2504
- return;
2505
- }
2506
- logger3.info("CLI", `Change detected: ${type} ${file}`);
2507
- debouncedBuildAll();
2508
- });
2509
- }, "startWatcher");
2510
- logger3.info("CLI", `Target: ${options1.target}`);
2511
- await buildAll();
2512
- copyPublicDir(options1.publicDir, options1.outDir);
2513
- startWatcher();
2464
+ }, "buildAll");
2465
+ const startWatcher = /* @__PURE__ */ __name(async () => {
2466
+ if (!options2.watch) return;
2467
+ const { watch } = await Promise.resolve().then(() => _interopRequireWildcard(__import_chokidar));
2468
+ const customIgnores = options2.ignoreWatch ? Array.isArray(options2.ignoreWatch) ? options2.ignoreWatch : [options2.ignoreWatch] : [];
2469
+ const ignored = [
2470
+ "**/{.git,node_modules}/**",
2471
+ options2.outDir,
2472
+ ...customIgnores
2473
+ ];
2474
+ const watchPaths = typeof options2.watch === "boolean" ? "." : Array.isArray(options2.watch) ? options2.watch.filter((path12) => typeof path12 === "string") : options2.watch;
2475
+ logger3.info(
2476
+ "CLI",
2477
+ `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => `"${v}"`).join(" | ") : `"${watchPaths}"`}`
2478
+ );
2479
+ logger3.info(
2480
+ "CLI",
2481
+ `Ignoring changes in ${ignored.map((v) => `"${v}"`).join(" | ")}`
2482
+ );
2483
+ const watcher = watch(await _tinyglobby.glob.call(void 0, watchPaths), {
2484
+ ignoreInitial: true,
2485
+ ignorePermissionErrors: true,
2486
+ ignored: /* @__PURE__ */ __name((p) => _tinyglobby.globSync.call(void 0, p, { ignore: ignored }).length === 0, "ignored")
2487
+ });
2488
+ watcher.on("all", async (type, file) => {
2489
+ file = _chunkTWFEYLU4js.slash.call(void 0, file);
2490
+ if (options2.publicDir && isInPublicDir(options2.publicDir, file)) {
2491
+ logger3.info("CLI", `Change in public dir: ${file}`);
2492
+ copyPublicDir(options2.publicDir, options2.outDir);
2493
+ return;
2494
+ }
2495
+ let shouldSkipChange = false;
2496
+ if (options2.watch === true) {
2497
+ if (file === "package.json" && !buildDependencies.has(file)) {
2498
+ const currentHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2499
+ shouldSkipChange = currentHash === depsHash;
2500
+ depsHash = currentHash;
2501
+ } else if (!buildDependencies.has(file)) {
2502
+ shouldSkipChange = true;
2503
+ }
2504
+ }
2505
+ if (shouldSkipChange) {
2506
+ return;
2507
+ }
2508
+ logger3.info("CLI", `Change detected: ${type} ${file}`);
2509
+ debouncedBuildAll();
2510
+ });
2511
+ }, "startWatcher");
2512
+ logger3.info("CLI", `Target: ${options2.target}`);
2513
+ await buildAll();
2514
+ copyPublicDir(options2.publicDir, options2.outDir);
2515
+ startWatcher();
2516
+ }
2517
+ }, "mainTasks");
2518
+ await Promise.all([dtsTask(), mainTasks()]);
2514
2519
  }
2515
- }, "mainTasks");
2516
- await Promise.all([
2517
- dtsTask(),
2518
- mainTasks()
2519
- ]);
2520
- }));
2520
+ )
2521
+ );
2521
2522
  }
2522
2523
  __name(build, "build");
2523
2524
  exports.build = build;
@@ -2526,6 +2527,7 @@ module.exports = exports.default;
2526
2527
  });
2527
2528
 
2528
2529
  // src/tsup.ts
2530
+ init_esm_shims();
2529
2531
  var import_tsup = __toESM(require_dist(), 1);
2530
2532
  async function executeTsup(context) {
2531
2533
  writeDebug(` \u{1F680} Running ${context.options.name} build`, context.workspaceConfig);