@storm-software/esbuild 0.52.20 → 0.53.1

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