@storm-software/unbuild 0.21.0 → 0.22.0
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/README.md +1 -1
- package/bin/unbuild.js +1596 -162
- package/bin/unbuild.mjs +1592 -162
- package/dist/build.js +10 -10
- package/dist/build.mjs +1 -1
- package/dist/chunk-2Q67L63A.js +2456 -0
- package/dist/chunk-4WKFVYTI.js +18 -0
- package/dist/{chunk-XEAFTDQ7.js → chunk-6KE6SIPQ.js} +5 -5
- package/dist/{chunk-DFIGNXGY.js → chunk-B2WY6JG2.js} +1035 -1035
- package/dist/{chunk-WPOEGALQ.js → chunk-BMAXMHJB.js} +5 -5
- package/dist/{chunk-3OJD7CO4.js → chunk-E73BVQF5.js} +5 -5
- package/dist/chunk-J5YBLOB7.js +27 -0
- package/dist/{chunk-RCEWRXM5.js → chunk-RUNO4F6F.js} +2 -2
- package/dist/chunk-SGIQJ2OU.mjs +2455 -0
- package/dist/{chunk-OQPSH7GE.js → chunk-UUI4UWA4.js} +37 -37
- package/dist/clean.d.mts +12 -2
- package/dist/clean.d.ts +12 -2
- package/dist/clean.js +4 -4
- package/dist/config.js +8 -8
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +10 -10
- package/dist/index.mjs +1 -1
- package/dist/types.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-3GQAWCBQ.js +0 -13
- package/dist/chunk-3KCZOJ2Q.js +0 -1023
- package/dist/chunk-AYFS4N2Z.mjs +0 -1023
- package/dist/chunk-AYRYNROK.js +0 -27
- package/dist/clean-DDbna8D4.d.mts +0 -1194
- package/dist/clean-DDbna8D4.d.ts +0 -1194
package/bin/unbuild.js
CHANGED
|
@@ -23,6 +23,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
mod
|
|
24
24
|
));
|
|
25
25
|
|
|
26
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.49.1_@types+node@22.10.7__@swc+core@1.7.26_@swc+helpers_ekim6y52mwpq6ssxiprcp44dam/node_modules/tsup/assets/cjs_shims.js
|
|
27
|
+
var getImportMetaUrl = /* @__PURE__ */ __name(() => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href, "getImportMetaUrl");
|
|
28
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
29
|
+
|
|
26
30
|
// ../config/src/schema.ts
|
|
27
31
|
var import_zod = __toESM(require("zod"));
|
|
28
32
|
|
|
@@ -510,7 +514,7 @@ var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
|
|
|
510
514
|
// ../config-tools/src/logger/console.ts
|
|
511
515
|
var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) => {
|
|
512
516
|
const _chalk = getChalk();
|
|
513
|
-
const
|
|
517
|
+
const colors3 = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
|
|
514
518
|
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
515
519
|
if (typeof logLevel === "number" && (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel)) {
|
|
516
520
|
return (_2) => {
|
|
@@ -519,48 +523,48 @@ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) =>
|
|
|
519
523
|
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
|
|
520
524
|
return (message) => {
|
|
521
525
|
console.error(`
|
|
522
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
526
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
523
527
|
`);
|
|
524
528
|
};
|
|
525
529
|
}
|
|
526
530
|
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
|
|
527
531
|
return (message) => {
|
|
528
532
|
console.error(`
|
|
529
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
533
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
530
534
|
`);
|
|
531
535
|
};
|
|
532
536
|
}
|
|
533
537
|
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
|
|
534
538
|
return (message) => {
|
|
535
539
|
console.warn(`
|
|
536
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
540
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
537
541
|
`);
|
|
538
542
|
};
|
|
539
543
|
}
|
|
540
544
|
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel || typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel)) {
|
|
541
545
|
return (message) => {
|
|
542
546
|
console.info(`
|
|
543
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
547
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
544
548
|
`);
|
|
545
549
|
};
|
|
546
550
|
}
|
|
547
551
|
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
|
|
548
552
|
return (message) => {
|
|
549
553
|
console.info(`
|
|
550
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
554
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
551
555
|
`);
|
|
552
556
|
};
|
|
553
557
|
}
|
|
554
558
|
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel || typeof logLevel === "string" && LogLevel.TRACE >= getLogLevel(logLevel)) {
|
|
555
559
|
return (message) => {
|
|
556
560
|
console.debug(`
|
|
557
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
561
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
558
562
|
`);
|
|
559
563
|
};
|
|
560
564
|
}
|
|
561
565
|
return (message) => {
|
|
562
566
|
console.log(`
|
|
563
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
567
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
564
568
|
`);
|
|
565
569
|
};
|
|
566
570
|
}, "getLogFn");
|
|
@@ -1382,19 +1386,1449 @@ var import_glob3 = require("glob");
|
|
|
1382
1386
|
var import_create_task_graph = require("nx/src/tasks-runner/create-task-graph");
|
|
1383
1387
|
|
|
1384
1388
|
// src/build.ts
|
|
1385
|
-
var
|
|
1386
|
-
var
|
|
1387
|
-
var
|
|
1389
|
+
var import_defu5 = __toESM(require("defu"));
|
|
1390
|
+
var import_node_fs8 = require("fs");
|
|
1391
|
+
var import_promises7 = require("fs/promises");
|
|
1388
1392
|
var import_node_path6 = require("path");
|
|
1389
1393
|
var import_find_workspace_root5 = require("nx/src/utils/find-workspace-root");
|
|
1390
|
-
|
|
1394
|
+
|
|
1395
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
1396
|
+
var import_node_module2 = __toESM(require("module"), 1);
|
|
1397
|
+
var import_node_fs6 = require("fs");
|
|
1398
|
+
var import_pathe = require("pathe");
|
|
1399
|
+
var import_utils = require("consola/utils");
|
|
1400
|
+
var import_consola = __toESM(require("consola"), 1);
|
|
1401
|
+
var import_defu3 = require("defu");
|
|
1402
|
+
var import_hookable = require("hookable");
|
|
1403
|
+
var import_pretty_bytes = __toESM(require("pretty-bytes"), 1);
|
|
1404
|
+
var import_tinyglobby = require("tinyglobby");
|
|
1405
|
+
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
1406
|
+
var import_jiti = require("jiti");
|
|
1407
|
+
var import_rollup = require("rollup");
|
|
1408
|
+
var import_rollup_plugin_dts = __toESM(require("rollup-plugin-dts"), 1);
|
|
1409
|
+
var import_plugin_commonjs = __toESM(require("@rollup/plugin-commonjs"), 1);
|
|
1410
|
+
var import_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
1411
|
+
var import_plugin_alias = __toESM(require("@rollup/plugin-alias"), 1);
|
|
1412
|
+
var import_plugin_replace = __toESM(require("@rollup/plugin-replace"), 1);
|
|
1413
|
+
var import_utils2 = require("pathe/utils");
|
|
1414
|
+
var import_mlly = require("mlly");
|
|
1415
|
+
var import_esbuild = require("esbuild");
|
|
1416
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
|
1417
|
+
var import_plugin_json = __toESM(require("@rollup/plugin-json"), 1);
|
|
1418
|
+
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
1419
|
+
var import_untyped = require("untyped");
|
|
1420
|
+
var import_babel_plugin = __toESM(require("untyped/babel-plugin"), 1);
|
|
1421
|
+
var import_scule = require("scule");
|
|
1422
|
+
var import_mkdist = require("mkdist");
|
|
1423
|
+
function definePreset(preset) {
|
|
1424
|
+
return preset;
|
|
1425
|
+
}
|
|
1426
|
+
__name(definePreset, "definePreset");
|
|
1427
|
+
var autoPreset = definePreset(() => {
|
|
1428
|
+
return {
|
|
1429
|
+
hooks: {
|
|
1430
|
+
"build:prepare"(ctx) {
|
|
1431
|
+
if (!ctx.pkg || ctx.options.entries.length > 0) {
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
const sourceFiles = listRecursively((0, import_pathe.join)(ctx.options.rootDir, "src"));
|
|
1435
|
+
const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir);
|
|
1436
|
+
for (const message of res.warnings) {
|
|
1437
|
+
warn(ctx, message);
|
|
1438
|
+
}
|
|
1439
|
+
ctx.options.entries.push(...res.entries);
|
|
1440
|
+
if (res.cjs) {
|
|
1441
|
+
ctx.options.rollup.emitCJS = true;
|
|
1442
|
+
}
|
|
1443
|
+
if (ctx.options.declaration === void 0) {
|
|
1444
|
+
ctx.options.declaration = res.dts ? "compatible" : false;
|
|
1445
|
+
}
|
|
1446
|
+
import_consola.consola.info(
|
|
1447
|
+
"Automatically detected entries:",
|
|
1448
|
+
import_utils.colors.cyan(
|
|
1449
|
+
ctx.options.entries.map(
|
|
1450
|
+
(e) => import_utils.colors.bold(
|
|
1451
|
+
e.input.replace(ctx.options.rootDir + "/", "").replace(/\/$/, "/*")
|
|
1452
|
+
)
|
|
1453
|
+
).join(", ")
|
|
1454
|
+
),
|
|
1455
|
+
import_utils.colors.gray(
|
|
1456
|
+
["esm", res.cjs && "cjs", res.dts && "dts"].filter(Boolean).map((tag) => `[${tag}]`).join(" ")
|
|
1457
|
+
)
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
});
|
|
1463
|
+
function inferEntries(pkg, sourceFiles, rootDir) {
|
|
1464
|
+
const warnings = [];
|
|
1465
|
+
sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length);
|
|
1466
|
+
const outputs = extractExportFilenames(pkg.exports);
|
|
1467
|
+
if (pkg.bin) {
|
|
1468
|
+
const binaries = typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin);
|
|
1469
|
+
for (const file of binaries) {
|
|
1470
|
+
outputs.push({ file });
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if (pkg.main) {
|
|
1474
|
+
outputs.push({ file: pkg.main });
|
|
1475
|
+
}
|
|
1476
|
+
if (pkg.module) {
|
|
1477
|
+
outputs.push({ type: "esm", file: pkg.module });
|
|
1478
|
+
}
|
|
1479
|
+
if (pkg.types || pkg.typings) {
|
|
1480
|
+
outputs.push({ file: pkg.types || pkg.typings });
|
|
1481
|
+
}
|
|
1482
|
+
const isESMPkg = pkg.type === "module";
|
|
1483
|
+
for (const output of outputs.filter((o) => !o.type)) {
|
|
1484
|
+
const isJS = output.file.endsWith(".js");
|
|
1485
|
+
if (isESMPkg && isJS || output.file.endsWith(".mjs")) {
|
|
1486
|
+
output.type = "esm";
|
|
1487
|
+
} else if (!isESMPkg && isJS || output.file.endsWith(".cjs")) {
|
|
1488
|
+
output.type = "cjs";
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
let cjs = false;
|
|
1492
|
+
let dts2 = false;
|
|
1493
|
+
const entries = [];
|
|
1494
|
+
for (const output of outputs) {
|
|
1495
|
+
const outputSlug = output.file.replace(
|
|
1496
|
+
/(\*[^/\\]*|\.d\.(m|c)?ts|\.\w+)$/,
|
|
1497
|
+
""
|
|
1498
|
+
);
|
|
1499
|
+
const isDir = outputSlug.endsWith("/");
|
|
1500
|
+
if (isDir && ["./", "/"].includes(outputSlug)) {
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
const possiblePaths = getEntrypointPaths(outputSlug);
|
|
1504
|
+
const input = possiblePaths.reduce((source, d) => {
|
|
1505
|
+
if (source) {
|
|
1506
|
+
return source;
|
|
1507
|
+
}
|
|
1508
|
+
const SOURCE_RE = new RegExp(
|
|
1509
|
+
`(?<=/|$)${d}${isDir ? "" : String.raw`\.\w+`}$`
|
|
1510
|
+
);
|
|
1511
|
+
return sourceFiles.find((i) => SOURCE_RE.test(i))?.replace(/(\.d\.(m|c)?ts|\.\w+)$/, "");
|
|
1512
|
+
}, void 0);
|
|
1513
|
+
if (!input) {
|
|
1514
|
+
if (!(0, import_node_fs6.existsSync)((0, import_pathe.resolve)(rootDir || ".", output.file))) {
|
|
1515
|
+
warnings.push(`Could not find entrypoint for \`${output.file}\``);
|
|
1516
|
+
}
|
|
1517
|
+
continue;
|
|
1518
|
+
}
|
|
1519
|
+
if (output.type === "cjs") {
|
|
1520
|
+
cjs = true;
|
|
1521
|
+
}
|
|
1522
|
+
const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1];
|
|
1523
|
+
if (/\.d\.(m|c)?ts$/.test(output.file)) {
|
|
1524
|
+
dts2 = true;
|
|
1525
|
+
}
|
|
1526
|
+
if (isDir) {
|
|
1527
|
+
entry.outDir = outputSlug;
|
|
1528
|
+
entry.format = output.type;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
return { entries, cjs, dts: dts2, warnings };
|
|
1532
|
+
}
|
|
1533
|
+
__name(inferEntries, "inferEntries");
|
|
1534
|
+
var getEntrypointPaths = /* @__PURE__ */ __name((path3) => {
|
|
1535
|
+
const segments = (0, import_pathe.normalize)(path3).split("/");
|
|
1536
|
+
return segments.map((_2, index) => segments.slice(index).join("/")).filter(Boolean);
|
|
1537
|
+
}, "getEntrypointPaths");
|
|
1538
|
+
async function ensuredir(path3) {
|
|
1539
|
+
await import_promises4.default.mkdir((0, import_pathe.dirname)(path3), { recursive: true });
|
|
1540
|
+
}
|
|
1541
|
+
__name(ensuredir, "ensuredir");
|
|
1542
|
+
function warn(ctx, message) {
|
|
1543
|
+
if (ctx.warnings.has(message)) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
import_consola.consola.debug("[unbuild] [warn]", message);
|
|
1547
|
+
ctx.warnings.add(message);
|
|
1548
|
+
}
|
|
1549
|
+
__name(warn, "warn");
|
|
1550
|
+
async function symlink(from, to, force = true) {
|
|
1551
|
+
await ensuredir(to);
|
|
1552
|
+
if (force) {
|
|
1553
|
+
await import_promises4.default.unlink(to).catch(() => {
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
await import_promises4.default.symlink(from, to, "junction");
|
|
1557
|
+
}
|
|
1558
|
+
__name(symlink, "symlink");
|
|
1559
|
+
function dumpObject(obj) {
|
|
1560
|
+
return "{ " + Object.keys(obj).map((key) => `${key}: ${JSON.stringify(obj[key])}`).join(", ") + " }";
|
|
1561
|
+
}
|
|
1562
|
+
__name(dumpObject, "dumpObject");
|
|
1563
|
+
function getpkg(id = "") {
|
|
1564
|
+
const s = id.split("/");
|
|
1565
|
+
return s[0][0] === "@" ? `${s[0]}/${s[1]}` : s[0];
|
|
1566
|
+
}
|
|
1567
|
+
__name(getpkg, "getpkg");
|
|
1568
|
+
async function rmdir(dir) {
|
|
1569
|
+
await import_promises4.default.unlink(dir).catch(() => {
|
|
1570
|
+
});
|
|
1571
|
+
await import_promises4.default.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
__name(rmdir, "rmdir");
|
|
1575
|
+
function listRecursively(path3) {
|
|
1576
|
+
const filenames = /* @__PURE__ */ new Set();
|
|
1577
|
+
const walk = /* @__PURE__ */ __name((path22) => {
|
|
1578
|
+
const files = (0, import_node_fs6.readdirSync)(path22);
|
|
1579
|
+
for (const file of files) {
|
|
1580
|
+
const fullPath = (0, import_pathe.resolve)(path22, file);
|
|
1581
|
+
if ((0, import_node_fs6.statSync)(fullPath).isDirectory()) {
|
|
1582
|
+
filenames.add(fullPath + "/");
|
|
1583
|
+
walk(fullPath);
|
|
1584
|
+
} else {
|
|
1585
|
+
filenames.add(fullPath);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
}, "walk");
|
|
1589
|
+
walk(path3);
|
|
1590
|
+
return [...filenames];
|
|
1591
|
+
}
|
|
1592
|
+
__name(listRecursively, "listRecursively");
|
|
1593
|
+
async function resolvePreset(preset, rootDir) {
|
|
1594
|
+
if (preset === "auto") {
|
|
1595
|
+
preset = autoPreset;
|
|
1596
|
+
} else if (typeof preset === "string") {
|
|
1597
|
+
preset = await (0, import_jiti.createJiti)(rootDir, { interopDefault: true }).import(preset, {
|
|
1598
|
+
default: true
|
|
1599
|
+
}) || {};
|
|
1600
|
+
}
|
|
1601
|
+
if (typeof preset === "function") {
|
|
1602
|
+
preset = preset();
|
|
1603
|
+
}
|
|
1604
|
+
return preset;
|
|
1605
|
+
}
|
|
1606
|
+
__name(resolvePreset, "resolvePreset");
|
|
1607
|
+
function inferExportType(condition, previousConditions = [], filename = "") {
|
|
1608
|
+
if (filename) {
|
|
1609
|
+
if (filename.endsWith(".d.ts")) {
|
|
1610
|
+
return "esm";
|
|
1611
|
+
}
|
|
1612
|
+
if (filename.endsWith(".mjs")) {
|
|
1613
|
+
return "esm";
|
|
1614
|
+
}
|
|
1615
|
+
if (filename.endsWith(".cjs")) {
|
|
1616
|
+
return "cjs";
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
switch (condition) {
|
|
1620
|
+
case "import": {
|
|
1621
|
+
return "esm";
|
|
1622
|
+
}
|
|
1623
|
+
case "require": {
|
|
1624
|
+
return "cjs";
|
|
1625
|
+
}
|
|
1626
|
+
default: {
|
|
1627
|
+
if (previousConditions.length === 0) {
|
|
1628
|
+
return "esm";
|
|
1629
|
+
}
|
|
1630
|
+
const [newCondition, ...rest] = previousConditions;
|
|
1631
|
+
return inferExportType(newCondition, rest, filename);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
__name(inferExportType, "inferExportType");
|
|
1636
|
+
function extractExportFilenames(exports2, conditions = []) {
|
|
1637
|
+
if (!exports2) {
|
|
1638
|
+
return [];
|
|
1639
|
+
}
|
|
1640
|
+
if (typeof exports2 === "string") {
|
|
1641
|
+
return [{ file: exports2, type: "esm" }];
|
|
1642
|
+
}
|
|
1643
|
+
return Object.entries(exports2).filter(([subpath]) => !subpath.endsWith(".json")).flatMap(
|
|
1644
|
+
([condition, exports22]) => typeof exports22 === "string" ? {
|
|
1645
|
+
file: exports22,
|
|
1646
|
+
type: inferExportType(condition, conditions, exports22)
|
|
1647
|
+
} : extractExportFilenames(exports22, [...conditions, condition])
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1650
|
+
__name(extractExportFilenames, "extractExportFilenames");
|
|
1651
|
+
function arrayIncludes(arr, searchElement) {
|
|
1652
|
+
return arr.some(
|
|
1653
|
+
(entry) => entry instanceof RegExp ? entry.test(searchElement) : entry === searchElement
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
__name(arrayIncludes, "arrayIncludes");
|
|
1657
|
+
function removeExtension(filename) {
|
|
1658
|
+
return filename.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/, "");
|
|
1659
|
+
}
|
|
1660
|
+
__name(removeExtension, "removeExtension");
|
|
1661
|
+
function inferPkgExternals(pkg) {
|
|
1662
|
+
const externals = [
|
|
1663
|
+
...Object.keys(pkg.dependencies || {}),
|
|
1664
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
1665
|
+
...Object.keys(pkg.devDependencies || {}).filter(
|
|
1666
|
+
(dep) => dep.startsWith("@types/")
|
|
1667
|
+
),
|
|
1668
|
+
...Object.keys(pkg.optionalDependencies || {})
|
|
1669
|
+
];
|
|
1670
|
+
if (pkg.name) {
|
|
1671
|
+
externals.push(pkg.name);
|
|
1672
|
+
if (pkg.exports) {
|
|
1673
|
+
for (const subpath of Object.keys(pkg.exports)) {
|
|
1674
|
+
if (subpath.startsWith("./")) {
|
|
1675
|
+
externals.push(pathToRegex(`${pkg.name}/${subpath.slice(2)}`));
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
if (pkg.imports) {
|
|
1681
|
+
for (const importName of Object.keys(pkg.imports)) {
|
|
1682
|
+
if (importName.startsWith("#")) {
|
|
1683
|
+
externals.push(pathToRegex(importName));
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return [...new Set(externals)];
|
|
1688
|
+
}
|
|
1689
|
+
__name(inferPkgExternals, "inferPkgExternals");
|
|
1690
|
+
function pathToRegex(path3) {
|
|
1691
|
+
return path3.includes("*") ? new RegExp(
|
|
1692
|
+
`^${path3.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`
|
|
1693
|
+
) : path3;
|
|
1694
|
+
}
|
|
1695
|
+
__name(pathToRegex, "pathToRegex");
|
|
1696
|
+
function withTrailingSlash(path3) {
|
|
1697
|
+
return path3.endsWith("/") ? path3 : `${path3}/`;
|
|
1698
|
+
}
|
|
1699
|
+
__name(withTrailingSlash, "withTrailingSlash");
|
|
1700
|
+
function validateDependencies(ctx) {
|
|
1701
|
+
const usedDependencies = /* @__PURE__ */ new Set();
|
|
1702
|
+
const unusedDependencies = new Set(
|
|
1703
|
+
Object.keys(ctx.pkg.dependencies || {})
|
|
1704
|
+
);
|
|
1705
|
+
const implicitDependencies = /* @__PURE__ */ new Set();
|
|
1706
|
+
for (const id of ctx.usedImports) {
|
|
1707
|
+
unusedDependencies.delete(id);
|
|
1708
|
+
usedDependencies.add(id);
|
|
1709
|
+
}
|
|
1710
|
+
if (Array.isArray(ctx.options.dependencies)) {
|
|
1711
|
+
for (const id of ctx.options.dependencies) {
|
|
1712
|
+
unusedDependencies.delete(id);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
for (const id of usedDependencies) {
|
|
1716
|
+
if (!arrayIncludes(ctx.options.externals, id) && !id.startsWith("chunks/") && !ctx.options.dependencies.includes(getpkg(id)) && !ctx.options.peerDependencies.includes(getpkg(id))) {
|
|
1717
|
+
implicitDependencies.add(id);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
if (unusedDependencies.size > 0) {
|
|
1721
|
+
warn(
|
|
1722
|
+
ctx,
|
|
1723
|
+
"Potential unused dependencies found: " + [...unusedDependencies].map((id) => import_utils.colors.cyan(id)).join(", ")
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) {
|
|
1727
|
+
warn(
|
|
1728
|
+
ctx,
|
|
1729
|
+
"Potential implicit dependencies found: " + [...implicitDependencies].map((id) => import_utils.colors.cyan(id)).join(", ")
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
__name(validateDependencies, "validateDependencies");
|
|
1734
|
+
function validatePackage(pkg, rootDir, ctx) {
|
|
1735
|
+
if (!pkg) {
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
const filenames = new Set(
|
|
1739
|
+
[
|
|
1740
|
+
...typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {}),
|
|
1741
|
+
pkg.main,
|
|
1742
|
+
pkg.module,
|
|
1743
|
+
pkg.types,
|
|
1744
|
+
pkg.typings,
|
|
1745
|
+
...extractExportFilenames(pkg.exports).map((i) => i.file)
|
|
1746
|
+
].map((i) => i && (0, import_pathe.resolve)(rootDir, i.replace(/\/[^/]*\*.*$/, "")))
|
|
1747
|
+
);
|
|
1748
|
+
const missingOutputs = [];
|
|
1749
|
+
for (const filename of filenames) {
|
|
1750
|
+
if (filename && !filename.includes("*") && !(0, import_node_fs6.existsSync)(filename)) {
|
|
1751
|
+
missingOutputs.push(filename.replace(rootDir + "/", ""));
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (missingOutputs.length > 0) {
|
|
1755
|
+
warn(
|
|
1756
|
+
ctx,
|
|
1757
|
+
`Potential missing package.json files: ${missingOutputs.map((o) => import_utils.colors.cyan(o)).join(", ")}`
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
__name(validatePackage, "validatePackage");
|
|
1762
|
+
var SHEBANG_RE = /^#![^\n]*/;
|
|
1763
|
+
function shebangPlugin() {
|
|
1764
|
+
return {
|
|
1765
|
+
name: "unbuild-shebang",
|
|
1766
|
+
async writeBundle(options, bundle) {
|
|
1767
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1768
|
+
if (output.type !== "chunk") {
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
if (output.code?.match(SHEBANG_RE)) {
|
|
1772
|
+
const outFile = (0, import_pathe.resolve)(options.dir, fileName);
|
|
1773
|
+
await makeExecutable(outFile);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
__name(shebangPlugin, "shebangPlugin");
|
|
1780
|
+
function removeShebangPlugin() {
|
|
1781
|
+
return {
|
|
1782
|
+
name: "unbuild-remove-shebang",
|
|
1783
|
+
renderChunk(code) {
|
|
1784
|
+
return code.replace(SHEBANG_RE, "");
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
__name(removeShebangPlugin, "removeShebangPlugin");
|
|
1789
|
+
async function makeExecutable(filePath) {
|
|
1790
|
+
await import_node_fs6.promises.chmod(
|
|
1791
|
+
filePath,
|
|
1792
|
+
493
|
|
1793
|
+
/* rwx r-x r-x */
|
|
1794
|
+
).catch(() => {
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
__name(makeExecutable, "makeExecutable");
|
|
1798
|
+
function getShebang(code, append = "\n") {
|
|
1799
|
+
const m = code.match(SHEBANG_RE);
|
|
1800
|
+
return m ? m + append : "";
|
|
1801
|
+
}
|
|
1802
|
+
__name(getShebang, "getShebang");
|
|
1803
|
+
var DefaultLoaders = {
|
|
1804
|
+
".js": "js",
|
|
1805
|
+
".mjs": "js",
|
|
1806
|
+
".cjs": "js",
|
|
1807
|
+
".ts": "ts",
|
|
1808
|
+
".mts": "ts",
|
|
1809
|
+
".cts": "ts",
|
|
1810
|
+
".tsx": "tsx",
|
|
1811
|
+
".jsx": "jsx"
|
|
1812
|
+
};
|
|
1813
|
+
function esbuild(options) {
|
|
1814
|
+
const {
|
|
1815
|
+
include = new RegExp(Object.keys(DefaultLoaders).join("|")),
|
|
1816
|
+
exclude = /node_modules/,
|
|
1817
|
+
loaders: loaderOptions,
|
|
1818
|
+
...esbuildOptions
|
|
1819
|
+
} = options;
|
|
1820
|
+
const loaders = { ...DefaultLoaders };
|
|
1821
|
+
if (loaderOptions) {
|
|
1822
|
+
for (const [key, value] of Object.entries(loaderOptions)) {
|
|
1823
|
+
if (typeof value === "string") {
|
|
1824
|
+
loaders[key] = value;
|
|
1825
|
+
} else if (value === false) {
|
|
1826
|
+
delete loaders[key];
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
const getLoader = /* @__PURE__ */ __name((id = "") => {
|
|
1831
|
+
return loaders[(0, import_pathe.extname)(id)];
|
|
1832
|
+
}, "getLoader");
|
|
1833
|
+
const filter = (0, import_pluginutils.createFilter)(include, exclude);
|
|
1834
|
+
return {
|
|
1835
|
+
name: "esbuild",
|
|
1836
|
+
async transform(code, id) {
|
|
1837
|
+
if (!filter(id)) {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1840
|
+
const loader = getLoader(id);
|
|
1841
|
+
if (!loader) {
|
|
1842
|
+
return null;
|
|
1843
|
+
}
|
|
1844
|
+
const result = await (0, import_esbuild.transform)(code, {
|
|
1845
|
+
...esbuildOptions,
|
|
1846
|
+
loader,
|
|
1847
|
+
sourcefile: id
|
|
1848
|
+
});
|
|
1849
|
+
printWarnings(id, result, this);
|
|
1850
|
+
return {
|
|
1851
|
+
code: result.code || "",
|
|
1852
|
+
map: result.map || null
|
|
1853
|
+
};
|
|
1854
|
+
},
|
|
1855
|
+
async renderChunk(code, { fileName }) {
|
|
1856
|
+
if (!options.minify) {
|
|
1857
|
+
return null;
|
|
1858
|
+
}
|
|
1859
|
+
if (/\.d\.(c|m)?tsx?$/.test(fileName)) {
|
|
1860
|
+
return null;
|
|
1861
|
+
}
|
|
1862
|
+
const loader = getLoader(fileName);
|
|
1863
|
+
if (!loader) {
|
|
1864
|
+
return null;
|
|
1865
|
+
}
|
|
1866
|
+
const result = await (0, import_esbuild.transform)(code, {
|
|
1867
|
+
...esbuildOptions,
|
|
1868
|
+
loader,
|
|
1869
|
+
sourcefile: fileName,
|
|
1870
|
+
minify: true
|
|
1871
|
+
});
|
|
1872
|
+
return {
|
|
1873
|
+
code: result.code || "",
|
|
1874
|
+
map: result.map || null
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
__name(esbuild, "esbuild");
|
|
1880
|
+
function printWarnings(id, result, plugin) {
|
|
1881
|
+
if (result.warnings) {
|
|
1882
|
+
for (const warning of result.warnings) {
|
|
1883
|
+
let message = "[esbuild]";
|
|
1884
|
+
if (warning.location) {
|
|
1885
|
+
message += ` (${(0, import_pathe.relative)(process.cwd(), id)}:${warning.location.line}:${warning.location.column})`;
|
|
1886
|
+
}
|
|
1887
|
+
message += ` ${warning.text}`;
|
|
1888
|
+
plugin.warn(message);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
__name(printWarnings, "printWarnings");
|
|
1893
|
+
var EXPORT_DEFAULT = "export default ";
|
|
1894
|
+
function JSONPlugin(options) {
|
|
1895
|
+
const plugin = (0, import_plugin_json.default)(options);
|
|
1896
|
+
return {
|
|
1897
|
+
...plugin,
|
|
1898
|
+
name: "unbuild-json",
|
|
1899
|
+
transform(code, id) {
|
|
1900
|
+
const res = plugin.transform.call(this, code, id);
|
|
1901
|
+
if (res && typeof res !== "string" && "code" in res && res.code && res.code.startsWith(EXPORT_DEFAULT)) {
|
|
1902
|
+
res.code = res.code.replace(EXPORT_DEFAULT, "module.exports = ");
|
|
1903
|
+
}
|
|
1904
|
+
return res;
|
|
1905
|
+
}
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
__name(JSONPlugin, "JSONPlugin");
|
|
1909
|
+
var defaults = {
|
|
1910
|
+
include: [/\.(md|txt|css|htm|html)$/],
|
|
1911
|
+
exclude: []
|
|
1912
|
+
};
|
|
1913
|
+
function rawPlugin(opts = {}) {
|
|
1914
|
+
opts = { ...opts, ...defaults };
|
|
1915
|
+
const filter = (0, import_pluginutils.createFilter)(opts.include, opts.exclude);
|
|
1916
|
+
return {
|
|
1917
|
+
name: "unbuild-raw",
|
|
1918
|
+
transform(code, id) {
|
|
1919
|
+
if (filter(id)) {
|
|
1920
|
+
return {
|
|
1921
|
+
code: `export default ${JSON.stringify(code)}`,
|
|
1922
|
+
map: null
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
__name(rawPlugin, "rawPlugin");
|
|
1929
|
+
function cjsPlugin(_opts) {
|
|
1930
|
+
return {
|
|
1931
|
+
name: "unbuild-cjs",
|
|
1932
|
+
renderChunk(code, _chunk, opts) {
|
|
1933
|
+
if (opts.format === "es") {
|
|
1934
|
+
return CJSToESM(code);
|
|
1935
|
+
}
|
|
1936
|
+
return null;
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
__name(cjsPlugin, "cjsPlugin");
|
|
1941
|
+
function fixCJSExportTypePlugin() {
|
|
1942
|
+
return {
|
|
1943
|
+
name: "unbuild-fix-cjs-export-type",
|
|
1944
|
+
renderChunk(code, info, opts) {
|
|
1945
|
+
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || info.exports?.length !== 1 || info.exports[0] !== "default") {
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1948
|
+
return code.replace(
|
|
1949
|
+
/(?<=(?<=[;}]|^)\s*export\s*){\s*([\w$]+)\s*as\s+default\s*}/,
|
|
1950
|
+
`= $1`
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
__name(fixCJSExportTypePlugin, "fixCJSExportTypePlugin");
|
|
1956
|
+
var CJSyntaxRe = /__filename|__dirname|require\(|require\.resolve\(/;
|
|
1957
|
+
var CJSShim = `
|
|
1958
|
+
|
|
1959
|
+
// -- Unbuild CommonJS Shims --
|
|
1960
|
+
import __cjs_url__ from 'url';
|
|
1961
|
+
import __cjs_path__ from 'path';
|
|
1962
|
+
import __cjs_mod__ from 'module';
|
|
1963
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
1964
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
1965
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
1966
|
+
`;
|
|
1967
|
+
function CJSToESM(code) {
|
|
1968
|
+
if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) {
|
|
1969
|
+
return null;
|
|
1970
|
+
}
|
|
1971
|
+
const lastESMImport = (0, import_mlly.findStaticImports)(code).pop();
|
|
1972
|
+
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
|
|
1973
|
+
const s = new import_magic_string.default(code);
|
|
1974
|
+
s.appendRight(indexToAppend, CJSShim);
|
|
1975
|
+
return {
|
|
1976
|
+
code: s.toString(),
|
|
1977
|
+
map: s.generateMap()
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
__name(CJSToESM, "CJSToESM");
|
|
1981
|
+
var DEFAULT_EXTENSIONS = [
|
|
1982
|
+
".ts",
|
|
1983
|
+
".tsx",
|
|
1984
|
+
".mts",
|
|
1985
|
+
".cts",
|
|
1986
|
+
".mjs",
|
|
1987
|
+
".cjs",
|
|
1988
|
+
".js",
|
|
1989
|
+
".jsx",
|
|
1990
|
+
".json"
|
|
1991
|
+
];
|
|
1992
|
+
function resolveAliases(ctx) {
|
|
1993
|
+
const aliases = {
|
|
1994
|
+
[ctx.pkg.name]: ctx.options.rootDir,
|
|
1995
|
+
...ctx.options.alias
|
|
1996
|
+
};
|
|
1997
|
+
if (ctx.options.rollup.alias) {
|
|
1998
|
+
if (Array.isArray(ctx.options.rollup.alias.entries)) {
|
|
1999
|
+
Object.assign(
|
|
2000
|
+
aliases,
|
|
2001
|
+
Object.fromEntries(
|
|
2002
|
+
ctx.options.rollup.alias.entries.map((entry) => {
|
|
2003
|
+
return [entry.find, entry.replacement];
|
|
2004
|
+
})
|
|
2005
|
+
)
|
|
2006
|
+
);
|
|
2007
|
+
} else {
|
|
2008
|
+
Object.assign(
|
|
2009
|
+
aliases,
|
|
2010
|
+
ctx.options.rollup.alias.entries || ctx.options.rollup.alias
|
|
2011
|
+
);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
return aliases;
|
|
2015
|
+
}
|
|
2016
|
+
__name(resolveAliases, "resolveAliases");
|
|
2017
|
+
function getChunkFilename(ctx, chunk, ext) {
|
|
2018
|
+
if (chunk.isDynamicEntry) {
|
|
2019
|
+
return `chunks/[name].${ext}`;
|
|
2020
|
+
}
|
|
2021
|
+
return `shared/${ctx.options.name}.[hash].${ext}`;
|
|
2022
|
+
}
|
|
2023
|
+
__name(getChunkFilename, "getChunkFilename");
|
|
2024
|
+
function getRollupOptions(ctx) {
|
|
2025
|
+
const _aliases = resolveAliases(ctx);
|
|
2026
|
+
return {
|
|
2027
|
+
input: Object.fromEntries(
|
|
2028
|
+
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [
|
|
2029
|
+
entry.name,
|
|
2030
|
+
(0, import_pathe.resolve)(ctx.options.rootDir, entry.input)
|
|
2031
|
+
])
|
|
2032
|
+
),
|
|
2033
|
+
output: [
|
|
2034
|
+
ctx.options.rollup.emitCJS && {
|
|
2035
|
+
dir: (0, import_pathe.resolve)(ctx.options.rootDir, ctx.options.outDir),
|
|
2036
|
+
entryFileNames: "[name].cjs",
|
|
2037
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "cjs"), "chunkFileNames"),
|
|
2038
|
+
format: "cjs",
|
|
2039
|
+
exports: "auto",
|
|
2040
|
+
interop: "compat",
|
|
2041
|
+
generatedCode: { constBindings: true },
|
|
2042
|
+
externalLiveBindings: false,
|
|
2043
|
+
freeze: false,
|
|
2044
|
+
sourcemap: ctx.options.sourcemap,
|
|
2045
|
+
...ctx.options.rollup.output
|
|
2046
|
+
},
|
|
2047
|
+
{
|
|
2048
|
+
dir: (0, import_pathe.resolve)(ctx.options.rootDir, ctx.options.outDir),
|
|
2049
|
+
entryFileNames: "[name].mjs",
|
|
2050
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "mjs"), "chunkFileNames"),
|
|
2051
|
+
format: "esm",
|
|
2052
|
+
exports: "auto",
|
|
2053
|
+
generatedCode: { constBindings: true },
|
|
2054
|
+
externalLiveBindings: false,
|
|
2055
|
+
freeze: false,
|
|
2056
|
+
sourcemap: ctx.options.sourcemap,
|
|
2057
|
+
...ctx.options.rollup.output
|
|
2058
|
+
}
|
|
2059
|
+
].filter(Boolean),
|
|
2060
|
+
external(originalId) {
|
|
2061
|
+
const resolvedId = (0, import_utils2.resolveAlias)(originalId, _aliases);
|
|
2062
|
+
const pkgName = (0, import_mlly.parseNodeModulePath)(resolvedId)?.name || (0, import_mlly.parseNodeModulePath)(originalId)?.name || getpkg(originalId);
|
|
2063
|
+
if (arrayIncludes(ctx.options.externals, pkgName) || arrayIncludes(ctx.options.externals, originalId) || arrayIncludes(ctx.options.externals, resolvedId)) {
|
|
2064
|
+
return true;
|
|
2065
|
+
}
|
|
2066
|
+
for (const id of [originalId, resolvedId]) {
|
|
2067
|
+
if (id[0] === "." || (0, import_pathe.isAbsolute)(id) || /src[/\\]/.test(id) || id.startsWith(ctx.pkg.name)) {
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (ctx.options.rollup.inlineDependencies === true || Array.isArray(ctx.options.rollup.inlineDependencies) && (arrayIncludes(ctx.options.rollup.inlineDependencies, pkgName) || arrayIncludes(ctx.options.rollup.inlineDependencies, originalId) || arrayIncludes(ctx.options.rollup.inlineDependencies, resolvedId))) {
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
warn(ctx, `Implicitly bundling "${originalId}"`);
|
|
2075
|
+
return false;
|
|
2076
|
+
},
|
|
2077
|
+
onwarn(warning, rollupWarn) {
|
|
2078
|
+
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
2079
|
+
rollupWarn(warning);
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
plugins: [
|
|
2083
|
+
ctx.options.rollup.replace && (0, import_plugin_replace.default)({
|
|
2084
|
+
...ctx.options.rollup.replace,
|
|
2085
|
+
values: {
|
|
2086
|
+
...ctx.options.replace,
|
|
2087
|
+
...ctx.options.rollup.replace.values
|
|
2088
|
+
}
|
|
2089
|
+
}),
|
|
2090
|
+
ctx.options.rollup.alias && (0, import_plugin_alias.default)({
|
|
2091
|
+
...ctx.options.rollup.alias,
|
|
2092
|
+
entries: _aliases
|
|
2093
|
+
}),
|
|
2094
|
+
ctx.options.rollup.resolve && (0, import_plugin_node_resolve.nodeResolve)({
|
|
2095
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2096
|
+
exportConditions: ["production"],
|
|
2097
|
+
...ctx.options.rollup.resolve
|
|
2098
|
+
}),
|
|
2099
|
+
ctx.options.rollup.json && JSONPlugin({
|
|
2100
|
+
...ctx.options.rollup.json
|
|
2101
|
+
}),
|
|
2102
|
+
shebangPlugin(),
|
|
2103
|
+
ctx.options.rollup.esbuild && esbuild({
|
|
2104
|
+
sourcemap: ctx.options.sourcemap,
|
|
2105
|
+
...ctx.options.rollup.esbuild
|
|
2106
|
+
}),
|
|
2107
|
+
ctx.options.rollup.commonjs && (0, import_plugin_commonjs.default)({
|
|
2108
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2109
|
+
...ctx.options.rollup.commonjs
|
|
2110
|
+
}),
|
|
2111
|
+
ctx.options.rollup.preserveDynamicImports && {
|
|
2112
|
+
renderDynamicImport() {
|
|
2113
|
+
return { left: "import(", right: ")" };
|
|
2114
|
+
}
|
|
2115
|
+
},
|
|
2116
|
+
ctx.options.rollup.cjsBridge && cjsPlugin(),
|
|
2117
|
+
rawPlugin()
|
|
2118
|
+
].filter(Boolean)
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
__name(getRollupOptions, "getRollupOptions");
|
|
2122
|
+
async function rollupStub(ctx) {
|
|
2123
|
+
const babelPlugins = ctx.options.stubOptions.jiti.transformOptions?.babel?.plugins;
|
|
2124
|
+
const importedBabelPlugins = [];
|
|
2125
|
+
const serializedJitiOptions = JSON.stringify(
|
|
2126
|
+
{
|
|
2127
|
+
...ctx.options.stubOptions.jiti,
|
|
2128
|
+
alias: {
|
|
2129
|
+
...resolveAliases(ctx),
|
|
2130
|
+
...ctx.options.stubOptions.jiti.alias
|
|
2131
|
+
},
|
|
2132
|
+
transformOptions: {
|
|
2133
|
+
...ctx.options.stubOptions.jiti.transformOptions,
|
|
2134
|
+
babel: {
|
|
2135
|
+
...ctx.options.stubOptions.jiti.transformOptions?.babel,
|
|
2136
|
+
plugins: "__$BABEL_PLUGINS"
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
},
|
|
2140
|
+
null,
|
|
2141
|
+
2
|
|
2142
|
+
).replace(
|
|
2143
|
+
'"__$BABEL_PLUGINS"',
|
|
2144
|
+
Array.isArray(babelPlugins) ? "[" + babelPlugins.map((plugin, i) => {
|
|
2145
|
+
if (Array.isArray(plugin)) {
|
|
2146
|
+
const [name, ...args] = plugin;
|
|
2147
|
+
importedBabelPlugins.push(name);
|
|
2148
|
+
return `[` + [
|
|
2149
|
+
`plugin${i}`,
|
|
2150
|
+
...args.map((val) => JSON.stringify(val))
|
|
2151
|
+
].join(", ") + "]";
|
|
2152
|
+
} else {
|
|
2153
|
+
importedBabelPlugins.push(plugin);
|
|
2154
|
+
return `plugin${i}`;
|
|
2155
|
+
}
|
|
2156
|
+
}).join(",") + "]" : "[]"
|
|
2157
|
+
);
|
|
2158
|
+
for (const entry of ctx.options.entries.filter(
|
|
2159
|
+
(entry2) => entry2.builder === "rollup"
|
|
2160
|
+
)) {
|
|
2161
|
+
const output = (0, import_pathe.resolve)(
|
|
2162
|
+
ctx.options.rootDir,
|
|
2163
|
+
ctx.options.outDir,
|
|
2164
|
+
entry.name
|
|
2165
|
+
);
|
|
2166
|
+
const isESM = ctx.pkg.type === "module";
|
|
2167
|
+
const resolvedEntry = (0, import_mlly.fileURLToPath)(ctx.jiti.esmResolve(entry.input));
|
|
2168
|
+
const resolvedEntryWithoutExt = resolvedEntry.slice(
|
|
2169
|
+
0,
|
|
2170
|
+
Math.max(0, resolvedEntry.length - (0, import_pathe.extname)(resolvedEntry).length)
|
|
2171
|
+
);
|
|
2172
|
+
const resolvedEntryForTypeImport = isESM ? `${resolvedEntry.replace(/(\.m?)(ts)$/, "$1js")}` : resolvedEntryWithoutExt;
|
|
2173
|
+
const code = await import_node_fs6.promises.readFile(resolvedEntry, "utf8");
|
|
2174
|
+
const shebang = getShebang(code);
|
|
2175
|
+
await (0, import_promises4.mkdir)((0, import_pathe.dirname)(output), { recursive: true });
|
|
2176
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2177
|
+
const jitiCJSPath = (0, import_pathe.relative)(
|
|
2178
|
+
(0, import_pathe.dirname)(output),
|
|
2179
|
+
await (0, import_mlly.resolvePath)("jiti", {
|
|
2180
|
+
url: importMetaUrl,
|
|
2181
|
+
conditions: ["node", "require"]
|
|
2182
|
+
})
|
|
2183
|
+
);
|
|
2184
|
+
await (0, import_promises4.writeFile)(
|
|
2185
|
+
output + ".cjs",
|
|
2186
|
+
shebang + [
|
|
2187
|
+
`const { createJiti } = require(${JSON.stringify(jitiCJSPath)})`,
|
|
2188
|
+
...importedBabelPlugins.map(
|
|
2189
|
+
(plugin, i) => `const plugin${i} = require(${JSON.stringify(plugin)})`
|
|
2190
|
+
),
|
|
2191
|
+
"",
|
|
2192
|
+
`const jiti = createJiti(__filename, ${serializedJitiOptions})`,
|
|
2193
|
+
"",
|
|
2194
|
+
`/** @type {import(${JSON.stringify(
|
|
2195
|
+
resolvedEntryForTypeImport
|
|
2196
|
+
)})} */`,
|
|
2197
|
+
`module.exports = jiti(${JSON.stringify(resolvedEntry)})`
|
|
2198
|
+
].join("\n")
|
|
2199
|
+
);
|
|
2200
|
+
}
|
|
2201
|
+
const namedExports = await (0, import_mlly.resolveModuleExportNames)(
|
|
2202
|
+
resolvedEntry,
|
|
2203
|
+
{
|
|
2204
|
+
extensions: DEFAULT_EXTENSIONS
|
|
2205
|
+
}
|
|
2206
|
+
).catch((error) => {
|
|
2207
|
+
warn(ctx, `Cannot analyze ${resolvedEntry} for exports:` + error);
|
|
2208
|
+
return [];
|
|
2209
|
+
});
|
|
2210
|
+
const hasDefaultExport = namedExports.includes("default") || namedExports.length === 0;
|
|
2211
|
+
const jitiESMPath = (0, import_pathe.relative)(
|
|
2212
|
+
(0, import_pathe.dirname)(output),
|
|
2213
|
+
await (0, import_mlly.resolvePath)("jiti", {
|
|
2214
|
+
url: importMetaUrl,
|
|
2215
|
+
conditions: ["node", "import"]
|
|
2216
|
+
})
|
|
2217
|
+
);
|
|
2218
|
+
await (0, import_promises4.writeFile)(
|
|
2219
|
+
output + ".mjs",
|
|
2220
|
+
shebang + [
|
|
2221
|
+
`import { createJiti } from ${JSON.stringify(jitiESMPath)};`,
|
|
2222
|
+
...importedBabelPlugins.map(
|
|
2223
|
+
(plugin, i) => `import plugin${i} from ${JSON.stringify(plugin)}`
|
|
2224
|
+
),
|
|
2225
|
+
"",
|
|
2226
|
+
`const jiti = createJiti(import.meta.url, ${serializedJitiOptions})`,
|
|
2227
|
+
"",
|
|
2228
|
+
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
2229
|
+
`const _module = await jiti.import(${JSON.stringify(
|
|
2230
|
+
resolvedEntry
|
|
2231
|
+
)});`,
|
|
2232
|
+
hasDefaultExport ? "\nexport default _module?.default ?? _module;" : "",
|
|
2233
|
+
...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)
|
|
2234
|
+
].join("\n")
|
|
2235
|
+
);
|
|
2236
|
+
if (ctx.options.declaration) {
|
|
2237
|
+
const dtsContent = [
|
|
2238
|
+
`export * from ${JSON.stringify(resolvedEntryForTypeImport)};`,
|
|
2239
|
+
hasDefaultExport ? `export { default } from ${JSON.stringify(resolvedEntryForTypeImport)};` : ""
|
|
2240
|
+
].join("\n");
|
|
2241
|
+
await (0, import_promises4.writeFile)(output + ".d.cts", dtsContent);
|
|
2242
|
+
await (0, import_promises4.writeFile)(output + ".d.mts", dtsContent);
|
|
2243
|
+
if (ctx.options.declaration === "compatible" || ctx.options.declaration === true) {
|
|
2244
|
+
await (0, import_promises4.writeFile)(output + ".d.ts", dtsContent);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
if (shebang) {
|
|
2248
|
+
await makeExecutable(output + ".cjs");
|
|
2249
|
+
await makeExecutable(output + ".mjs");
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
__name(rollupStub, "rollupStub");
|
|
2254
|
+
function rollupWatch(rollupOptions) {
|
|
2255
|
+
const watcher = (0, import_rollup.watch)(rollupOptions);
|
|
2256
|
+
let inputs;
|
|
2257
|
+
if (Array.isArray(rollupOptions.input)) {
|
|
2258
|
+
inputs = rollupOptions.input;
|
|
2259
|
+
} else if (typeof rollupOptions.input === "string") {
|
|
2260
|
+
inputs = [rollupOptions.input];
|
|
2261
|
+
} else {
|
|
2262
|
+
inputs = Object.keys(rollupOptions.input || {});
|
|
2263
|
+
}
|
|
2264
|
+
import_consola.default.info(
|
|
2265
|
+
`[unbuild] [rollup] Starting watchers for entries: ${inputs.map((input) => "./" + (0, import_pathe.relative)(process.cwd(), input)).join(", ")}`
|
|
2266
|
+
);
|
|
2267
|
+
import_consola.default.warn(
|
|
2268
|
+
"[unbuild] [rollup] Watch mode is experimental and may be unstable"
|
|
2269
|
+
);
|
|
2270
|
+
watcher.on("change", (id, { event }) => {
|
|
2271
|
+
import_consola.default.info(`${import_utils.colors.cyan((0, import_pathe.relative)(".", id))} was ${event}d`);
|
|
2272
|
+
});
|
|
2273
|
+
watcher.on("restart", () => {
|
|
2274
|
+
import_consola.default.info(import_utils.colors.gray("[unbuild] [rollup] Rebuilding bundle"));
|
|
2275
|
+
});
|
|
2276
|
+
watcher.on("event", (event) => {
|
|
2277
|
+
if (event.code === "END") {
|
|
2278
|
+
import_consola.default.success(import_utils.colors.green("[unbuild] [rollup] Rebuild finished\n"));
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
__name(rollupWatch, "rollupWatch");
|
|
2283
|
+
async function rollupBuild(ctx) {
|
|
2284
|
+
if (ctx.options.stub) {
|
|
2285
|
+
await rollupStub(ctx);
|
|
2286
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2289
|
+
const rollupOptions = getRollupOptions(ctx);
|
|
2290
|
+
await ctx.hooks.callHook("rollup:options", ctx, rollupOptions);
|
|
2291
|
+
if (Object.keys(rollupOptions.input).length === 0) {
|
|
2292
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
const buildResult = await (0, import_rollup.rollup)(rollupOptions);
|
|
2296
|
+
await ctx.hooks.callHook("rollup:build", ctx, buildResult);
|
|
2297
|
+
const allOutputOptions = rollupOptions.output;
|
|
2298
|
+
for (const outputOptions of allOutputOptions) {
|
|
2299
|
+
const { output } = await buildResult.write(outputOptions);
|
|
2300
|
+
const chunkFileNames = /* @__PURE__ */ new Set();
|
|
2301
|
+
const outputChunks = output.filter(
|
|
2302
|
+
(e) => e.type === "chunk"
|
|
2303
|
+
);
|
|
2304
|
+
for (const entry of outputChunks) {
|
|
2305
|
+
chunkFileNames.add(entry.fileName);
|
|
2306
|
+
for (const id of entry.imports) {
|
|
2307
|
+
ctx.usedImports.add(id);
|
|
2308
|
+
}
|
|
2309
|
+
if (entry.isEntry) {
|
|
2310
|
+
ctx.buildEntries.push({
|
|
2311
|
+
chunks: entry.imports.filter(
|
|
2312
|
+
(i) => outputChunks.find((c) => c.fileName === i)
|
|
2313
|
+
),
|
|
2314
|
+
modules: Object.entries(entry.modules).map(([id, mod]) => ({
|
|
2315
|
+
id,
|
|
2316
|
+
bytes: mod.renderedLength
|
|
2317
|
+
})),
|
|
2318
|
+
path: entry.fileName,
|
|
2319
|
+
bytes: Buffer.byteLength(entry.code, "utf8"),
|
|
2320
|
+
exports: entry.exports
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
for (const chunkFileName of chunkFileNames) {
|
|
2325
|
+
ctx.usedImports.delete(chunkFileName);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
if (ctx.options.watch) {
|
|
2329
|
+
rollupWatch(rollupOptions);
|
|
2330
|
+
if (ctx.options.declaration && ctx.options.watch) {
|
|
2331
|
+
import_consola.default.warn("`rollup` DTS builder does not support watch mode yet.");
|
|
2332
|
+
}
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2335
|
+
if (ctx.options.declaration) {
|
|
2336
|
+
rollupOptions.plugins = [
|
|
2337
|
+
...rollupOptions.plugins,
|
|
2338
|
+
(0, import_rollup_plugin_dts.default)(ctx.options.rollup.dts),
|
|
2339
|
+
removeShebangPlugin(),
|
|
2340
|
+
ctx.options.rollup.emitCJS && fixCJSExportTypePlugin()
|
|
2341
|
+
].filter(Boolean);
|
|
2342
|
+
await ctx.hooks.callHook("rollup:dts:options", ctx, rollupOptions);
|
|
2343
|
+
const typesBuild2 = await (0, import_rollup.rollup)(rollupOptions);
|
|
2344
|
+
await ctx.hooks.callHook("rollup:dts:build", ctx, typesBuild2);
|
|
2345
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2346
|
+
await typesBuild2.write({
|
|
2347
|
+
dir: (0, import_pathe.resolve)(ctx.options.rootDir, ctx.options.outDir),
|
|
2348
|
+
entryFileNames: "[name].d.cts",
|
|
2349
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.cts"), "chunkFileNames")
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
await typesBuild2.write({
|
|
2353
|
+
dir: (0, import_pathe.resolve)(ctx.options.rootDir, ctx.options.outDir),
|
|
2354
|
+
entryFileNames: "[name].d.mts",
|
|
2355
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.mts"), "chunkFileNames")
|
|
2356
|
+
});
|
|
2357
|
+
if (ctx.options.declaration === true || ctx.options.declaration === "compatible") {
|
|
2358
|
+
await typesBuild2.write({
|
|
2359
|
+
dir: (0, import_pathe.resolve)(ctx.options.rootDir, ctx.options.outDir),
|
|
2360
|
+
entryFileNames: "[name].d.ts",
|
|
2361
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.ts"), "chunkFileNames")
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2366
|
+
}
|
|
2367
|
+
__name(rollupBuild, "rollupBuild");
|
|
2368
|
+
async function typesBuild(ctx) {
|
|
2369
|
+
const entries = ctx.options.entries.filter(
|
|
2370
|
+
(entry) => entry.builder === "untyped"
|
|
2371
|
+
);
|
|
2372
|
+
await ctx.hooks.callHook("untyped:entries", ctx, entries);
|
|
2373
|
+
for (const entry of entries) {
|
|
2374
|
+
const options = {
|
|
2375
|
+
jiti: {
|
|
2376
|
+
interopDefault: true,
|
|
2377
|
+
transformOptions: {
|
|
2378
|
+
babel: {
|
|
2379
|
+
plugins: [import_babel_plugin.default]
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
};
|
|
2384
|
+
await ctx.hooks.callHook("untyped:entry:options", ctx, entry, options);
|
|
2385
|
+
const untypedJiti = (0, import_jiti.createJiti)(ctx.options.rootDir, options.jiti);
|
|
2386
|
+
const distDir = entry.outDir;
|
|
2387
|
+
let rawSchema = await untypedJiti.import((0, import_pathe.resolve)(ctx.options.rootDir, entry.input), {
|
|
2388
|
+
try: true
|
|
2389
|
+
}) || {};
|
|
2390
|
+
const rawSchemaKeys = Object.keys(rawSchema);
|
|
2391
|
+
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
|
|
2392
|
+
rawSchema = rawSchema.default;
|
|
2393
|
+
}
|
|
2394
|
+
const defaults2 = entry.defaults || {};
|
|
2395
|
+
const schema = await (0, import_untyped.resolveSchema)(rawSchema, defaults2);
|
|
2396
|
+
await ctx.hooks.callHook("untyped:entry:schema", ctx, entry, schema);
|
|
2397
|
+
const outputs = {
|
|
2398
|
+
markdown: {
|
|
2399
|
+
fileName: (0, import_pathe.resolve)(distDir, `${entry.name}.md`),
|
|
2400
|
+
contents: (0, import_untyped.generateMarkdown)(schema)
|
|
2401
|
+
},
|
|
2402
|
+
schema: {
|
|
2403
|
+
fileName: `${entry.name}.schema.json`,
|
|
2404
|
+
contents: JSON.stringify(schema, null, 2)
|
|
2405
|
+
},
|
|
2406
|
+
defaults: {
|
|
2407
|
+
fileName: `${entry.name}.defaults.json`,
|
|
2408
|
+
contents: JSON.stringify(defaults2, null, 2)
|
|
2409
|
+
},
|
|
2410
|
+
declaration: entry.declaration ? {
|
|
2411
|
+
fileName: `${entry.name}.d.ts`,
|
|
2412
|
+
contents: (0, import_untyped.generateTypes)(schema, {
|
|
2413
|
+
interfaceName: (0, import_scule.pascalCase)(entry.name + "-schema")
|
|
2414
|
+
})
|
|
2415
|
+
} : void 0
|
|
2416
|
+
};
|
|
2417
|
+
await ctx.hooks.callHook("untyped:entry:outputs", ctx, entry, outputs);
|
|
2418
|
+
for (const output of Object.values(outputs)) {
|
|
2419
|
+
if (!output) continue;
|
|
2420
|
+
await (0, import_promises4.writeFile)(
|
|
2421
|
+
(0, import_pathe.resolve)(distDir, output.fileName),
|
|
2422
|
+
output.contents,
|
|
2423
|
+
"utf8"
|
|
2424
|
+
);
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
await ctx.hooks.callHook("untyped:done", ctx);
|
|
2428
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2429
|
+
import_consola.default.warn("`untyped` builder does not support watch mode yet.");
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
__name(typesBuild, "typesBuild");
|
|
2433
|
+
async function mkdistBuild(ctx) {
|
|
2434
|
+
const entries = ctx.options.entries.filter(
|
|
2435
|
+
(e) => e.builder === "mkdist"
|
|
2436
|
+
);
|
|
2437
|
+
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
2438
|
+
for (const entry of entries) {
|
|
2439
|
+
const distDir = entry.outDir;
|
|
2440
|
+
if (ctx.options.stub) {
|
|
2441
|
+
await rmdir(distDir);
|
|
2442
|
+
await symlink(entry.input, distDir);
|
|
2443
|
+
} else {
|
|
2444
|
+
const mkdistOptions = {
|
|
2445
|
+
rootDir: ctx.options.rootDir,
|
|
2446
|
+
srcDir: entry.input,
|
|
2447
|
+
distDir,
|
|
2448
|
+
cleanDist: false,
|
|
2449
|
+
...entry
|
|
2450
|
+
};
|
|
2451
|
+
await ctx.hooks.callHook(
|
|
2452
|
+
"mkdist:entry:options",
|
|
2453
|
+
ctx,
|
|
2454
|
+
entry,
|
|
2455
|
+
mkdistOptions
|
|
2456
|
+
);
|
|
2457
|
+
const output = await (0, import_mkdist.mkdist)(mkdistOptions);
|
|
2458
|
+
ctx.buildEntries.push({
|
|
2459
|
+
path: distDir,
|
|
2460
|
+
chunks: output.writtenFiles.map((p) => (0, import_pathe.relative)(ctx.options.outDir, p))
|
|
2461
|
+
});
|
|
2462
|
+
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
2463
|
+
if (output.errors) {
|
|
2464
|
+
for (const error of output.errors) {
|
|
2465
|
+
warn(
|
|
2466
|
+
ctx,
|
|
2467
|
+
`mkdist build failed for \`${(0, import_pathe.relative)(ctx.options.rootDir, error.filename)}\`:
|
|
2468
|
+
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
2469
|
+
);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
2475
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2476
|
+
import_consola.default.warn("`mkdist` builder does not support watch mode yet.");
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
__name(mkdistBuild, "mkdistBuild");
|
|
2480
|
+
var copy = import_node_fs6.promises.cp || import_node_fs6.promises.copyFile;
|
|
2481
|
+
async function copyBuild(ctx) {
|
|
2482
|
+
const entries = ctx.options.entries.filter(
|
|
2483
|
+
(e) => e.builder === "copy"
|
|
2484
|
+
);
|
|
2485
|
+
await ctx.hooks.callHook("copy:entries", ctx, entries);
|
|
2486
|
+
for (const entry of entries) {
|
|
2487
|
+
const distDir = entry.outDir;
|
|
2488
|
+
if (ctx.options.stub) {
|
|
2489
|
+
await rmdir(distDir);
|
|
2490
|
+
await symlink(entry.input, distDir);
|
|
2491
|
+
} else {
|
|
2492
|
+
const patterns = Array.isArray(entry.pattern) ? entry.pattern : [entry.pattern || "**"];
|
|
2493
|
+
const paths = await (0, import_tinyglobby.glob)(patterns, {
|
|
2494
|
+
cwd: (0, import_pathe.resolve)(ctx.options.rootDir, entry.input),
|
|
2495
|
+
absolute: false
|
|
2496
|
+
});
|
|
2497
|
+
const outputList = await Promise.allSettled(
|
|
2498
|
+
paths.map(async (path3) => {
|
|
2499
|
+
const src = (0, import_pathe.resolve)(ctx.options.rootDir, entry.input, path3);
|
|
2500
|
+
const dist = (0, import_pathe.resolve)(ctx.options.rootDir, distDir, path3);
|
|
2501
|
+
await copy(src, dist);
|
|
2502
|
+
return dist;
|
|
2503
|
+
})
|
|
2504
|
+
);
|
|
2505
|
+
for (const output of outputList) {
|
|
2506
|
+
if (output.status === "rejected") {
|
|
2507
|
+
warn(ctx, output.reason);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
ctx.buildEntries.push({
|
|
2511
|
+
path: distDir,
|
|
2512
|
+
chunks: outputList.filter(({ status }) => status === "fulfilled").map(
|
|
2513
|
+
(p) => (0, import_pathe.relative)(
|
|
2514
|
+
ctx.options.outDir,
|
|
2515
|
+
p.value
|
|
2516
|
+
)
|
|
2517
|
+
)
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
await ctx.hooks.callHook("copy:done", ctx);
|
|
2522
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2523
|
+
import_consola.default.warn("`untyped` builder does not support watch mode yet.");
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
__name(copyBuild, "copyBuild");
|
|
2527
|
+
async function build(rootDir, stub, inputConfig = {}) {
|
|
2528
|
+
rootDir = (0, import_pathe.resolve)(process.cwd(), rootDir || ".");
|
|
2529
|
+
const jiti = (0, import_jiti.createJiti)(rootDir);
|
|
2530
|
+
const _buildConfig = await jiti.import(inputConfig?.config || "./build.config", {
|
|
2531
|
+
try: !inputConfig.config,
|
|
2532
|
+
default: true
|
|
2533
|
+
}) || {};
|
|
2534
|
+
const buildConfigs = (Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]).filter(Boolean);
|
|
2535
|
+
const pkg = await jiti.import("./package.json", {
|
|
2536
|
+
try: true,
|
|
2537
|
+
default: true
|
|
2538
|
+
}) || {};
|
|
2539
|
+
const cleanedDirs = [];
|
|
2540
|
+
const _watchMode = inputConfig.watch === true;
|
|
2541
|
+
const _stubMode = !_watchMode && (stub || inputConfig.stub === true);
|
|
2542
|
+
for (const buildConfig of buildConfigs) {
|
|
2543
|
+
await _build(
|
|
2544
|
+
rootDir,
|
|
2545
|
+
inputConfig,
|
|
2546
|
+
buildConfig,
|
|
2547
|
+
pkg,
|
|
2548
|
+
cleanedDirs,
|
|
2549
|
+
_stubMode,
|
|
2550
|
+
_watchMode
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
__name(build, "build");
|
|
2555
|
+
async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs, _stubMode, _watchMode) {
|
|
2556
|
+
const preset = await resolvePreset(
|
|
2557
|
+
buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || inputConfig.preset || "auto",
|
|
2558
|
+
rootDir
|
|
2559
|
+
);
|
|
2560
|
+
const options = (0, import_defu3.defu)(
|
|
2561
|
+
buildConfig,
|
|
2562
|
+
pkg.unbuild || pkg.build,
|
|
2563
|
+
inputConfig,
|
|
2564
|
+
preset,
|
|
2565
|
+
{
|
|
2566
|
+
name: (pkg?.name || "").split("/").pop() || "default",
|
|
2567
|
+
rootDir,
|
|
2568
|
+
entries: [],
|
|
2569
|
+
clean: true,
|
|
2570
|
+
declaration: void 0,
|
|
2571
|
+
outDir: "dist",
|
|
2572
|
+
stub: _stubMode,
|
|
2573
|
+
stubOptions: {
|
|
2574
|
+
/**
|
|
2575
|
+
* See https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
2576
|
+
*/
|
|
2577
|
+
jiti: {
|
|
2578
|
+
interopDefault: true,
|
|
2579
|
+
alias: {}
|
|
2580
|
+
}
|
|
2581
|
+
},
|
|
2582
|
+
watch: _watchMode,
|
|
2583
|
+
watchOptions: _watchMode ? {
|
|
2584
|
+
exclude: "node_modules/**",
|
|
2585
|
+
include: "src/**"
|
|
2586
|
+
} : void 0,
|
|
2587
|
+
externals: [
|
|
2588
|
+
...import_node_module2.default.builtinModules,
|
|
2589
|
+
...import_node_module2.default.builtinModules.map((m) => "node:" + m)
|
|
2590
|
+
],
|
|
2591
|
+
dependencies: [],
|
|
2592
|
+
devDependencies: [],
|
|
2593
|
+
peerDependencies: [],
|
|
2594
|
+
alias: {},
|
|
2595
|
+
replace: {},
|
|
2596
|
+
failOnWarn: true,
|
|
2597
|
+
sourcemap: false,
|
|
2598
|
+
rollup: {
|
|
2599
|
+
emitCJS: false,
|
|
2600
|
+
watch: false,
|
|
2601
|
+
cjsBridge: false,
|
|
2602
|
+
inlineDependencies: false,
|
|
2603
|
+
preserveDynamicImports: true,
|
|
2604
|
+
output: {
|
|
2605
|
+
// https://v8.dev/features/import-attributes
|
|
2606
|
+
importAttributesKey: "with"
|
|
2607
|
+
},
|
|
2608
|
+
// Plugins
|
|
2609
|
+
replace: {
|
|
2610
|
+
preventAssignment: true
|
|
2611
|
+
},
|
|
2612
|
+
alias: {},
|
|
2613
|
+
resolve: {
|
|
2614
|
+
preferBuiltins: true
|
|
2615
|
+
},
|
|
2616
|
+
json: {
|
|
2617
|
+
preferConst: true
|
|
2618
|
+
},
|
|
2619
|
+
commonjs: {
|
|
2620
|
+
ignoreTryCatch: true
|
|
2621
|
+
},
|
|
2622
|
+
esbuild: { target: "esnext" },
|
|
2623
|
+
dts: {
|
|
2624
|
+
// https://github.com/Swatinem/rollup-plugin-dts/issues/143
|
|
2625
|
+
compilerOptions: { preserveSymlinks: false },
|
|
2626
|
+
respectExternal: true
|
|
2627
|
+
}
|
|
2628
|
+
},
|
|
2629
|
+
parallel: false
|
|
2630
|
+
}
|
|
2631
|
+
);
|
|
2632
|
+
options.outDir = (0, import_pathe.resolve)(options.rootDir, options.outDir);
|
|
2633
|
+
const jiti = (0, import_jiti.createJiti)(options.rootDir, { interopDefault: true });
|
|
2634
|
+
const ctx = {
|
|
2635
|
+
options,
|
|
2636
|
+
jiti,
|
|
2637
|
+
warnings: /* @__PURE__ */ new Set(),
|
|
2638
|
+
pkg,
|
|
2639
|
+
buildEntries: [],
|
|
2640
|
+
usedImports: /* @__PURE__ */ new Set(),
|
|
2641
|
+
hooks: (0, import_hookable.createHooks)()
|
|
2642
|
+
};
|
|
2643
|
+
if (preset.hooks) {
|
|
2644
|
+
ctx.hooks.addHooks(preset.hooks);
|
|
2645
|
+
}
|
|
2646
|
+
if (inputConfig.hooks) {
|
|
2647
|
+
ctx.hooks.addHooks(inputConfig.hooks);
|
|
2648
|
+
}
|
|
2649
|
+
if (buildConfig.hooks) {
|
|
2650
|
+
ctx.hooks.addHooks(buildConfig.hooks);
|
|
2651
|
+
}
|
|
2652
|
+
await ctx.hooks.callHook("build:prepare", ctx);
|
|
2653
|
+
options.entries = options.entries.map(
|
|
2654
|
+
(entry) => typeof entry === "string" ? { input: entry } : entry
|
|
2655
|
+
);
|
|
2656
|
+
for (const entry of options.entries) {
|
|
2657
|
+
if (typeof entry.name !== "string") {
|
|
2658
|
+
let relativeInput = (0, import_pathe.isAbsolute)(entry.input) ? (0, import_pathe.relative)(rootDir, entry.input) : (0, import_pathe.normalize)(entry.input);
|
|
2659
|
+
if (relativeInput.startsWith("./")) {
|
|
2660
|
+
relativeInput = relativeInput.slice(2);
|
|
2661
|
+
}
|
|
2662
|
+
entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
|
|
2663
|
+
}
|
|
2664
|
+
if (!entry.input) {
|
|
2665
|
+
throw new Error("Missing entry input: " + dumpObject(entry));
|
|
2666
|
+
}
|
|
2667
|
+
if (!entry.builder) {
|
|
2668
|
+
entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
|
|
2669
|
+
}
|
|
2670
|
+
if (options.declaration !== void 0 && entry.declaration === void 0) {
|
|
2671
|
+
entry.declaration = options.declaration;
|
|
2672
|
+
}
|
|
2673
|
+
entry.input = (0, import_pathe.resolve)(options.rootDir, entry.input);
|
|
2674
|
+
entry.outDir = (0, import_pathe.resolve)(options.rootDir, entry.outDir || options.outDir);
|
|
2675
|
+
}
|
|
2676
|
+
options.dependencies = Object.keys(pkg.dependencies || {});
|
|
2677
|
+
options.peerDependencies = Object.keys(pkg.peerDependencies || {});
|
|
2678
|
+
options.devDependencies = Object.keys(pkg.devDependencies || {});
|
|
2679
|
+
options.externals.push(...inferPkgExternals(pkg));
|
|
2680
|
+
options.externals = [...new Set(options.externals)];
|
|
2681
|
+
await ctx.hooks.callHook("build:before", ctx);
|
|
2682
|
+
import_consola.consola.info(
|
|
2683
|
+
import_utils.colors.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`)
|
|
2684
|
+
);
|
|
2685
|
+
if (process.env.DEBUG) {
|
|
2686
|
+
import_consola.consola.info(`${import_utils.colors.bold("Root dir:")} ${options.rootDir}
|
|
2687
|
+
${import_utils.colors.bold("Entries:")}
|
|
2688
|
+
${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")}
|
|
2689
|
+
`);
|
|
2690
|
+
}
|
|
2691
|
+
if (options.clean) {
|
|
2692
|
+
for (const dir of new Set(
|
|
2693
|
+
options.entries.map((e) => e.outDir).filter(Boolean).sort()
|
|
2694
|
+
)) {
|
|
2695
|
+
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
2696
|
+
continue;
|
|
2697
|
+
}
|
|
2698
|
+
cleanedDirs.push(dir);
|
|
2699
|
+
import_consola.consola.info(
|
|
2700
|
+
`Cleaning dist directory: \`./${(0, import_pathe.relative)(process.cwd(), dir)}\``
|
|
2701
|
+
);
|
|
2702
|
+
await rmdir(dir);
|
|
2703
|
+
await import_node_fs6.promises.mkdir(dir, { recursive: true });
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
const buildTasks = [
|
|
2707
|
+
typesBuild,
|
|
2708
|
+
// untyped
|
|
2709
|
+
mkdistBuild,
|
|
2710
|
+
// mkdist
|
|
2711
|
+
rollupBuild,
|
|
2712
|
+
// rollup
|
|
2713
|
+
copyBuild
|
|
2714
|
+
// copy
|
|
2715
|
+
];
|
|
2716
|
+
if (options.parallel) {
|
|
2717
|
+
await Promise.all(buildTasks.map((task) => task(ctx)));
|
|
2718
|
+
} else {
|
|
2719
|
+
for (const task of buildTasks) {
|
|
2720
|
+
await task(ctx);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
if (options.stub || options.watch) {
|
|
2724
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2725
|
+
return;
|
|
2726
|
+
}
|
|
2727
|
+
import_consola.consola.success(import_utils.colors.green("Build succeeded for " + options.name));
|
|
2728
|
+
const outFiles = await (0, import_tinyglobby.glob)(["**"], { cwd: options.outDir });
|
|
2729
|
+
for (const file of outFiles) {
|
|
2730
|
+
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
2731
|
+
if (!entry) {
|
|
2732
|
+
entry = {
|
|
2733
|
+
path: file,
|
|
2734
|
+
chunk: true
|
|
2735
|
+
};
|
|
2736
|
+
ctx.buildEntries.push(entry);
|
|
2737
|
+
}
|
|
2738
|
+
if (!entry.bytes) {
|
|
2739
|
+
const stat = await import_node_fs6.promises.stat((0, import_pathe.resolve)(options.outDir, file));
|
|
2740
|
+
entry.bytes = stat.size;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
const rPath = /* @__PURE__ */ __name((p) => (0, import_pathe.relative)(process.cwd(), (0, import_pathe.resolve)(options.outDir, p)), "rPath");
|
|
2744
|
+
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
2745
|
+
let totalBytes = entry.bytes || 0;
|
|
2746
|
+
for (const chunk of entry.chunks || []) {
|
|
2747
|
+
totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
|
|
2748
|
+
}
|
|
2749
|
+
let line = ` ${import_utils.colors.bold(rPath(entry.path))} (` + [
|
|
2750
|
+
totalBytes && `total size: ${import_utils.colors.cyan((0, import_pretty_bytes.default)(totalBytes))}`,
|
|
2751
|
+
entry.bytes && `chunk size: ${import_utils.colors.cyan((0, import_pretty_bytes.default)(entry.bytes))}`,
|
|
2752
|
+
entry.exports?.length && `exports: ${import_utils.colors.gray(entry.exports.join(", "))}`
|
|
2753
|
+
].filter(Boolean).join(", ") + ")";
|
|
2754
|
+
if (entry.chunks?.length) {
|
|
2755
|
+
line += "\n" + entry.chunks.map((p) => {
|
|
2756
|
+
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
2757
|
+
return import_utils.colors.gray(
|
|
2758
|
+
" \u2514\u2500 " + rPath(p) + import_utils.colors.bold(
|
|
2759
|
+
chunk.bytes ? ` (${(0, import_pretty_bytes.default)(chunk?.bytes)})` : ""
|
|
2760
|
+
)
|
|
2761
|
+
);
|
|
2762
|
+
}).join("\n");
|
|
2763
|
+
}
|
|
2764
|
+
if (entry.modules?.length) {
|
|
2765
|
+
line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
2766
|
+
return import_utils.colors.gray(
|
|
2767
|
+
" \u{1F4E6} " + rPath(m.id) + import_utils.colors.bold(m.bytes ? ` (${(0, import_pretty_bytes.default)(m.bytes)})` : "")
|
|
2768
|
+
);
|
|
2769
|
+
}).join("\n");
|
|
2770
|
+
}
|
|
2771
|
+
import_consola.consola.log(entry.chunk ? import_utils.colors.gray(line) : line);
|
|
2772
|
+
}
|
|
2773
|
+
console.log(
|
|
2774
|
+
"\u03A3 Total dist size (byte size):",
|
|
2775
|
+
import_utils.colors.cyan(
|
|
2776
|
+
(0, import_pretty_bytes.default)(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))
|
|
2777
|
+
)
|
|
2778
|
+
);
|
|
2779
|
+
validateDependencies(ctx);
|
|
2780
|
+
validatePackage(pkg, rootDir, ctx);
|
|
2781
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2782
|
+
import_consola.consola.log("");
|
|
2783
|
+
if (ctx.warnings.size > 0) {
|
|
2784
|
+
import_consola.consola.warn(
|
|
2785
|
+
"Build is done with some warnings:\n\n" + [...ctx.warnings].map((msg) => "- " + msg).join("\n")
|
|
2786
|
+
);
|
|
2787
|
+
if (ctx.options.failOnWarn) {
|
|
2788
|
+
import_consola.consola.error(
|
|
2789
|
+
"Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ."
|
|
2790
|
+
);
|
|
2791
|
+
process.exit(1);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
__name(_build, "_build");
|
|
2796
|
+
|
|
2797
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/index.mjs
|
|
2798
|
+
var import_node_module3 = require("module");
|
|
2799
|
+
var import_node_fs7 = require("fs");
|
|
2800
|
+
var import_pathe2 = require("pathe");
|
|
2801
|
+
var import_utils3 = require("consola/utils");
|
|
2802
|
+
var import_consola2 = require("consola");
|
|
2803
|
+
var import_defu4 = require("defu");
|
|
2804
|
+
var import_hookable2 = require("hookable");
|
|
2805
|
+
var import_pretty_bytes2 = require("pretty-bytes");
|
|
2806
|
+
var import_tinyglobby2 = require("tinyglobby");
|
|
2807
|
+
var import_promises5 = require("fs/promises");
|
|
2808
|
+
var import_jiti2 = require("jiti");
|
|
2809
|
+
var import_rollup2 = require("rollup");
|
|
2810
|
+
var import_rollup_plugin_dts2 = require("rollup-plugin-dts");
|
|
2811
|
+
var import_plugin_commonjs2 = require("@rollup/plugin-commonjs");
|
|
2812
|
+
var import_plugin_node_resolve2 = require("@rollup/plugin-node-resolve");
|
|
2813
|
+
var import_plugin_alias2 = require("@rollup/plugin-alias");
|
|
2814
|
+
var import_plugin_replace2 = require("@rollup/plugin-replace");
|
|
2815
|
+
var import_utils4 = require("pathe/utils");
|
|
2816
|
+
var import_mlly2 = require("mlly");
|
|
2817
|
+
var import_esbuild2 = require("esbuild");
|
|
2818
|
+
var import_pluginutils2 = require("@rollup/pluginutils");
|
|
2819
|
+
var import_plugin_json2 = require("@rollup/plugin-json");
|
|
2820
|
+
var import_magic_string2 = require("magic-string");
|
|
2821
|
+
var import_untyped2 = require("untyped");
|
|
2822
|
+
var import_babel_plugin2 = require("untyped/babel-plugin");
|
|
2823
|
+
var import_scule2 = require("scule");
|
|
2824
|
+
var import_mkdist2 = require("mkdist");
|
|
1391
2825
|
|
|
1392
2826
|
// src/clean.ts
|
|
1393
|
-
var
|
|
2827
|
+
var import_promises6 = require("fs/promises");
|
|
1394
2828
|
async function clean(name = "Unbuild", directory, config) {
|
|
1395
2829
|
writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
1396
2830
|
const stopwatch = getStopwatch(`${name} output clean`);
|
|
1397
|
-
await (0,
|
|
2831
|
+
await (0, import_promises6.rm)(directory, {
|
|
1398
2832
|
recursive: true,
|
|
1399
2833
|
force: true
|
|
1400
2834
|
});
|
|
@@ -1456,7 +2890,7 @@ var import_compiler_helper_dependency = require("@nx/js/src/utils/compiler-helpe
|
|
|
1456
2890
|
// ../../node_modules/.pnpm/rollup-plugin-typescript2@0.36.0_rollup@4.29.1_typescript@5.7.3/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.es.js
|
|
1457
2891
|
var require$$0 = __toESM(require("path"));
|
|
1458
2892
|
var import_path2 = __toESM(require("path"));
|
|
1459
|
-
var
|
|
2893
|
+
var import_pluginutils3 = require("@rollup/pluginutils");
|
|
1460
2894
|
var import_util = __toESM(require("util"));
|
|
1461
2895
|
var import_os = __toESM(require("os"));
|
|
1462
2896
|
var import_semver = __toESM(require("semver"));
|
|
@@ -1466,12 +2900,12 @@ var import_fs_extra = require("fs-extra");
|
|
|
1466
2900
|
var import_crypto = __toESM(require("crypto"));
|
|
1467
2901
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1468
2902
|
function adopt(value) {
|
|
1469
|
-
return value instanceof P ? value : new P(function(
|
|
1470
|
-
|
|
2903
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
2904
|
+
resolve3(value);
|
|
1471
2905
|
});
|
|
1472
2906
|
}
|
|
1473
2907
|
__name(adopt, "adopt");
|
|
1474
|
-
return new (P || (P = Promise))(function(
|
|
2908
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1475
2909
|
function fulfilled(value) {
|
|
1476
2910
|
try {
|
|
1477
2911
|
step(generator.next(value));
|
|
@@ -1489,7 +2923,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
1489
2923
|
}
|
|
1490
2924
|
__name(rejected, "rejected");
|
|
1491
2925
|
function step(result) {
|
|
1492
|
-
result.done ?
|
|
2926
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1493
2927
|
}
|
|
1494
2928
|
__name(step, "step");
|
|
1495
2929
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -1500,7 +2934,7 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
|
|
|
1500
2934
|
var safe = {
|
|
1501
2935
|
exports: {}
|
|
1502
2936
|
};
|
|
1503
|
-
var
|
|
2937
|
+
var colors2 = {
|
|
1504
2938
|
exports: {}
|
|
1505
2939
|
};
|
|
1506
2940
|
var styles = {
|
|
@@ -2217,16 +3651,16 @@ function requireAmerica() {
|
|
|
2217
3651
|
if (hasRequiredAmerica) return america.exports;
|
|
2218
3652
|
hasRequiredAmerica = 1;
|
|
2219
3653
|
(function(module2) {
|
|
2220
|
-
module2["exports"] = function(
|
|
3654
|
+
module2["exports"] = function(colors3) {
|
|
2221
3655
|
return function(letter, i, exploded) {
|
|
2222
3656
|
if (letter === " ") return letter;
|
|
2223
3657
|
switch (i % 3) {
|
|
2224
3658
|
case 0:
|
|
2225
|
-
return
|
|
3659
|
+
return colors3.red(letter);
|
|
2226
3660
|
case 1:
|
|
2227
|
-
return
|
|
3661
|
+
return colors3.white(letter);
|
|
2228
3662
|
case 2:
|
|
2229
|
-
return
|
|
3663
|
+
return colors3.blue(letter);
|
|
2230
3664
|
}
|
|
2231
3665
|
};
|
|
2232
3666
|
};
|
|
@@ -2242,9 +3676,9 @@ function requireZebra() {
|
|
|
2242
3676
|
if (hasRequiredZebra) return zebra.exports;
|
|
2243
3677
|
hasRequiredZebra = 1;
|
|
2244
3678
|
(function(module2) {
|
|
2245
|
-
module2["exports"] = function(
|
|
3679
|
+
module2["exports"] = function(colors3) {
|
|
2246
3680
|
return function(letter, i, exploded) {
|
|
2247
|
-
return i % 2 === 0 ? letter :
|
|
3681
|
+
return i % 2 === 0 ? letter : colors3.inverse(letter);
|
|
2248
3682
|
};
|
|
2249
3683
|
};
|
|
2250
3684
|
})(zebra);
|
|
@@ -2259,7 +3693,7 @@ function requireRainbow() {
|
|
|
2259
3693
|
if (hasRequiredRainbow) return rainbow.exports;
|
|
2260
3694
|
hasRequiredRainbow = 1;
|
|
2261
3695
|
(function(module2) {
|
|
2262
|
-
module2["exports"] = function(
|
|
3696
|
+
module2["exports"] = function(colors3) {
|
|
2263
3697
|
var rainbowColors = [
|
|
2264
3698
|
"red",
|
|
2265
3699
|
"yellow",
|
|
@@ -2271,7 +3705,7 @@ function requireRainbow() {
|
|
|
2271
3705
|
if (letter === " ") {
|
|
2272
3706
|
return letter;
|
|
2273
3707
|
} else {
|
|
2274
|
-
return
|
|
3708
|
+
return colors3[rainbowColors[i++ % rainbowColors.length]](letter);
|
|
2275
3709
|
}
|
|
2276
3710
|
};
|
|
2277
3711
|
};
|
|
@@ -2287,7 +3721,7 @@ function requireRandom() {
|
|
|
2287
3721
|
if (hasRequiredRandom) return random.exports;
|
|
2288
3722
|
hasRequiredRandom = 1;
|
|
2289
3723
|
(function(module2) {
|
|
2290
|
-
module2["exports"] = function(
|
|
3724
|
+
module2["exports"] = function(colors3) {
|
|
2291
3725
|
var available = [
|
|
2292
3726
|
"underline",
|
|
2293
3727
|
"inverse",
|
|
@@ -2308,7 +3742,7 @@ function requireRandom() {
|
|
|
2308
3742
|
"brightMagenta"
|
|
2309
3743
|
];
|
|
2310
3744
|
return function(letter, i, exploded) {
|
|
2311
|
-
return letter === " " ? letter :
|
|
3745
|
+
return letter === " " ? letter : colors3[available[Math.round(Math.random() * (available.length - 2))]](letter);
|
|
2312
3746
|
};
|
|
2313
3747
|
};
|
|
2314
3748
|
})(random);
|
|
@@ -2316,33 +3750,33 @@ function requireRandom() {
|
|
|
2316
3750
|
}
|
|
2317
3751
|
__name(requireRandom, "requireRandom");
|
|
2318
3752
|
(function(module2) {
|
|
2319
|
-
var
|
|
2320
|
-
module2["exports"] =
|
|
2321
|
-
|
|
3753
|
+
var colors3 = {};
|
|
3754
|
+
module2["exports"] = colors3;
|
|
3755
|
+
colors3.themes = {};
|
|
2322
3756
|
var util = import_util.default;
|
|
2323
|
-
var ansiStyles =
|
|
3757
|
+
var ansiStyles = colors3.styles = styles.exports;
|
|
2324
3758
|
var defineProps = Object.defineProperties;
|
|
2325
3759
|
var newLineRegex = new RegExp(/[\r\n]+/g);
|
|
2326
|
-
|
|
2327
|
-
if (typeof
|
|
2328
|
-
|
|
3760
|
+
colors3.supportsColor = supportsColors.supportsColor;
|
|
3761
|
+
if (typeof colors3.enabled === "undefined") {
|
|
3762
|
+
colors3.enabled = colors3.supportsColor() !== false;
|
|
2329
3763
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
3764
|
+
colors3.enable = function() {
|
|
3765
|
+
colors3.enabled = true;
|
|
2332
3766
|
};
|
|
2333
|
-
|
|
2334
|
-
|
|
3767
|
+
colors3.disable = function() {
|
|
3768
|
+
colors3.enabled = false;
|
|
2335
3769
|
};
|
|
2336
|
-
|
|
3770
|
+
colors3.stripColors = colors3.strip = function(str) {
|
|
2337
3771
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
2338
3772
|
};
|
|
2339
|
-
|
|
2340
|
-
if (!
|
|
3773
|
+
colors3.stylize = /* @__PURE__ */ __name(function stylize(str, style) {
|
|
3774
|
+
if (!colors3.enabled) {
|
|
2341
3775
|
return str + "";
|
|
2342
3776
|
}
|
|
2343
3777
|
var styleMap = ansiStyles[style];
|
|
2344
|
-
if (!styleMap && style in
|
|
2345
|
-
return
|
|
3778
|
+
if (!styleMap && style in colors3) {
|
|
3779
|
+
return colors3[style](str);
|
|
2346
3780
|
}
|
|
2347
3781
|
return styleMap.open + str + styleMap.close;
|
|
2348
3782
|
}, "stylize");
|
|
@@ -2353,7 +3787,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2353
3787
|
}
|
|
2354
3788
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
2355
3789
|
}, "escapeStringRegexp");
|
|
2356
|
-
function
|
|
3790
|
+
function build3(_styles) {
|
|
2357
3791
|
var builder = /* @__PURE__ */ __name(function builder2() {
|
|
2358
3792
|
return applyStyle.apply(builder2, arguments);
|
|
2359
3793
|
}, "builder");
|
|
@@ -2361,7 +3795,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2361
3795
|
builder.__proto__ = proto;
|
|
2362
3796
|
return builder;
|
|
2363
3797
|
}
|
|
2364
|
-
__name(
|
|
3798
|
+
__name(build3, "build");
|
|
2365
3799
|
var styles$1 = function() {
|
|
2366
3800
|
var ret = {};
|
|
2367
3801
|
ansiStyles.grey = ansiStyles.gray;
|
|
@@ -2369,13 +3803,13 @@ __name(requireRandom, "requireRandom");
|
|
|
2369
3803
|
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
|
|
2370
3804
|
ret[key] = {
|
|
2371
3805
|
get: /* @__PURE__ */ __name(function() {
|
|
2372
|
-
return
|
|
3806
|
+
return build3(this._styles.concat(key));
|
|
2373
3807
|
}, "get")
|
|
2374
3808
|
};
|
|
2375
3809
|
});
|
|
2376
3810
|
return ret;
|
|
2377
3811
|
}();
|
|
2378
|
-
var proto = defineProps(/* @__PURE__ */ __name(function
|
|
3812
|
+
var proto = defineProps(/* @__PURE__ */ __name(function colors4() {
|
|
2379
3813
|
}, "colors"), styles$1);
|
|
2380
3814
|
function applyStyle() {
|
|
2381
3815
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -2386,7 +3820,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2386
3820
|
return util.inspect(arg);
|
|
2387
3821
|
}
|
|
2388
3822
|
}).join(" ");
|
|
2389
|
-
if (!
|
|
3823
|
+
if (!colors3.enabled || !str) {
|
|
2390
3824
|
return str;
|
|
2391
3825
|
}
|
|
2392
3826
|
var newLinesPresent = str.indexOf("\n") != -1;
|
|
@@ -2404,22 +3838,22 @@ __name(requireRandom, "requireRandom");
|
|
|
2404
3838
|
return str;
|
|
2405
3839
|
}
|
|
2406
3840
|
__name(applyStyle, "applyStyle");
|
|
2407
|
-
|
|
3841
|
+
colors3.setTheme = function(theme) {
|
|
2408
3842
|
if (typeof theme === "string") {
|
|
2409
3843
|
console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");
|
|
2410
3844
|
return;
|
|
2411
3845
|
}
|
|
2412
3846
|
for (var style in theme) {
|
|
2413
3847
|
(function(style2) {
|
|
2414
|
-
|
|
3848
|
+
colors3[style2] = function(str) {
|
|
2415
3849
|
if (typeof theme[style2] === "object") {
|
|
2416
3850
|
var out = str;
|
|
2417
3851
|
for (var i in theme[style2]) {
|
|
2418
|
-
out =
|
|
3852
|
+
out = colors3[theme[style2][i]](out);
|
|
2419
3853
|
}
|
|
2420
3854
|
return out;
|
|
2421
3855
|
}
|
|
2422
|
-
return
|
|
3856
|
+
return colors3[theme[style2]](str);
|
|
2423
3857
|
};
|
|
2424
3858
|
})(style);
|
|
2425
3859
|
}
|
|
@@ -2429,7 +3863,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2429
3863
|
Object.keys(styles$1).forEach(function(name) {
|
|
2430
3864
|
ret[name] = {
|
|
2431
3865
|
get: /* @__PURE__ */ __name(function() {
|
|
2432
|
-
return
|
|
3866
|
+
return build3([
|
|
2433
3867
|
name
|
|
2434
3868
|
]);
|
|
2435
3869
|
}, "get")
|
|
@@ -2443,24 +3877,24 @@ __name(requireRandom, "requireRandom");
|
|
|
2443
3877
|
exploded = exploded.map(map2);
|
|
2444
3878
|
return exploded.join("");
|
|
2445
3879
|
}, "sequencer");
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
for (var map in
|
|
3880
|
+
colors3.trap = requireTrap();
|
|
3881
|
+
colors3.zalgo = requireZalgo();
|
|
3882
|
+
colors3.maps = {};
|
|
3883
|
+
colors3.maps.america = requireAmerica()(colors3);
|
|
3884
|
+
colors3.maps.zebra = requireZebra()(colors3);
|
|
3885
|
+
colors3.maps.rainbow = requireRainbow()(colors3);
|
|
3886
|
+
colors3.maps.random = requireRandom()(colors3);
|
|
3887
|
+
for (var map in colors3.maps) {
|
|
2454
3888
|
(function(map2) {
|
|
2455
|
-
|
|
2456
|
-
return sequencer(
|
|
3889
|
+
colors3[map2] = function(str) {
|
|
3890
|
+
return sequencer(colors3.maps[map2], str);
|
|
2457
3891
|
};
|
|
2458
3892
|
})(map);
|
|
2459
3893
|
}
|
|
2460
|
-
defineProps(
|
|
2461
|
-
})(
|
|
3894
|
+
defineProps(colors3, init());
|
|
3895
|
+
})(colors2);
|
|
2462
3896
|
(function(module2) {
|
|
2463
|
-
var colors$1 =
|
|
3897
|
+
var colors$1 = colors2.exports;
|
|
2464
3898
|
module2["exports"] = colors$1;
|
|
2465
3899
|
})(safe);
|
|
2466
3900
|
var path$4 = import_path2.default;
|
|
@@ -2500,8 +3934,8 @@ var pLimit$2 = {
|
|
|
2500
3934
|
var pTry$2 = {
|
|
2501
3935
|
exports: {}
|
|
2502
3936
|
};
|
|
2503
|
-
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((
|
|
2504
|
-
|
|
3937
|
+
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((resolve3) => {
|
|
3938
|
+
resolve3(fn(...arguments_));
|
|
2505
3939
|
}), "pTry$1");
|
|
2506
3940
|
pTry$2.exports = pTry$1;
|
|
2507
3941
|
pTry$2.exports.default = pTry$1;
|
|
@@ -2518,20 +3952,20 @@ var pLimit$1 = /* @__PURE__ */ __name((concurrency) => {
|
|
|
2518
3952
|
queue.shift()();
|
|
2519
3953
|
}
|
|
2520
3954
|
}, "next");
|
|
2521
|
-
const run = /* @__PURE__ */ __name((fn,
|
|
3955
|
+
const run = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2522
3956
|
activeCount++;
|
|
2523
3957
|
const result = pTry(fn, ...args);
|
|
2524
|
-
|
|
3958
|
+
resolve3(result);
|
|
2525
3959
|
result.then(next, next);
|
|
2526
3960
|
}, "run");
|
|
2527
|
-
const enqueue = /* @__PURE__ */ __name((fn,
|
|
3961
|
+
const enqueue = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2528
3962
|
if (activeCount < concurrency) {
|
|
2529
|
-
run(fn,
|
|
3963
|
+
run(fn, resolve3, ...args);
|
|
2530
3964
|
} else {
|
|
2531
|
-
queue.push(run.bind(null, fn,
|
|
3965
|
+
queue.push(run.bind(null, fn, resolve3, ...args));
|
|
2532
3966
|
}
|
|
2533
3967
|
}, "enqueue");
|
|
2534
|
-
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((
|
|
3968
|
+
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve3) => enqueue(fn, resolve3, ...args)), "generator");
|
|
2535
3969
|
Object.defineProperties(generator, {
|
|
2536
3970
|
activeCount: {
|
|
2537
3971
|
get: /* @__PURE__ */ __name(() => activeCount, "get")
|
|
@@ -2774,12 +4208,12 @@ var checkPath = /* @__PURE__ */ __name((pth) => {
|
|
|
2774
4208
|
}
|
|
2775
4209
|
}, "checkPath");
|
|
2776
4210
|
var processOptions = /* @__PURE__ */ __name((options) => {
|
|
2777
|
-
const
|
|
4211
|
+
const defaults2 = {
|
|
2778
4212
|
mode: 511 & ~process.umask(),
|
|
2779
4213
|
fs: fs$1
|
|
2780
4214
|
};
|
|
2781
4215
|
return {
|
|
2782
|
-
...
|
|
4216
|
+
...defaults2,
|
|
2783
4217
|
...options
|
|
2784
4218
|
};
|
|
2785
4219
|
}, "processOptions");
|
|
@@ -2794,11 +4228,11 @@ var permissionError = /* @__PURE__ */ __name((pth) => {
|
|
|
2794
4228
|
var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
2795
4229
|
checkPath(input);
|
|
2796
4230
|
options = processOptions(options);
|
|
2797
|
-
const
|
|
4231
|
+
const mkdir2 = promisify(options.fs.mkdir);
|
|
2798
4232
|
const stat = promisify(options.fs.stat);
|
|
2799
4233
|
if (useNativeRecursiveOption && options.fs.mkdir === fs$1.mkdir) {
|
|
2800
4234
|
const pth = path$1.resolve(input);
|
|
2801
|
-
await
|
|
4235
|
+
await mkdir2(pth, {
|
|
2802
4236
|
mode: options.mode,
|
|
2803
4237
|
recursive: true
|
|
2804
4238
|
});
|
|
@@ -2806,7 +4240,7 @@ var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
|
2806
4240
|
}
|
|
2807
4241
|
const make = /* @__PURE__ */ __name(async (pth) => {
|
|
2808
4242
|
try {
|
|
2809
|
-
await
|
|
4243
|
+
await mkdir2(pth, options.mode);
|
|
2810
4244
|
return pth;
|
|
2811
4245
|
} catch (error) {
|
|
2812
4246
|
if (error.code === "EPERM") {
|
|
@@ -3008,7 +4442,7 @@ var LanguageServiceHost = class LanguageServiceHost2 {
|
|
|
3008
4442
|
this.service = service;
|
|
3009
4443
|
}
|
|
3010
4444
|
setSnapshot(fileName, source) {
|
|
3011
|
-
fileName = (0,
|
|
4445
|
+
fileName = (0, import_pluginutils3.normalizePath)(fileName);
|
|
3012
4446
|
const snapshot = tsModule.ScriptSnapshot.fromString(source);
|
|
3013
4447
|
this.snapshots[fileName] = snapshot;
|
|
3014
4448
|
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
|
@@ -3016,14 +4450,14 @@ var LanguageServiceHost = class LanguageServiceHost2 {
|
|
|
3016
4450
|
return snapshot;
|
|
3017
4451
|
}
|
|
3018
4452
|
getScriptSnapshot(fileName) {
|
|
3019
|
-
fileName = (0,
|
|
4453
|
+
fileName = (0, import_pluginutils3.normalizePath)(fileName);
|
|
3020
4454
|
if (fileName in this.snapshots) return this.snapshots[fileName];
|
|
3021
4455
|
const source = tsModule.sys.readFile(fileName);
|
|
3022
4456
|
if (source) return this.setSnapshot(fileName, source);
|
|
3023
4457
|
return void 0;
|
|
3024
4458
|
}
|
|
3025
4459
|
getScriptVersion(fileName) {
|
|
3026
|
-
fileName = (0,
|
|
4460
|
+
fileName = (0, import_pluginutils3.normalizePath)(fileName);
|
|
3027
4461
|
return (this.versions[fileName] || 0).toString();
|
|
3028
4462
|
}
|
|
3029
4463
|
getCustomTransformers() {
|
|
@@ -3501,11 +4935,11 @@ var lodash$1 = {
|
|
|
3501
4935
|
return result;
|
|
3502
4936
|
}
|
|
3503
4937
|
__name(arrayFilter, "arrayFilter");
|
|
3504
|
-
function
|
|
4938
|
+
function arrayIncludes2(array, value) {
|
|
3505
4939
|
var length = array == null ? 0 : array.length;
|
|
3506
4940
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
3507
4941
|
}
|
|
3508
|
-
__name(
|
|
4942
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
3509
4943
|
function arrayIncludesWith(array, value, comparator) {
|
|
3510
4944
|
var index = -1, length = array == null ? 0 : array.length;
|
|
3511
4945
|
while (++index < length) {
|
|
@@ -3754,9 +5188,9 @@ var lodash$1 = {
|
|
|
3754
5188
|
return result;
|
|
3755
5189
|
}
|
|
3756
5190
|
__name(mapToArray, "mapToArray");
|
|
3757
|
-
function overArg(func,
|
|
5191
|
+
function overArg(func, transform3) {
|
|
3758
5192
|
return function(arg) {
|
|
3759
|
-
return func(
|
|
5193
|
+
return func(transform3(arg));
|
|
3760
5194
|
};
|
|
3761
5195
|
}
|
|
3762
5196
|
__name(overArg, "overArg");
|
|
@@ -4430,7 +5864,7 @@ var lodash$1 = {
|
|
|
4430
5864
|
}
|
|
4431
5865
|
__name(baseDelay, "baseDelay");
|
|
4432
5866
|
function baseDifference(array, values2, iteratee2, comparator) {
|
|
4433
|
-
var index = -1, includes2 =
|
|
5867
|
+
var index = -1, includes2 = arrayIncludes2, isCommon = true, length = array.length, result2 = [], valuesLength = values2.length;
|
|
4434
5868
|
if (!length) {
|
|
4435
5869
|
return result2;
|
|
4436
5870
|
}
|
|
@@ -4585,7 +6019,7 @@ var lodash$1 = {
|
|
|
4585
6019
|
}
|
|
4586
6020
|
__name(baseInRange, "baseInRange");
|
|
4587
6021
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
4588
|
-
var includes2 = comparator ? arrayIncludesWith :
|
|
6022
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes2, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array1(othLength), maxLength = Infinity, result2 = [];
|
|
4589
6023
|
while (othIndex--) {
|
|
4590
6024
|
var array = arrays[othIndex];
|
|
4591
6025
|
if (othIndex && iteratee2) {
|
|
@@ -5166,7 +6600,7 @@ var lodash$1 = {
|
|
|
5166
6600
|
}
|
|
5167
6601
|
__name(baseToString, "baseToString");
|
|
5168
6602
|
function baseUniq(array, iteratee2, comparator) {
|
|
5169
|
-
var index = -1, includes2 =
|
|
6603
|
+
var index = -1, includes2 = arrayIncludes2, length = array.length, isCommon = true, result2 = [], seen = result2;
|
|
5170
6604
|
if (comparator) {
|
|
5171
6605
|
isCommon = false;
|
|
5172
6606
|
includes2 = arrayIncludesWith;
|
|
@@ -6364,7 +7798,7 @@ var lodash$1 = {
|
|
|
6364
7798
|
return nativeObjectToString.call(value);
|
|
6365
7799
|
}
|
|
6366
7800
|
__name(objectToString, "objectToString");
|
|
6367
|
-
function overRest(func, start,
|
|
7801
|
+
function overRest(func, start, transform4) {
|
|
6368
7802
|
start = nativeMax(start === undefined$1 ? func.length - 1 : start, 0);
|
|
6369
7803
|
return function() {
|
|
6370
7804
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array1(length);
|
|
@@ -6376,7 +7810,7 @@ var lodash$1 = {
|
|
|
6376
7810
|
while (++index < start) {
|
|
6377
7811
|
otherArgs[index] = args[index];
|
|
6378
7812
|
}
|
|
6379
|
-
otherArgs[start] =
|
|
7813
|
+
otherArgs[start] = transform4(array);
|
|
6380
7814
|
return apply(func, this, otherArgs);
|
|
6381
7815
|
};
|
|
6382
7816
|
}
|
|
@@ -6477,7 +7911,7 @@ var lodash$1 = {
|
|
|
6477
7911
|
function updateWrapDetails(details, bitmask) {
|
|
6478
7912
|
arrayEach(wrapFlags, function(pair) {
|
|
6479
7913
|
var value = "_." + pair[0];
|
|
6480
|
-
if (bitmask & pair[1] && !
|
|
7914
|
+
if (bitmask & pair[1] && !arrayIncludes2(details, value)) {
|
|
6481
7915
|
details.push(value);
|
|
6482
7916
|
}
|
|
6483
7917
|
});
|
|
@@ -6688,10 +8122,10 @@ var lodash$1 = {
|
|
|
6688
8122
|
}
|
|
6689
8123
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined$1, comparator) : [];
|
|
6690
8124
|
});
|
|
6691
|
-
function
|
|
8125
|
+
function join5(array, separator) {
|
|
6692
8126
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
6693
8127
|
}
|
|
6694
|
-
__name(
|
|
8128
|
+
__name(join5, "join");
|
|
6695
8129
|
function last(array) {
|
|
6696
8130
|
var length = array == null ? 0 : array.length;
|
|
6697
8131
|
return length ? array[length - 1] : undefined$1;
|
|
@@ -7796,7 +9230,7 @@ var lodash$1 = {
|
|
|
7796
9230
|
return properties == null ? result2 : baseAssign(result2, properties);
|
|
7797
9231
|
}
|
|
7798
9232
|
__name(create, "create");
|
|
7799
|
-
var
|
|
9233
|
+
var defaults2 = baseRest(function(object, sources) {
|
|
7800
9234
|
object = Object1(object);
|
|
7801
9235
|
var index = -1;
|
|
7802
9236
|
var length = sources.length;
|
|
@@ -7991,7 +9425,7 @@ var lodash$1 = {
|
|
|
7991
9425
|
__name(setWith, "setWith");
|
|
7992
9426
|
var toPairs = createToPairs(keys);
|
|
7993
9427
|
var toPairsIn = createToPairs(keysIn);
|
|
7994
|
-
function
|
|
9428
|
+
function transform3(object, iteratee2, accumulator) {
|
|
7995
9429
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
7996
9430
|
iteratee2 = getIteratee(iteratee2, 4);
|
|
7997
9431
|
if (accumulator == null) {
|
|
@@ -8009,7 +9443,7 @@ var lodash$1 = {
|
|
|
8009
9443
|
});
|
|
8010
9444
|
return accumulator;
|
|
8011
9445
|
}
|
|
8012
|
-
__name(
|
|
9446
|
+
__name(transform3, "transform");
|
|
8013
9447
|
function unset(object, path3) {
|
|
8014
9448
|
return object == null ? true : baseUnset(object, path3);
|
|
8015
9449
|
}
|
|
@@ -8179,11 +9613,11 @@ var lodash$1 = {
|
|
|
8179
9613
|
return baseRepeat(toString(string), n);
|
|
8180
9614
|
}
|
|
8181
9615
|
__name(repeat, "repeat");
|
|
8182
|
-
function
|
|
9616
|
+
function replace2() {
|
|
8183
9617
|
var args = arguments, string = toString(args[0]);
|
|
8184
9618
|
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
8185
9619
|
}
|
|
8186
|
-
__name(
|
|
9620
|
+
__name(replace2, "replace");
|
|
8187
9621
|
var snakeCase = createCompounder(function(result2, word, index) {
|
|
8188
9622
|
return result2 + (index ? "_" : "") + word.toLowerCase();
|
|
8189
9623
|
});
|
|
@@ -8636,7 +10070,7 @@ var lodash$1 = {
|
|
|
8636
10070
|
lodash2.curry = curry;
|
|
8637
10071
|
lodash2.curryRight = curryRight;
|
|
8638
10072
|
lodash2.debounce = debounce;
|
|
8639
|
-
lodash2.defaults =
|
|
10073
|
+
lodash2.defaults = defaults2;
|
|
8640
10074
|
lodash2.defaultsDeep = defaultsDeep;
|
|
8641
10075
|
lodash2.defer = defer;
|
|
8642
10076
|
lodash2.delay = delay;
|
|
@@ -8736,7 +10170,7 @@ var lodash$1 = {
|
|
|
8736
10170
|
lodash2.toPairsIn = toPairsIn;
|
|
8737
10171
|
lodash2.toPath = toPath;
|
|
8738
10172
|
lodash2.toPlainObject = toPlainObject;
|
|
8739
|
-
lodash2.transform =
|
|
10173
|
+
lodash2.transform = transform3;
|
|
8740
10174
|
lodash2.unary = unary;
|
|
8741
10175
|
lodash2.union = union;
|
|
8742
10176
|
lodash2.unionBy = unionBy;
|
|
@@ -8846,7 +10280,7 @@ var lodash$1 = {
|
|
|
8846
10280
|
lodash2.isUndefined = isUndefined;
|
|
8847
10281
|
lodash2.isWeakMap = isWeakMap;
|
|
8848
10282
|
lodash2.isWeakSet = isWeakSet;
|
|
8849
|
-
lodash2.join =
|
|
10283
|
+
lodash2.join = join5;
|
|
8850
10284
|
lodash2.kebabCase = kebabCase;
|
|
8851
10285
|
lodash2.last = last;
|
|
8852
10286
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -8878,7 +10312,7 @@ var lodash$1 = {
|
|
|
8878
10312
|
lodash2.reduce = reduce;
|
|
8879
10313
|
lodash2.reduceRight = reduceRight;
|
|
8880
10314
|
lodash2.repeat = repeat;
|
|
8881
|
-
lodash2.replace =
|
|
10315
|
+
lodash2.replace = replace2;
|
|
8882
10316
|
lodash2.result = result;
|
|
8883
10317
|
lodash2.round = round;
|
|
8884
10318
|
lodash2.runInContext = runInContext2;
|
|
@@ -10270,9 +11704,9 @@ var hasRequired_overArg;
|
|
|
10270
11704
|
function require_overArg() {
|
|
10271
11705
|
if (hasRequired_overArg) return _overArg;
|
|
10272
11706
|
hasRequired_overArg = 1;
|
|
10273
|
-
function overArg(func,
|
|
11707
|
+
function overArg(func, transform3) {
|
|
10274
11708
|
return function(arg) {
|
|
10275
|
-
return func(
|
|
11709
|
+
return func(transform3(arg));
|
|
10276
11710
|
};
|
|
10277
11711
|
}
|
|
10278
11712
|
__name(overArg, "overArg");
|
|
@@ -12393,7 +13827,7 @@ function requireTransform() {
|
|
|
12393
13827
|
if (hasRequiredTransform) return transform_1;
|
|
12394
13828
|
hasRequiredTransform = 1;
|
|
12395
13829
|
var arrayEach = require_arrayEach(), baseCreate = require_baseCreate(), baseForOwn = require_baseForOwn(), baseIteratee = require_baseIteratee(), getPrototype = require_getPrototype(), isArray = requireIsArray(), isBuffer2 = requireIsBuffer(), isFunction = requireIsFunction(), isObject = requireIsObject(), isTypedArray = requireIsTypedArray();
|
|
12396
|
-
function
|
|
13830
|
+
function transform3(object, iteratee, accumulator) {
|
|
12397
13831
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
12398
13832
|
iteratee = baseIteratee(iteratee, 4);
|
|
12399
13833
|
if (accumulator == null) {
|
|
@@ -12411,8 +13845,8 @@ function requireTransform() {
|
|
|
12411
13845
|
});
|
|
12412
13846
|
return accumulator;
|
|
12413
13847
|
}
|
|
12414
|
-
__name(
|
|
12415
|
-
transform_1 =
|
|
13848
|
+
__name(transform3, "transform");
|
|
13849
|
+
transform_1 = transform3;
|
|
12416
13850
|
return transform_1;
|
|
12417
13851
|
}
|
|
12418
13852
|
__name(requireTransform, "requireTransform");
|
|
@@ -12490,7 +13924,7 @@ function require_overRest() {
|
|
|
12490
13924
|
hasRequired_overRest = 1;
|
|
12491
13925
|
var apply = require_apply();
|
|
12492
13926
|
var nativeMax = Math.max;
|
|
12493
|
-
function overRest(func, start,
|
|
13927
|
+
function overRest(func, start, transform3) {
|
|
12494
13928
|
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
12495
13929
|
return function() {
|
|
12496
13930
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
|
|
@@ -12502,7 +13936,7 @@ function require_overRest() {
|
|
|
12502
13936
|
while (++index < start) {
|
|
12503
13937
|
otherArgs[index] = args[index];
|
|
12504
13938
|
}
|
|
12505
|
-
otherArgs[start] =
|
|
13939
|
+
otherArgs[start] = transform3(array);
|
|
12506
13940
|
return apply(func, this, otherArgs);
|
|
12507
13941
|
};
|
|
12508
13942
|
}
|
|
@@ -12652,12 +14086,12 @@ function require_arrayIncludes() {
|
|
|
12652
14086
|
if (hasRequired_arrayIncludes) return _arrayIncludes;
|
|
12653
14087
|
hasRequired_arrayIncludes = 1;
|
|
12654
14088
|
var baseIndexOf = require_baseIndexOf();
|
|
12655
|
-
function
|
|
14089
|
+
function arrayIncludes2(array, value) {
|
|
12656
14090
|
var length = array == null ? 0 : array.length;
|
|
12657
14091
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
12658
14092
|
}
|
|
12659
|
-
__name(
|
|
12660
|
-
_arrayIncludes =
|
|
14093
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
14094
|
+
_arrayIncludes = arrayIncludes2;
|
|
12661
14095
|
return _arrayIncludes;
|
|
12662
14096
|
}
|
|
12663
14097
|
__name(require_arrayIncludes, "require_arrayIncludes");
|
|
@@ -12714,10 +14148,10 @@ var hasRequired_baseUniq;
|
|
|
12714
14148
|
function require_baseUniq() {
|
|
12715
14149
|
if (hasRequired_baseUniq) return _baseUniq;
|
|
12716
14150
|
hasRequired_baseUniq = 1;
|
|
12717
|
-
var SetCache = require_SetCache(),
|
|
14151
|
+
var SetCache = require_SetCache(), arrayIncludes2 = require_arrayIncludes(), arrayIncludesWith = require_arrayIncludesWith(), cacheHas = require_cacheHas(), createSet = require_createSet(), setToArray = require_setToArray();
|
|
12718
14152
|
var LARGE_ARRAY_SIZE = 200;
|
|
12719
14153
|
function baseUniq(array, iteratee, comparator) {
|
|
12720
|
-
var index = -1, includes =
|
|
14154
|
+
var index = -1, includes = arrayIncludes2, length = array.length, isCommon = true, result = [], seen = result;
|
|
12721
14155
|
if (comparator) {
|
|
12722
14156
|
isCommon = false;
|
|
12723
14157
|
includes = arrayIncludesWith;
|
|
@@ -13052,27 +14486,27 @@ Graph$2.prototype.isLeaf = function(v) {
|
|
|
13052
14486
|
return neighbors.length === 0;
|
|
13053
14487
|
};
|
|
13054
14488
|
Graph$2.prototype.filterNodes = function(filter) {
|
|
13055
|
-
var
|
|
14489
|
+
var copy2 = new this.constructor({
|
|
13056
14490
|
directed: this._isDirected,
|
|
13057
14491
|
multigraph: this._isMultigraph,
|
|
13058
14492
|
compound: this._isCompound
|
|
13059
14493
|
});
|
|
13060
|
-
|
|
14494
|
+
copy2.setGraph(this.graph());
|
|
13061
14495
|
var self1 = this;
|
|
13062
14496
|
_$b.each(this._nodes, function(value, v) {
|
|
13063
14497
|
if (filter(v)) {
|
|
13064
|
-
|
|
14498
|
+
copy2.setNode(v, value);
|
|
13065
14499
|
}
|
|
13066
14500
|
});
|
|
13067
14501
|
_$b.each(this._edgeObjs, function(e) {
|
|
13068
|
-
if (
|
|
13069
|
-
|
|
14502
|
+
if (copy2.hasNode(e.v) && copy2.hasNode(e.w)) {
|
|
14503
|
+
copy2.setEdge(e, self1.edge(e));
|
|
13070
14504
|
}
|
|
13071
14505
|
});
|
|
13072
14506
|
var parents = {};
|
|
13073
14507
|
function findParent(v) {
|
|
13074
14508
|
var parent = self1.parent(v);
|
|
13075
|
-
if (parent === void 0 ||
|
|
14509
|
+
if (parent === void 0 || copy2.hasNode(parent)) {
|
|
13076
14510
|
parents[v] = parent;
|
|
13077
14511
|
return parent;
|
|
13078
14512
|
} else if (parent in parents) {
|
|
@@ -13083,11 +14517,11 @@ Graph$2.prototype.filterNodes = function(filter) {
|
|
|
13083
14517
|
}
|
|
13084
14518
|
__name(findParent, "findParent");
|
|
13085
14519
|
if (this._isCompound) {
|
|
13086
|
-
_$b.each(
|
|
13087
|
-
|
|
14520
|
+
_$b.each(copy2.nodes(), function(v) {
|
|
14521
|
+
copy2.setParent(v, findParent(v));
|
|
13088
14522
|
});
|
|
13089
14523
|
}
|
|
13090
|
-
return
|
|
14524
|
+
return copy2;
|
|
13091
14525
|
};
|
|
13092
14526
|
Graph$2.prototype.setDefaultEdgeLabel = function(newDefault) {
|
|
13093
14527
|
if (!_$b.isFunction(newDefault)) {
|
|
@@ -14412,9 +15846,9 @@ var TsCache = class TsCache2 {
|
|
|
14412
15846
|
this.syntacticDiagnosticsCache.roll();
|
|
14413
15847
|
this.typesCache.roll();
|
|
14414
15848
|
}
|
|
14415
|
-
getCompiled(id, snapshot,
|
|
15849
|
+
getCompiled(id, snapshot, transform3) {
|
|
14416
15850
|
this.context.info(`${safe.exports.blue("transpiling")} '${id}'`);
|
|
14417
|
-
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration),
|
|
15851
|
+
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration), transform3);
|
|
14418
15852
|
}
|
|
14419
15853
|
getSyntacticDiagnostics(id, snapshot, check) {
|
|
14420
15854
|
return this.getDiagnostics("syntax", this.syntacticDiagnosticsCache, id, snapshot, check);
|
|
@@ -14497,7 +15931,7 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
|
|
|
14497
15931
|
noEmit: false,
|
|
14498
15932
|
noEmitOnError: false,
|
|
14499
15933
|
inlineSourceMap: false,
|
|
14500
|
-
outDir: (0,
|
|
15934
|
+
outDir: (0, import_pluginutils3.normalizePath)(`${cacheRoot}/placeholder`),
|
|
14501
15935
|
allowNonTsExtensions: true
|
|
14502
15936
|
};
|
|
14503
15937
|
if (!preParsedTsconfig) return overrides;
|
|
@@ -14512,13 +15946,13 @@ __name(getOptionsOverrides, "getOptionsOverrides");
|
|
|
14512
15946
|
function expandIncludeWithDirs(include, dirs) {
|
|
14513
15947
|
const newDirs = [];
|
|
14514
15948
|
dirs.forEach((root) => {
|
|
14515
|
-
if (include instanceof Array) include.forEach((x) => newDirs.push((0,
|
|
14516
|
-
else newDirs.push((0,
|
|
15949
|
+
if (include instanceof Array) include.forEach((x) => newDirs.push((0, import_pluginutils3.normalizePath)(require$$0.join(root, x))));
|
|
15950
|
+
else newDirs.push((0, import_pluginutils3.normalizePath)(require$$0.join(root, include)));
|
|
14517
15951
|
});
|
|
14518
15952
|
return newDirs;
|
|
14519
15953
|
}
|
|
14520
15954
|
__name(expandIncludeWithDirs, "expandIncludeWithDirs");
|
|
14521
|
-
function
|
|
15955
|
+
function createFilter2(context, pluginOptions, parsedConfig) {
|
|
14522
15956
|
let included = pluginOptions.include;
|
|
14523
15957
|
let excluded = pluginOptions.exclude;
|
|
14524
15958
|
if (parsedConfig.options.rootDirs) {
|
|
@@ -14533,11 +15967,11 @@ function createFilter(context, pluginOptions, parsedConfig) {
|
|
|
14533
15967
|
${JSON.stringify(included, void 0, 4)}`);
|
|
14534
15968
|
context.debug(() => `excluded:
|
|
14535
15969
|
${JSON.stringify(excluded, void 0, 4)}`);
|
|
14536
|
-
return (0,
|
|
15970
|
+
return (0, import_pluginutils3.createFilter)(included, excluded, {
|
|
14537
15971
|
resolve: parsedConfig.options.rootDir
|
|
14538
15972
|
});
|
|
14539
15973
|
}
|
|
14540
|
-
__name(
|
|
15974
|
+
__name(createFilter2, "createFilter");
|
|
14541
15975
|
function parseTsConfig(context, pluginOptions) {
|
|
14542
15976
|
var _a, _b;
|
|
14543
15977
|
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
|
|
@@ -14618,7 +16052,7 @@ var typescript = /* @__PURE__ */ __name((options) => {
|
|
|
14618
16052
|
}, "getDiagnostics");
|
|
14619
16053
|
const typecheckFile = /* @__PURE__ */ __name((id, snapshot, tcContext) => {
|
|
14620
16054
|
if (!snapshot) return;
|
|
14621
|
-
id = (0,
|
|
16055
|
+
id = (0, import_pluginutils3.normalizePath)(id);
|
|
14622
16056
|
checkedFiles.add(id);
|
|
14623
16057
|
const diagnostics = getDiagnostics(id, snapshot);
|
|
14624
16058
|
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty !== false);
|
|
@@ -14626,7 +16060,7 @@ var typescript = /* @__PURE__ */ __name((options) => {
|
|
|
14626
16060
|
}, "typecheckFile");
|
|
14627
16061
|
const addDeclaration = /* @__PURE__ */ __name((id, result) => {
|
|
14628
16062
|
if (!result.dts) return;
|
|
14629
|
-
const key = (0,
|
|
16063
|
+
const key = (0, import_pluginutils3.normalizePath)(id);
|
|
14630
16064
|
declarations[key] = {
|
|
14631
16065
|
type: result.dts,
|
|
14632
16066
|
map: result.dtsmap
|
|
@@ -14708,7 +16142,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14708
16142
|
if (pluginOptions.objectHashIgnoreUnknownHack) context.warn(() => `${safe.exports.yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`);
|
|
14709
16143
|
if (pluginOptions.rollupCommonJSResolveHack) context.warn(() => `${safe.exports.yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
|
|
14710
16144
|
if (watchMode) context.info(`running in watch mode`);
|
|
14711
|
-
filter =
|
|
16145
|
+
filter = createFilter2(context, pluginOptions, parsedConfig);
|
|
14712
16146
|
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
|
|
14713
16147
|
service = tsModule.createLanguageService(servicesHost, documentRegistry);
|
|
14714
16148
|
servicesHost.setLanguageService(service);
|
|
@@ -14723,7 +16157,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14723
16157
|
}
|
|
14724
16158
|
},
|
|
14725
16159
|
watchChange(id) {
|
|
14726
|
-
const key = (0,
|
|
16160
|
+
const key = (0, import_pluginutils3.normalizePath)(id);
|
|
14727
16161
|
delete declarations[key];
|
|
14728
16162
|
checkedFiles.delete(key);
|
|
14729
16163
|
},
|
|
@@ -14731,7 +16165,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14731
16165
|
var _a;
|
|
14732
16166
|
if (importee === TSLIB) return TSLIB_VIRTUAL;
|
|
14733
16167
|
if (!importer) return;
|
|
14734
|
-
importer = (0,
|
|
16168
|
+
importer = (0, import_pluginutils3.normalizePath)(importer);
|
|
14735
16169
|
const result = tsModule.nodeModuleNameResolver(importee, importer, parsedConfig.options, tsModule.sys);
|
|
14736
16170
|
const resolved = (_a = result.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
|
|
14737
16171
|
if (!resolved) return;
|
|
@@ -14817,7 +16251,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14817
16251
|
});
|
|
14818
16252
|
}
|
|
14819
16253
|
parsedConfig.fileNames.forEach((name) => {
|
|
14820
|
-
const key = (0,
|
|
16254
|
+
const key = (0, import_pluginutils3.normalizePath)(name);
|
|
14821
16255
|
if (checkedFiles.has(key) || !filter(key)) return;
|
|
14822
16256
|
context.debug(() => `type-checking missed '${key}'`);
|
|
14823
16257
|
const snapshot = servicesHost.getScriptSnapshot(key);
|
|
@@ -14830,7 +16264,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14830
16264
|
generateRound++;
|
|
14831
16265
|
if (!parsedConfig.options.declaration) return;
|
|
14832
16266
|
parsedConfig.fileNames.forEach((name) => {
|
|
14833
|
-
const key = (0,
|
|
16267
|
+
const key = (0, import_pluginutils3.normalizePath)(name);
|
|
14834
16268
|
if (key in declarations || !filter(key)) return;
|
|
14835
16269
|
context.debug(() => `generating missed declarations for '${key}'`);
|
|
14836
16270
|
const out = convertEmitOutput(service.getEmitOutput(key, true));
|
|
@@ -14852,11 +16286,11 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14852
16286
|
const parsedText = JSON.parse(entryText);
|
|
14853
16287
|
parsedText.sources = parsedText.sources.map((source) => {
|
|
14854
16288
|
const absolutePath = (0, import_path2.resolve)(cachePlaceholder, source);
|
|
14855
|
-
return (0,
|
|
16289
|
+
return (0, import_pluginutils3.normalizePath)((0, import_path2.relative)(declarationDir, absolutePath));
|
|
14856
16290
|
});
|
|
14857
16291
|
entryText = JSON.stringify(parsedText);
|
|
14858
16292
|
}
|
|
14859
|
-
const relativePath = (0,
|
|
16293
|
+
const relativePath = (0, import_pluginutils3.normalizePath)((0, import_path2.relative)(cachePlaceholder, fileName));
|
|
14860
16294
|
context.debug(() => `${safe.exports.blue("emitting declarations")} for '${key}' to '${relativePath}'`);
|
|
14861
16295
|
this.emitFile({
|
|
14862
16296
|
type: "asset",
|
|
@@ -14975,35 +16409,35 @@ async function resolveOptions(options) {
|
|
|
14975
16409
|
if (options.configPath) {
|
|
14976
16410
|
const configFile = await loadConfig2(options.configPath);
|
|
14977
16411
|
if (configFile) {
|
|
14978
|
-
options = (0,
|
|
16412
|
+
options = (0, import_defu5.default)(options, configFile);
|
|
14979
16413
|
}
|
|
14980
16414
|
}
|
|
14981
16415
|
const projectGraph = (0, import_devkit6.readCachedProjectGraph)();
|
|
14982
16416
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
14983
|
-
if (!(0,
|
|
16417
|
+
if (!(0, import_node_fs8.existsSync)(projectJsonPath)) {
|
|
14984
16418
|
throw new Error("Cannot find project.json configuration");
|
|
14985
16419
|
}
|
|
14986
|
-
const projectJsonContent = await (0,
|
|
16420
|
+
const projectJsonContent = await (0, import_promises7.readFile)(projectJsonPath, "utf8");
|
|
14987
16421
|
const projectJson = JSON.parse(projectJsonContent);
|
|
14988
16422
|
const projectName = projectJson.name;
|
|
14989
16423
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
14990
|
-
if (!(0,
|
|
16424
|
+
if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
|
|
14991
16425
|
throw new Error("Cannot find package.json configuration");
|
|
14992
16426
|
}
|
|
14993
|
-
const packageJsonContent = await (0,
|
|
16427
|
+
const packageJsonContent = await (0, import_promises7.readFile)(packageJsonPath, "utf8");
|
|
14994
16428
|
const packageJson = JSON.parse(packageJsonContent);
|
|
14995
16429
|
let tsconfig = options.tsconfig;
|
|
14996
16430
|
if (!tsconfig) {
|
|
14997
16431
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
14998
16432
|
}
|
|
14999
|
-
if (!(0,
|
|
16433
|
+
if (!(0, import_node_fs8.existsSync)(tsconfig)) {
|
|
15000
16434
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
15001
16435
|
}
|
|
15002
16436
|
let sourceRoot = projectJson.sourceRoot;
|
|
15003
16437
|
if (!sourceRoot) {
|
|
15004
16438
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
15005
16439
|
}
|
|
15006
|
-
if (!(0,
|
|
16440
|
+
if (!(0, import_node_fs8.existsSync)(sourceRoot)) {
|
|
15007
16441
|
throw new Error("Cannot find sourceRoot directory");
|
|
15008
16442
|
}
|
|
15009
16443
|
const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -15105,16 +16539,16 @@ async function resolveOptions(options) {
|
|
|
15105
16539
|
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
15106
16540
|
}
|
|
15107
16541
|
if (options.rollup) {
|
|
15108
|
-
let
|
|
16542
|
+
let rollup2 = {};
|
|
15109
16543
|
if (typeof options.rollup === "string") {
|
|
15110
16544
|
const rollupFile = await loadConfig2(options.rollup);
|
|
15111
16545
|
if (rollupFile) {
|
|
15112
|
-
|
|
16546
|
+
rollup2 = rollupFile;
|
|
15113
16547
|
}
|
|
15114
16548
|
} else {
|
|
15115
|
-
|
|
16549
|
+
rollup2 = options.rollup;
|
|
15116
16550
|
}
|
|
15117
|
-
resolvedOptions.rollup = (0,
|
|
16551
|
+
resolvedOptions.rollup = (0, import_defu5.default)(resolvedOptions.rollup ?? {}, rollup2);
|
|
15118
16552
|
}
|
|
15119
16553
|
resolvedOptions.hooks = {
|
|
15120
16554
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
@@ -15126,14 +16560,14 @@ async function resolveOptions(options) {
|
|
|
15126
16560
|
}
|
|
15127
16561
|
__name(resolveOptions, "resolveOptions");
|
|
15128
16562
|
async function generatePackageJson(options) {
|
|
15129
|
-
if (options.generatePackageJson !== false && (0,
|
|
16563
|
+
if (options.generatePackageJson !== false && (0, import_node_fs8.existsSync)(joinPaths(options.projectRoot, "package.json"))) {
|
|
15130
16564
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
15131
16565
|
const stopwatch = getStopwatch("Write package.json file");
|
|
15132
16566
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
15133
|
-
if (!(0,
|
|
16567
|
+
if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
|
|
15134
16568
|
throw new Error("Cannot find package.json configuration");
|
|
15135
16569
|
}
|
|
15136
|
-
let packageJsonContent = await (0,
|
|
16570
|
+
let packageJsonContent = await (0, import_promises7.readFile)(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
15137
16571
|
if (!packageJsonContent) {
|
|
15138
16572
|
throw new Error("Cannot find package.json configuration file");
|
|
15139
16573
|
}
|
|
@@ -15150,7 +16584,7 @@ async function executeUnbuild(options) {
|
|
|
15150
16584
|
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
15151
16585
|
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
15152
16586
|
try {
|
|
15153
|
-
await
|
|
16587
|
+
await build(options.projectRoot, false, {
|
|
15154
16588
|
...options,
|
|
15155
16589
|
rootDir: options.projectRoot
|
|
15156
16590
|
});
|
|
@@ -15175,7 +16609,7 @@ async function cleanOutputPath(options) {
|
|
|
15175
16609
|
return options;
|
|
15176
16610
|
}
|
|
15177
16611
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
15178
|
-
async function
|
|
16612
|
+
async function build2(options) {
|
|
15179
16613
|
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
|
|
15180
16614
|
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
15181
16615
|
try {
|
|
@@ -15192,7 +16626,7 @@ async function build(options) {
|
|
|
15192
16626
|
stopwatch();
|
|
15193
16627
|
}
|
|
15194
16628
|
}
|
|
15195
|
-
__name(
|
|
16629
|
+
__name(build2, "build");
|
|
15196
16630
|
|
|
15197
16631
|
// bin/unbuild.ts
|
|
15198
16632
|
async function createProgram(config) {
|
|
@@ -15270,7 +16704,7 @@ async function createProgram(config) {
|
|
|
15270
16704
|
__name(createProgram, "createProgram");
|
|
15271
16705
|
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
15272
16706
|
try {
|
|
15273
|
-
await
|
|
16707
|
+
await build2({
|
|
15274
16708
|
...options,
|
|
15275
16709
|
sourcemap: !!options.debug,
|
|
15276
16710
|
replace: {},
|