@tochii/build 2.2.2 → 2.2.4
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.
- package/dist/cli.mjs +1 -1
- package/dist/tsup@8.4.0-minified/chunk-BMINWOCT.js +5 -0
- package/dist/tsup@8.4.0-minified/chunk-SP4XNZBT.js +40 -0
- package/dist/{tsup@8.4.0/cli-node.js → tsup@8.4.0-minified/cli-node.d.ts} +0 -2
- package/dist/tsup@8.4.0-minified/cli-node.js +2 -0
- package/dist/{tsup@8.4.0 → tsup@8.4.0-minified}/index.d.ts +2 -2
- package/dist/tsup@8.4.0-minified/index.js +1 -0
- package/dist/{tsup@8.4.0/rollup.js → tsup@8.4.0-minified/rollup.d.ts} +5 -35
- package/dist/tsup@8.4.0-minified/rollup.js +46 -0
- package/package.json +16 -2
- package/dist/tsup@8.4.0/chunk-BYH4XDRH.js +0 -6
- package/dist/tsup@8.4.0/chunk-GZSSIGNC.js +0 -153
- package/dist/tsup@8.4.0/chunk-JZ25TPTY.js +0 -42
- package/dist/tsup@8.4.0/chunk-TWFEYLU4.js +0 -352
- package/dist/tsup@8.4.0/chunk-VGC3FXLU.js +0 -203
- package/dist/tsup@8.4.0/cli-default.js +0 -12
- package/dist/tsup@8.4.0/cli-main.js +0 -8
- package/dist/tsup@8.4.0/index.js +0 -1707
@@ -1,42 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/errors.ts
|
2
|
-
var _worker_threads = require('worker_threads');
|
3
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
4
|
-
var PrettyError = class extends Error {
|
5
|
-
constructor(message) {
|
6
|
-
super(message);
|
7
|
-
this.name = this.constructor.name;
|
8
|
-
if (typeof Error.captureStackTrace === "function") {
|
9
|
-
Error.captureStackTrace(this, this.constructor);
|
10
|
-
} else {
|
11
|
-
this.stack = new Error(message).stack;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
};
|
15
|
-
function handleError(error) {
|
16
|
-
if (error.loc) {
|
17
|
-
console.error(
|
18
|
-
_picocolors2.default.bold(
|
19
|
-
_picocolors2.default.red(
|
20
|
-
`Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`
|
21
|
-
)
|
22
|
-
)
|
23
|
-
);
|
24
|
-
}
|
25
|
-
if (error.frame) {
|
26
|
-
console.error(_picocolors2.default.red(error.message));
|
27
|
-
console.error(_picocolors2.default.dim(error.frame));
|
28
|
-
} else if (error instanceof PrettyError) {
|
29
|
-
console.error(_picocolors2.default.red(error.message));
|
30
|
-
} else {
|
31
|
-
console.error(_picocolors2.default.red(error.stack));
|
32
|
-
}
|
33
|
-
process.exitCode = 1;
|
34
|
-
if (!_worker_threads.isMainThread && _worker_threads.parentPort) {
|
35
|
-
_worker_threads.parentPort.postMessage("error");
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
exports.PrettyError = PrettyError; exports.handleError = handleError;
|
@@ -1,352 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
9
|
-
}) : x)(function(x) {
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
12
|
-
});
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
15
|
-
};
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
18
|
-
for (let key of __getOwnPropNames(from))
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
21
|
-
}
|
22
|
-
return to;
|
23
|
-
};
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
30
|
-
mod
|
31
|
-
));
|
32
|
-
|
33
|
-
// src/utils.ts
|
34
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
35
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
36
|
-
var _resolvefrom = require('resolve-from'); var _resolvefrom2 = _interopRequireDefault(_resolvefrom);
|
37
|
-
|
38
|
-
// node_modules/.pnpm/strip-json-comments@5.0.1/node_modules/strip-json-comments/index.js
|
39
|
-
var singleComment = Symbol("singleComment");
|
40
|
-
var multiComment = Symbol("multiComment");
|
41
|
-
var stripWithoutWhitespace = () => "";
|
42
|
-
var stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/\S/g, " ");
|
43
|
-
var isEscaped = (jsonString, quotePosition) => {
|
44
|
-
let index = quotePosition - 1;
|
45
|
-
let backslashCount = 0;
|
46
|
-
while (jsonString[index] === "\\") {
|
47
|
-
index -= 1;
|
48
|
-
backslashCount += 1;
|
49
|
-
}
|
50
|
-
return Boolean(backslashCount % 2);
|
51
|
-
};
|
52
|
-
function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
|
53
|
-
if (typeof jsonString !== "string") {
|
54
|
-
throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
|
55
|
-
}
|
56
|
-
const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
|
57
|
-
let isInsideString = false;
|
58
|
-
let isInsideComment = false;
|
59
|
-
let offset = 0;
|
60
|
-
let buffer = "";
|
61
|
-
let result = "";
|
62
|
-
let commaIndex = -1;
|
63
|
-
for (let index = 0; index < jsonString.length; index++) {
|
64
|
-
const currentCharacter = jsonString[index];
|
65
|
-
const nextCharacter = jsonString[index + 1];
|
66
|
-
if (!isInsideComment && currentCharacter === '"') {
|
67
|
-
const escaped = isEscaped(jsonString, index);
|
68
|
-
if (!escaped) {
|
69
|
-
isInsideString = !isInsideString;
|
70
|
-
}
|
71
|
-
}
|
72
|
-
if (isInsideString) {
|
73
|
-
continue;
|
74
|
-
}
|
75
|
-
if (!isInsideComment && currentCharacter + nextCharacter === "//") {
|
76
|
-
buffer += jsonString.slice(offset, index);
|
77
|
-
offset = index;
|
78
|
-
isInsideComment = singleComment;
|
79
|
-
index++;
|
80
|
-
} else if (isInsideComment === singleComment && currentCharacter + nextCharacter === "\r\n") {
|
81
|
-
index++;
|
82
|
-
isInsideComment = false;
|
83
|
-
buffer += strip(jsonString, offset, index);
|
84
|
-
offset = index;
|
85
|
-
continue;
|
86
|
-
} else if (isInsideComment === singleComment && currentCharacter === "\n") {
|
87
|
-
isInsideComment = false;
|
88
|
-
buffer += strip(jsonString, offset, index);
|
89
|
-
offset = index;
|
90
|
-
} else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
|
91
|
-
buffer += jsonString.slice(offset, index);
|
92
|
-
offset = index;
|
93
|
-
isInsideComment = multiComment;
|
94
|
-
index++;
|
95
|
-
continue;
|
96
|
-
} else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
|
97
|
-
index++;
|
98
|
-
isInsideComment = false;
|
99
|
-
buffer += strip(jsonString, offset, index + 1);
|
100
|
-
offset = index + 1;
|
101
|
-
continue;
|
102
|
-
} else if (trailingCommas && !isInsideComment) {
|
103
|
-
if (commaIndex !== -1) {
|
104
|
-
if (currentCharacter === "}" || currentCharacter === "]") {
|
105
|
-
buffer += jsonString.slice(offset, index);
|
106
|
-
result += strip(buffer, 0, 1) + buffer.slice(1);
|
107
|
-
buffer = "";
|
108
|
-
offset = index;
|
109
|
-
commaIndex = -1;
|
110
|
-
} else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
|
111
|
-
buffer += jsonString.slice(offset, index);
|
112
|
-
offset = index;
|
113
|
-
commaIndex = -1;
|
114
|
-
}
|
115
|
-
} else if (currentCharacter === ",") {
|
116
|
-
result += buffer + jsonString.slice(offset, index);
|
117
|
-
buffer = "";
|
118
|
-
offset = index;
|
119
|
-
commaIndex = index;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
return result + buffer + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
124
|
-
}
|
125
|
-
|
126
|
-
// src/utils.ts
|
127
|
-
var _tinyglobby = require('tinyglobby');
|
128
|
-
function getPostcss() {
|
129
|
-
return localRequire("postcss");
|
130
|
-
}
|
131
|
-
function getApiExtractor() {
|
132
|
-
return localRequire("@microsoft/api-extractor");
|
133
|
-
}
|
134
|
-
function localRequire(moduleName) {
|
135
|
-
const p = _resolvefrom2.default.silent(process.cwd(), moduleName);
|
136
|
-
return p && __require(p);
|
137
|
-
}
|
138
|
-
async function removeFiles(patterns, dir) {
|
139
|
-
const files = await _tinyglobby.glob.call(void 0, patterns, {
|
140
|
-
cwd: dir,
|
141
|
-
absolute: true
|
142
|
-
});
|
143
|
-
files.forEach((file) => _fs2.default.existsSync(file) && _fs2.default.unlinkSync(file));
|
144
|
-
}
|
145
|
-
function debouncePromise(fn, delay, onError) {
|
146
|
-
let timeout;
|
147
|
-
let promiseInFly;
|
148
|
-
let callbackPending;
|
149
|
-
return function debounced(...args) {
|
150
|
-
if (promiseInFly) {
|
151
|
-
callbackPending = () => {
|
152
|
-
debounced(...args);
|
153
|
-
callbackPending = void 0;
|
154
|
-
};
|
155
|
-
} else {
|
156
|
-
if (timeout != null) clearTimeout(timeout);
|
157
|
-
timeout = setTimeout(() => {
|
158
|
-
timeout = void 0;
|
159
|
-
promiseInFly = fn(...args).catch(onError).finally(() => {
|
160
|
-
promiseInFly = void 0;
|
161
|
-
if (callbackPending) callbackPending();
|
162
|
-
});
|
163
|
-
}, delay);
|
164
|
-
}
|
165
|
-
};
|
166
|
-
}
|
167
|
-
function slash(path2) {
|
168
|
-
const isExtendedLengthPath = path2.startsWith("\\\\?\\");
|
169
|
-
if (isExtendedLengthPath) {
|
170
|
-
return path2;
|
171
|
-
}
|
172
|
-
return path2.replace(/\\/g, "/");
|
173
|
-
}
|
174
|
-
function truthy(value) {
|
175
|
-
return Boolean(value);
|
176
|
-
}
|
177
|
-
function jsoncParse(data) {
|
178
|
-
try {
|
179
|
-
return new Function(`return ${stripJsonComments(data).trim()}`)();
|
180
|
-
} catch (e2) {
|
181
|
-
return {};
|
182
|
-
}
|
183
|
-
}
|
184
|
-
function defaultOutExtension({
|
185
|
-
format,
|
186
|
-
pkgType
|
187
|
-
}) {
|
188
|
-
let jsExtension = ".js";
|
189
|
-
let dtsExtension = ".d.ts";
|
190
|
-
const isModule = pkgType === "module";
|
191
|
-
if (isModule && format === "cjs") {
|
192
|
-
jsExtension = ".cjs";
|
193
|
-
dtsExtension = ".d.cts";
|
194
|
-
}
|
195
|
-
if (!isModule && format === "esm") {
|
196
|
-
jsExtension = ".mjs";
|
197
|
-
dtsExtension = ".d.mts";
|
198
|
-
}
|
199
|
-
if (format === "iife") {
|
200
|
-
jsExtension = ".global.js";
|
201
|
-
}
|
202
|
-
return {
|
203
|
-
js: jsExtension,
|
204
|
-
dts: dtsExtension
|
205
|
-
};
|
206
|
-
}
|
207
|
-
function ensureTempDeclarationDir() {
|
208
|
-
const cwd = process.cwd();
|
209
|
-
const dirPath = _path2.default.join(cwd, ".tsup", "declaration");
|
210
|
-
if (_fs2.default.existsSync(dirPath)) {
|
211
|
-
return dirPath;
|
212
|
-
}
|
213
|
-
_fs2.default.mkdirSync(dirPath, { recursive: true });
|
214
|
-
const gitIgnorePath = _path2.default.join(cwd, ".tsup", ".gitignore");
|
215
|
-
writeFileSync(gitIgnorePath, "**/*\n");
|
216
|
-
return dirPath;
|
217
|
-
}
|
218
|
-
var toObjectEntry = (entry) => {
|
219
|
-
if (typeof entry === "string") {
|
220
|
-
entry = [entry];
|
221
|
-
}
|
222
|
-
if (!Array.isArray(entry)) {
|
223
|
-
return entry;
|
224
|
-
}
|
225
|
-
entry = entry.map((e) => e.replace(/\\/g, "/"));
|
226
|
-
const ancestor = findLowestCommonAncestor(entry);
|
227
|
-
return entry.reduce(
|
228
|
-
(result, item) => {
|
229
|
-
const key = item.replace(ancestor, "").replace(/^\//, "").replace(/\.[a-z]+$/, "");
|
230
|
-
return {
|
231
|
-
...result,
|
232
|
-
[key]: item
|
233
|
-
};
|
234
|
-
},
|
235
|
-
{}
|
236
|
-
);
|
237
|
-
};
|
238
|
-
var findLowestCommonAncestor = (filepaths) => {
|
239
|
-
if (filepaths.length <= 1) return "";
|
240
|
-
const [first, ...rest] = filepaths;
|
241
|
-
let ancestor = first.split("/");
|
242
|
-
for (const filepath of rest) {
|
243
|
-
const directories = filepath.split("/", ancestor.length);
|
244
|
-
let index = 0;
|
245
|
-
for (const directory of directories) {
|
246
|
-
if (directory === ancestor[index]) {
|
247
|
-
index += 1;
|
248
|
-
} else {
|
249
|
-
ancestor = ancestor.slice(0, index);
|
250
|
-
break;
|
251
|
-
}
|
252
|
-
}
|
253
|
-
ancestor = ancestor.slice(0, index);
|
254
|
-
}
|
255
|
-
return ancestor.length <= 1 && ancestor[0] === "" ? `/${ancestor[0]}` : ancestor.join("/");
|
256
|
-
};
|
257
|
-
function toAbsolutePath(p, cwd) {
|
258
|
-
if (_path2.default.isAbsolute(p)) {
|
259
|
-
return p;
|
260
|
-
}
|
261
|
-
return slash(_path2.default.normalize(_path2.default.join(cwd || process.cwd(), p)));
|
262
|
-
}
|
263
|
-
function writeFileSync(filePath, content) {
|
264
|
-
_fs2.default.mkdirSync(_path2.default.dirname(filePath), { recursive: true });
|
265
|
-
_fs2.default.writeFileSync(filePath, content);
|
266
|
-
}
|
267
|
-
function replaceDtsWithJsExtensions(dtsFilePath) {
|
268
|
-
return dtsFilePath.replace(
|
269
|
-
/\.d\.(ts|mts|cts)$/,
|
270
|
-
(_, fileExtension) => {
|
271
|
-
switch (fileExtension) {
|
272
|
-
case "ts":
|
273
|
-
return ".js";
|
274
|
-
case "mts":
|
275
|
-
return ".mjs";
|
276
|
-
case "cts":
|
277
|
-
return ".cjs";
|
278
|
-
default:
|
279
|
-
return "";
|
280
|
-
}
|
281
|
-
}
|
282
|
-
);
|
283
|
-
}
|
284
|
-
var convertArrayEntriesToObjectEntries = (arrayOfEntries) => {
|
285
|
-
const objectEntries = Object.fromEntries(
|
286
|
-
arrayOfEntries.map(
|
287
|
-
(entry) => [
|
288
|
-
_path2.default.posix.join(
|
289
|
-
...entry.split(_path2.default.posix.sep).slice(1, -1).concat(_path2.default.parse(entry).name)
|
290
|
-
),
|
291
|
-
entry
|
292
|
-
]
|
293
|
-
)
|
294
|
-
);
|
295
|
-
return objectEntries;
|
296
|
-
};
|
297
|
-
var resolveEntryPaths = async (entryPaths) => {
|
298
|
-
const resolvedEntryPaths = typeof entryPaths === "string" || Array.isArray(entryPaths) ? convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, entryPaths)) : entryPaths;
|
299
|
-
return resolvedEntryPaths;
|
300
|
-
};
|
301
|
-
var resolveExperimentalDtsConfig = async (options, tsconfig) => {
|
302
|
-
const resolvedEntryPaths = await resolveEntryPaths(
|
303
|
-
_optionalChain([options, 'access', _2 => _2.experimentalDts, 'optionalAccess', _3 => _3.entry]) || options.entry
|
304
|
-
);
|
305
|
-
const experimentalDtsObjectEntry = Object.keys(resolvedEntryPaths).length === 0 ? Array.isArray(options.entry) ? convertArrayEntriesToObjectEntries(options.entry) : options.entry : resolvedEntryPaths;
|
306
|
-
const normalizedExperimentalDtsConfig = {
|
307
|
-
compilerOptions: {
|
308
|
-
...tsconfig.data.compilerOptions || {},
|
309
|
-
..._optionalChain([options, 'access', _4 => _4.experimentalDts, 'optionalAccess', _5 => _5.compilerOptions]) || {}
|
310
|
-
},
|
311
|
-
entry: experimentalDtsObjectEntry
|
312
|
-
};
|
313
|
-
return normalizedExperimentalDtsConfig;
|
314
|
-
};
|
315
|
-
var resolveInitialExperimentalDtsConfig = async (experimentalDts) => {
|
316
|
-
if (experimentalDts == null) {
|
317
|
-
return;
|
318
|
-
}
|
319
|
-
if (typeof experimentalDts === "boolean")
|
320
|
-
return experimentalDts ? { entry: {} } : void 0;
|
321
|
-
if (typeof experimentalDts === "string") {
|
322
|
-
return {
|
323
|
-
entry: convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, experimentalDts))
|
324
|
-
};
|
325
|
-
}
|
326
|
-
return {
|
327
|
-
...experimentalDts,
|
328
|
-
entry: _optionalChain([experimentalDts, 'optionalAccess', _6 => _6.entry]) == null ? {} : await resolveEntryPaths(experimentalDts.entry)
|
329
|
-
};
|
330
|
-
};
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
exports.__require = __require; exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.getPostcss = getPostcss; exports.getApiExtractor = getApiExtractor; exports.localRequire = localRequire; exports.removeFiles = removeFiles; exports.debouncePromise = debouncePromise; exports.slash = slash; exports.truthy = truthy; exports.jsoncParse = jsoncParse; exports.defaultOutExtension = defaultOutExtension; exports.ensureTempDeclarationDir = ensureTempDeclarationDir; exports.toObjectEntry = toObjectEntry; exports.toAbsolutePath = toAbsolutePath; exports.writeFileSync = writeFileSync; exports.replaceDtsWithJsExtensions = replaceDtsWithJsExtensions; exports.resolveExperimentalDtsConfig = resolveExperimentalDtsConfig; exports.resolveInitialExperimentalDtsConfig = resolveInitialExperimentalDtsConfig;
|
@@ -1,203 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
2
|
-
|
3
|
-
var _chunkTWFEYLU4js = require('./chunk-TWFEYLU4.js');
|
4
|
-
|
5
|
-
// src/load.ts
|
6
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
7
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
8
|
-
var _joycon = require('joycon'); var _joycon2 = _interopRequireDefault(_joycon);
|
9
|
-
var _bundlerequire = require('bundle-require');
|
10
|
-
var joycon = new (0, _joycon2.default)();
|
11
|
-
var loadJson = async (filepath) => {
|
12
|
-
try {
|
13
|
-
return _chunkTWFEYLU4js.jsoncParse.call(void 0, await _fs2.default.promises.readFile(filepath, "utf8"));
|
14
|
-
} catch (error) {
|
15
|
-
if (error instanceof Error) {
|
16
|
-
throw new Error(
|
17
|
-
`Failed to parse ${_path2.default.relative(process.cwd(), filepath)}: ${error.message}`
|
18
|
-
);
|
19
|
-
} else {
|
20
|
-
throw error;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
};
|
24
|
-
var jsonLoader = {
|
25
|
-
test: /\.json$/,
|
26
|
-
load(filepath) {
|
27
|
-
return loadJson(filepath);
|
28
|
-
}
|
29
|
-
};
|
30
|
-
joycon.addLoader(jsonLoader);
|
31
|
-
async function loadTsupConfig(cwd, configFile) {
|
32
|
-
const configJoycon = new (0, _joycon2.default)();
|
33
|
-
const configPath = await configJoycon.resolve({
|
34
|
-
files: configFile ? [configFile] : [
|
35
|
-
"tsup.config.ts",
|
36
|
-
"tsup.config.cts",
|
37
|
-
"tsup.config.mts",
|
38
|
-
"tsup.config.js",
|
39
|
-
"tsup.config.cjs",
|
40
|
-
"tsup.config.mjs",
|
41
|
-
"tsup.config.json",
|
42
|
-
"package.json"
|
43
|
-
],
|
44
|
-
cwd,
|
45
|
-
stopDir: _path2.default.parse(cwd).root,
|
46
|
-
packageKey: "tsup"
|
47
|
-
});
|
48
|
-
if (configPath) {
|
49
|
-
if (configPath.endsWith(".json")) {
|
50
|
-
let data = await loadJson(configPath);
|
51
|
-
if (configPath.endsWith("package.json")) {
|
52
|
-
data = data.tsup;
|
53
|
-
}
|
54
|
-
if (data) {
|
55
|
-
return { path: configPath, data };
|
56
|
-
}
|
57
|
-
return {};
|
58
|
-
}
|
59
|
-
const config = await _bundlerequire.bundleRequire.call(void 0, {
|
60
|
-
filepath: configPath
|
61
|
-
});
|
62
|
-
return {
|
63
|
-
path: configPath,
|
64
|
-
data: config.mod.tsup || config.mod.default || config.mod
|
65
|
-
};
|
66
|
-
}
|
67
|
-
return {};
|
68
|
-
}
|
69
|
-
async function loadPkg(cwd, clearCache = false) {
|
70
|
-
if (clearCache) {
|
71
|
-
joycon.clearCache();
|
72
|
-
}
|
73
|
-
const { data } = await joycon.load(["package.json"], cwd, _path2.default.dirname(cwd));
|
74
|
-
return data || {};
|
75
|
-
}
|
76
|
-
async function getProductionDeps(cwd, clearCache = false) {
|
77
|
-
const data = await loadPkg(cwd, clearCache);
|
78
|
-
const deps = Array.from(
|
79
|
-
/* @__PURE__ */ new Set([
|
80
|
-
...Object.keys(data.dependencies || {}),
|
81
|
-
...Object.keys(data.peerDependencies || {})
|
82
|
-
])
|
83
|
-
);
|
84
|
-
return deps;
|
85
|
-
}
|
86
|
-
async function getAllDepsHash(cwd) {
|
87
|
-
const data = await loadPkg(cwd, true);
|
88
|
-
return JSON.stringify({
|
89
|
-
...data.dependencies,
|
90
|
-
...data.peerDependencies,
|
91
|
-
...data.devDependencies
|
92
|
-
});
|
93
|
-
}
|
94
|
-
|
95
|
-
// src/log.ts
|
96
|
-
var _util = require('util'); var _util2 = _interopRequireDefault(_util);
|
97
|
-
var _worker_threads = require('worker_threads');
|
98
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
99
|
-
var colorize = (type, data, onlyImportant = false) => {
|
100
|
-
if (onlyImportant && (type === "info" || type === "success")) return data;
|
101
|
-
const color = type === "info" ? "blue" : type === "error" ? "red" : type === "warn" ? "yellow" : "green";
|
102
|
-
return _picocolors2.default[color](data);
|
103
|
-
};
|
104
|
-
var makeLabel = (name, input, type) => {
|
105
|
-
return [
|
106
|
-
name && `${_picocolors2.default.dim("[")}${name.toUpperCase()}${_picocolors2.default.dim("]")}`,
|
107
|
-
colorize(type, input.toUpperCase())
|
108
|
-
].filter(Boolean).join(" ");
|
109
|
-
};
|
110
|
-
var silent = false;
|
111
|
-
function setSilent(isSilent) {
|
112
|
-
silent = !!isSilent;
|
113
|
-
}
|
114
|
-
function getSilent() {
|
115
|
-
return silent;
|
116
|
-
}
|
117
|
-
var createLogger = (name) => {
|
118
|
-
return {
|
119
|
-
setName(_name) {
|
120
|
-
name = _name;
|
121
|
-
},
|
122
|
-
success(label, ...args) {
|
123
|
-
return this.log(label, "success", ...args);
|
124
|
-
},
|
125
|
-
info(label, ...args) {
|
126
|
-
return this.log(label, "info", ...args);
|
127
|
-
},
|
128
|
-
error(label, ...args) {
|
129
|
-
return this.log(label, "error", ...args);
|
130
|
-
},
|
131
|
-
warn(label, ...args) {
|
132
|
-
return this.log(label, "warn", ...args);
|
133
|
-
},
|
134
|
-
log(label, type, ...data) {
|
135
|
-
const args = [
|
136
|
-
makeLabel(name, label, type),
|
137
|
-
...data.map((item) => colorize(type, item, true))
|
138
|
-
];
|
139
|
-
switch (type) {
|
140
|
-
case "error": {
|
141
|
-
if (!_worker_threads.isMainThread) {
|
142
|
-
_optionalChain([_worker_threads.parentPort, 'optionalAccess', _ => _.postMessage, 'call', _2 => _2({
|
143
|
-
type: "error",
|
144
|
-
text: _util2.default.format(...args)
|
145
|
-
})]);
|
146
|
-
return;
|
147
|
-
}
|
148
|
-
return console.error(...args);
|
149
|
-
}
|
150
|
-
default:
|
151
|
-
if (silent) return;
|
152
|
-
if (!_worker_threads.isMainThread) {
|
153
|
-
_optionalChain([_worker_threads.parentPort, 'optionalAccess', _3 => _3.postMessage, 'call', _4 => _4({
|
154
|
-
type: "log",
|
155
|
-
text: _util2.default.format(...args)
|
156
|
-
})]);
|
157
|
-
return;
|
158
|
-
}
|
159
|
-
console.log(...args);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
};
|
163
|
-
};
|
164
|
-
|
165
|
-
// src/lib/report-size.ts
|
166
|
-
|
167
|
-
var prettyBytes = (bytes) => {
|
168
|
-
if (bytes === 0) return "0 B";
|
169
|
-
const unit = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
170
|
-
const exp = Math.floor(Math.log(bytes) / Math.log(1024));
|
171
|
-
return `${(bytes / 1024 ** exp).toFixed(2)} ${unit[exp]}`;
|
172
|
-
};
|
173
|
-
var getLengthOfLongestString = (strings) => {
|
174
|
-
return strings.reduce((max, str) => {
|
175
|
-
return Math.max(max, str.length);
|
176
|
-
}, 0);
|
177
|
-
};
|
178
|
-
var padRight = (str, maxLength) => {
|
179
|
-
return str + " ".repeat(maxLength - str.length);
|
180
|
-
};
|
181
|
-
var reportSize = (logger, format, files) => {
|
182
|
-
const filenames = Object.keys(files);
|
183
|
-
const maxLength = getLengthOfLongestString(filenames) + 1;
|
184
|
-
for (const name of filenames) {
|
185
|
-
logger.success(
|
186
|
-
format,
|
187
|
-
`${_picocolors2.default.bold(padRight(name, maxLength))}${_picocolors2.default.green(
|
188
|
-
prettyBytes(files[name])
|
189
|
-
)}`
|
190
|
-
);
|
191
|
-
}
|
192
|
-
};
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
exports.loadTsupConfig = loadTsupConfig; exports.loadPkg = loadPkg; exports.getProductionDeps = getProductionDeps; exports.getAllDepsHash = getAllDepsHash; exports.setSilent = setSilent; exports.getSilent = getSilent; exports.createLogger = createLogger; exports.reportSize = reportSize;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
|
-
|
4
|
-
var _chunkGZSSIGNCjs = require('./chunk-GZSSIGNC.js');
|
5
|
-
require('./chunk-BYH4XDRH.js');
|
6
|
-
|
7
|
-
|
8
|
-
var _chunkJZ25TPTYjs = require('./chunk-JZ25TPTY.js');
|
9
|
-
require('./chunk-TWFEYLU4.js');
|
10
|
-
|
11
|
-
// src/cli-default.ts
|
12
|
-
_chunkGZSSIGNCjs.main.call(void 0, ).catch(_chunkJZ25TPTYjs.handleError);
|