@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.mjs
CHANGED
|
@@ -495,7 +495,7 @@ var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
|
|
|
495
495
|
// ../config-tools/src/logger/console.ts
|
|
496
496
|
var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) => {
|
|
497
497
|
const _chalk = getChalk();
|
|
498
|
-
const
|
|
498
|
+
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;
|
|
499
499
|
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
500
500
|
if (typeof logLevel === "number" && (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel)) {
|
|
501
501
|
return (_2) => {
|
|
@@ -504,48 +504,48 @@ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) =>
|
|
|
504
504
|
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
|
|
505
505
|
return (message) => {
|
|
506
506
|
console.error(`
|
|
507
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
507
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
508
508
|
`);
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
|
|
512
512
|
return (message) => {
|
|
513
513
|
console.error(`
|
|
514
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
514
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
515
515
|
`);
|
|
516
516
|
};
|
|
517
517
|
}
|
|
518
518
|
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
|
|
519
519
|
return (message) => {
|
|
520
520
|
console.warn(`
|
|
521
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
521
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
522
522
|
`);
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
525
|
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel || typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel)) {
|
|
526
526
|
return (message) => {
|
|
527
527
|
console.info(`
|
|
528
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
528
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
529
529
|
`);
|
|
530
530
|
};
|
|
531
531
|
}
|
|
532
532
|
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
|
|
533
533
|
return (message) => {
|
|
534
534
|
console.info(`
|
|
535
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
535
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
536
536
|
`);
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
539
|
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel || typeof logLevel === "string" && LogLevel.TRACE >= getLogLevel(logLevel)) {
|
|
540
540
|
return (message) => {
|
|
541
541
|
console.debug(`
|
|
542
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
542
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
543
543
|
`);
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
return (message) => {
|
|
547
547
|
console.log(`
|
|
548
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
548
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
549
549
|
`);
|
|
550
550
|
};
|
|
551
551
|
}, "getLogFn");
|
|
@@ -1367,12 +1367,1442 @@ import { glob as glob2 } from "glob";
|
|
|
1367
1367
|
import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
|
|
1368
1368
|
|
|
1369
1369
|
// src/build.ts
|
|
1370
|
-
import
|
|
1371
|
-
import { existsSync as
|
|
1370
|
+
import defu4 from "defu";
|
|
1371
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
1372
1372
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
1373
|
-
import { relative as
|
|
1373
|
+
import { relative as relative5 } from "node:path";
|
|
1374
1374
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
1375
|
-
|
|
1375
|
+
|
|
1376
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
1377
|
+
import Module from "node:module";
|
|
1378
|
+
import { existsSync as existsSync5, readdirSync, statSync, promises } from "node:fs";
|
|
1379
|
+
import { join as join3, resolve, normalize, dirname, relative as relative2, extname, isAbsolute } from "pathe";
|
|
1380
|
+
import { colors } from "consola/utils";
|
|
1381
|
+
import consola$1, { consola } from "consola";
|
|
1382
|
+
import { defu as defu3 } from "defu";
|
|
1383
|
+
import { createHooks } from "hookable";
|
|
1384
|
+
import prettyBytes from "pretty-bytes";
|
|
1385
|
+
import { glob as glob3 } from "tinyglobby";
|
|
1386
|
+
import fsp, { mkdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
1387
|
+
import { createJiti } from "jiti";
|
|
1388
|
+
import { watch, rollup } from "rollup";
|
|
1389
|
+
import dts from "rollup-plugin-dts";
|
|
1390
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
1391
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
1392
|
+
import alias from "@rollup/plugin-alias";
|
|
1393
|
+
import replace from "@rollup/plugin-replace";
|
|
1394
|
+
import { resolveAlias } from "pathe/utils";
|
|
1395
|
+
import { findStaticImports, parseNodeModulePath, fileURLToPath, resolvePath, resolveModuleExportNames } from "mlly";
|
|
1396
|
+
import { transform as transform2 } from "esbuild";
|
|
1397
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
1398
|
+
import rollupJSONPlugin from "@rollup/plugin-json";
|
|
1399
|
+
import MagicString from "magic-string";
|
|
1400
|
+
import { resolveSchema, generateMarkdown, generateTypes } from "untyped";
|
|
1401
|
+
import untypedPlugin from "untyped/babel-plugin";
|
|
1402
|
+
import { pascalCase } from "scule";
|
|
1403
|
+
import { mkdist } from "mkdist";
|
|
1404
|
+
function definePreset(preset) {
|
|
1405
|
+
return preset;
|
|
1406
|
+
}
|
|
1407
|
+
__name(definePreset, "definePreset");
|
|
1408
|
+
var autoPreset = definePreset(() => {
|
|
1409
|
+
return {
|
|
1410
|
+
hooks: {
|
|
1411
|
+
"build:prepare"(ctx) {
|
|
1412
|
+
if (!ctx.pkg || ctx.options.entries.length > 0) {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
const sourceFiles = listRecursively(join3(ctx.options.rootDir, "src"));
|
|
1416
|
+
const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir);
|
|
1417
|
+
for (const message of res.warnings) {
|
|
1418
|
+
warn(ctx, message);
|
|
1419
|
+
}
|
|
1420
|
+
ctx.options.entries.push(...res.entries);
|
|
1421
|
+
if (res.cjs) {
|
|
1422
|
+
ctx.options.rollup.emitCJS = true;
|
|
1423
|
+
}
|
|
1424
|
+
if (ctx.options.declaration === void 0) {
|
|
1425
|
+
ctx.options.declaration = res.dts ? "compatible" : false;
|
|
1426
|
+
}
|
|
1427
|
+
consola.info(
|
|
1428
|
+
"Automatically detected entries:",
|
|
1429
|
+
colors.cyan(
|
|
1430
|
+
ctx.options.entries.map(
|
|
1431
|
+
(e) => colors.bold(
|
|
1432
|
+
e.input.replace(ctx.options.rootDir + "/", "").replace(/\/$/, "/*")
|
|
1433
|
+
)
|
|
1434
|
+
).join(", ")
|
|
1435
|
+
),
|
|
1436
|
+
colors.gray(
|
|
1437
|
+
["esm", res.cjs && "cjs", res.dts && "dts"].filter(Boolean).map((tag) => `[${tag}]`).join(" ")
|
|
1438
|
+
)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
});
|
|
1444
|
+
function inferEntries(pkg, sourceFiles, rootDir) {
|
|
1445
|
+
const warnings = [];
|
|
1446
|
+
sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length);
|
|
1447
|
+
const outputs = extractExportFilenames(pkg.exports);
|
|
1448
|
+
if (pkg.bin) {
|
|
1449
|
+
const binaries = typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin);
|
|
1450
|
+
for (const file of binaries) {
|
|
1451
|
+
outputs.push({ file });
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
if (pkg.main) {
|
|
1455
|
+
outputs.push({ file: pkg.main });
|
|
1456
|
+
}
|
|
1457
|
+
if (pkg.module) {
|
|
1458
|
+
outputs.push({ type: "esm", file: pkg.module });
|
|
1459
|
+
}
|
|
1460
|
+
if (pkg.types || pkg.typings) {
|
|
1461
|
+
outputs.push({ file: pkg.types || pkg.typings });
|
|
1462
|
+
}
|
|
1463
|
+
const isESMPkg = pkg.type === "module";
|
|
1464
|
+
for (const output of outputs.filter((o) => !o.type)) {
|
|
1465
|
+
const isJS = output.file.endsWith(".js");
|
|
1466
|
+
if (isESMPkg && isJS || output.file.endsWith(".mjs")) {
|
|
1467
|
+
output.type = "esm";
|
|
1468
|
+
} else if (!isESMPkg && isJS || output.file.endsWith(".cjs")) {
|
|
1469
|
+
output.type = "cjs";
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
let cjs = false;
|
|
1473
|
+
let dts2 = false;
|
|
1474
|
+
const entries = [];
|
|
1475
|
+
for (const output of outputs) {
|
|
1476
|
+
const outputSlug = output.file.replace(
|
|
1477
|
+
/(\*[^/\\]*|\.d\.(m|c)?ts|\.\w+)$/,
|
|
1478
|
+
""
|
|
1479
|
+
);
|
|
1480
|
+
const isDir = outputSlug.endsWith("/");
|
|
1481
|
+
if (isDir && ["./", "/"].includes(outputSlug)) {
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
const possiblePaths = getEntrypointPaths(outputSlug);
|
|
1485
|
+
const input = possiblePaths.reduce((source, d) => {
|
|
1486
|
+
if (source) {
|
|
1487
|
+
return source;
|
|
1488
|
+
}
|
|
1489
|
+
const SOURCE_RE = new RegExp(
|
|
1490
|
+
`(?<=/|$)${d}${isDir ? "" : String.raw`\.\w+`}$`
|
|
1491
|
+
);
|
|
1492
|
+
return sourceFiles.find((i) => SOURCE_RE.test(i))?.replace(/(\.d\.(m|c)?ts|\.\w+)$/, "");
|
|
1493
|
+
}, void 0);
|
|
1494
|
+
if (!input) {
|
|
1495
|
+
if (!existsSync5(resolve(rootDir || ".", output.file))) {
|
|
1496
|
+
warnings.push(`Could not find entrypoint for \`${output.file}\``);
|
|
1497
|
+
}
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
if (output.type === "cjs") {
|
|
1501
|
+
cjs = true;
|
|
1502
|
+
}
|
|
1503
|
+
const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1];
|
|
1504
|
+
if (/\.d\.(m|c)?ts$/.test(output.file)) {
|
|
1505
|
+
dts2 = true;
|
|
1506
|
+
}
|
|
1507
|
+
if (isDir) {
|
|
1508
|
+
entry.outDir = outputSlug;
|
|
1509
|
+
entry.format = output.type;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return { entries, cjs, dts: dts2, warnings };
|
|
1513
|
+
}
|
|
1514
|
+
__name(inferEntries, "inferEntries");
|
|
1515
|
+
var getEntrypointPaths = /* @__PURE__ */ __name((path3) => {
|
|
1516
|
+
const segments = normalize(path3).split("/");
|
|
1517
|
+
return segments.map((_2, index) => segments.slice(index).join("/")).filter(Boolean);
|
|
1518
|
+
}, "getEntrypointPaths");
|
|
1519
|
+
async function ensuredir(path3) {
|
|
1520
|
+
await fsp.mkdir(dirname(path3), { recursive: true });
|
|
1521
|
+
}
|
|
1522
|
+
__name(ensuredir, "ensuredir");
|
|
1523
|
+
function warn(ctx, message) {
|
|
1524
|
+
if (ctx.warnings.has(message)) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
consola.debug("[unbuild] [warn]", message);
|
|
1528
|
+
ctx.warnings.add(message);
|
|
1529
|
+
}
|
|
1530
|
+
__name(warn, "warn");
|
|
1531
|
+
async function symlink(from, to, force = true) {
|
|
1532
|
+
await ensuredir(to);
|
|
1533
|
+
if (force) {
|
|
1534
|
+
await fsp.unlink(to).catch(() => {
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
await fsp.symlink(from, to, "junction");
|
|
1538
|
+
}
|
|
1539
|
+
__name(symlink, "symlink");
|
|
1540
|
+
function dumpObject(obj) {
|
|
1541
|
+
return "{ " + Object.keys(obj).map((key) => `${key}: ${JSON.stringify(obj[key])}`).join(", ") + " }";
|
|
1542
|
+
}
|
|
1543
|
+
__name(dumpObject, "dumpObject");
|
|
1544
|
+
function getpkg(id = "") {
|
|
1545
|
+
const s = id.split("/");
|
|
1546
|
+
return s[0][0] === "@" ? `${s[0]}/${s[1]}` : s[0];
|
|
1547
|
+
}
|
|
1548
|
+
__name(getpkg, "getpkg");
|
|
1549
|
+
async function rmdir(dir) {
|
|
1550
|
+
await fsp.unlink(dir).catch(() => {
|
|
1551
|
+
});
|
|
1552
|
+
await fsp.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
__name(rmdir, "rmdir");
|
|
1556
|
+
function listRecursively(path3) {
|
|
1557
|
+
const filenames = /* @__PURE__ */ new Set();
|
|
1558
|
+
const walk = /* @__PURE__ */ __name((path22) => {
|
|
1559
|
+
const files = readdirSync(path22);
|
|
1560
|
+
for (const file of files) {
|
|
1561
|
+
const fullPath = resolve(path22, file);
|
|
1562
|
+
if (statSync(fullPath).isDirectory()) {
|
|
1563
|
+
filenames.add(fullPath + "/");
|
|
1564
|
+
walk(fullPath);
|
|
1565
|
+
} else {
|
|
1566
|
+
filenames.add(fullPath);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}, "walk");
|
|
1570
|
+
walk(path3);
|
|
1571
|
+
return [...filenames];
|
|
1572
|
+
}
|
|
1573
|
+
__name(listRecursively, "listRecursively");
|
|
1574
|
+
async function resolvePreset(preset, rootDir) {
|
|
1575
|
+
if (preset === "auto") {
|
|
1576
|
+
preset = autoPreset;
|
|
1577
|
+
} else if (typeof preset === "string") {
|
|
1578
|
+
preset = await createJiti(rootDir, { interopDefault: true }).import(preset, {
|
|
1579
|
+
default: true
|
|
1580
|
+
}) || {};
|
|
1581
|
+
}
|
|
1582
|
+
if (typeof preset === "function") {
|
|
1583
|
+
preset = preset();
|
|
1584
|
+
}
|
|
1585
|
+
return preset;
|
|
1586
|
+
}
|
|
1587
|
+
__name(resolvePreset, "resolvePreset");
|
|
1588
|
+
function inferExportType(condition, previousConditions = [], filename = "") {
|
|
1589
|
+
if (filename) {
|
|
1590
|
+
if (filename.endsWith(".d.ts")) {
|
|
1591
|
+
return "esm";
|
|
1592
|
+
}
|
|
1593
|
+
if (filename.endsWith(".mjs")) {
|
|
1594
|
+
return "esm";
|
|
1595
|
+
}
|
|
1596
|
+
if (filename.endsWith(".cjs")) {
|
|
1597
|
+
return "cjs";
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
switch (condition) {
|
|
1601
|
+
case "import": {
|
|
1602
|
+
return "esm";
|
|
1603
|
+
}
|
|
1604
|
+
case "require": {
|
|
1605
|
+
return "cjs";
|
|
1606
|
+
}
|
|
1607
|
+
default: {
|
|
1608
|
+
if (previousConditions.length === 0) {
|
|
1609
|
+
return "esm";
|
|
1610
|
+
}
|
|
1611
|
+
const [newCondition, ...rest] = previousConditions;
|
|
1612
|
+
return inferExportType(newCondition, rest, filename);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
__name(inferExportType, "inferExportType");
|
|
1617
|
+
function extractExportFilenames(exports, conditions = []) {
|
|
1618
|
+
if (!exports) {
|
|
1619
|
+
return [];
|
|
1620
|
+
}
|
|
1621
|
+
if (typeof exports === "string") {
|
|
1622
|
+
return [{ file: exports, type: "esm" }];
|
|
1623
|
+
}
|
|
1624
|
+
return Object.entries(exports).filter(([subpath]) => !subpath.endsWith(".json")).flatMap(
|
|
1625
|
+
([condition, exports2]) => typeof exports2 === "string" ? {
|
|
1626
|
+
file: exports2,
|
|
1627
|
+
type: inferExportType(condition, conditions, exports2)
|
|
1628
|
+
} : extractExportFilenames(exports2, [...conditions, condition])
|
|
1629
|
+
);
|
|
1630
|
+
}
|
|
1631
|
+
__name(extractExportFilenames, "extractExportFilenames");
|
|
1632
|
+
function arrayIncludes(arr, searchElement) {
|
|
1633
|
+
return arr.some(
|
|
1634
|
+
(entry) => entry instanceof RegExp ? entry.test(searchElement) : entry === searchElement
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
__name(arrayIncludes, "arrayIncludes");
|
|
1638
|
+
function removeExtension(filename) {
|
|
1639
|
+
return filename.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/, "");
|
|
1640
|
+
}
|
|
1641
|
+
__name(removeExtension, "removeExtension");
|
|
1642
|
+
function inferPkgExternals(pkg) {
|
|
1643
|
+
const externals = [
|
|
1644
|
+
...Object.keys(pkg.dependencies || {}),
|
|
1645
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
1646
|
+
...Object.keys(pkg.devDependencies || {}).filter(
|
|
1647
|
+
(dep) => dep.startsWith("@types/")
|
|
1648
|
+
),
|
|
1649
|
+
...Object.keys(pkg.optionalDependencies || {})
|
|
1650
|
+
];
|
|
1651
|
+
if (pkg.name) {
|
|
1652
|
+
externals.push(pkg.name);
|
|
1653
|
+
if (pkg.exports) {
|
|
1654
|
+
for (const subpath of Object.keys(pkg.exports)) {
|
|
1655
|
+
if (subpath.startsWith("./")) {
|
|
1656
|
+
externals.push(pathToRegex(`${pkg.name}/${subpath.slice(2)}`));
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
if (pkg.imports) {
|
|
1662
|
+
for (const importName of Object.keys(pkg.imports)) {
|
|
1663
|
+
if (importName.startsWith("#")) {
|
|
1664
|
+
externals.push(pathToRegex(importName));
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
return [...new Set(externals)];
|
|
1669
|
+
}
|
|
1670
|
+
__name(inferPkgExternals, "inferPkgExternals");
|
|
1671
|
+
function pathToRegex(path3) {
|
|
1672
|
+
return path3.includes("*") ? new RegExp(
|
|
1673
|
+
`^${path3.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`
|
|
1674
|
+
) : path3;
|
|
1675
|
+
}
|
|
1676
|
+
__name(pathToRegex, "pathToRegex");
|
|
1677
|
+
function withTrailingSlash(path3) {
|
|
1678
|
+
return path3.endsWith("/") ? path3 : `${path3}/`;
|
|
1679
|
+
}
|
|
1680
|
+
__name(withTrailingSlash, "withTrailingSlash");
|
|
1681
|
+
function validateDependencies(ctx) {
|
|
1682
|
+
const usedDependencies = /* @__PURE__ */ new Set();
|
|
1683
|
+
const unusedDependencies = new Set(
|
|
1684
|
+
Object.keys(ctx.pkg.dependencies || {})
|
|
1685
|
+
);
|
|
1686
|
+
const implicitDependencies = /* @__PURE__ */ new Set();
|
|
1687
|
+
for (const id of ctx.usedImports) {
|
|
1688
|
+
unusedDependencies.delete(id);
|
|
1689
|
+
usedDependencies.add(id);
|
|
1690
|
+
}
|
|
1691
|
+
if (Array.isArray(ctx.options.dependencies)) {
|
|
1692
|
+
for (const id of ctx.options.dependencies) {
|
|
1693
|
+
unusedDependencies.delete(id);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
for (const id of usedDependencies) {
|
|
1697
|
+
if (!arrayIncludes(ctx.options.externals, id) && !id.startsWith("chunks/") && !ctx.options.dependencies.includes(getpkg(id)) && !ctx.options.peerDependencies.includes(getpkg(id))) {
|
|
1698
|
+
implicitDependencies.add(id);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (unusedDependencies.size > 0) {
|
|
1702
|
+
warn(
|
|
1703
|
+
ctx,
|
|
1704
|
+
"Potential unused dependencies found: " + [...unusedDependencies].map((id) => colors.cyan(id)).join(", ")
|
|
1705
|
+
);
|
|
1706
|
+
}
|
|
1707
|
+
if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) {
|
|
1708
|
+
warn(
|
|
1709
|
+
ctx,
|
|
1710
|
+
"Potential implicit dependencies found: " + [...implicitDependencies].map((id) => colors.cyan(id)).join(", ")
|
|
1711
|
+
);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
__name(validateDependencies, "validateDependencies");
|
|
1715
|
+
function validatePackage(pkg, rootDir, ctx) {
|
|
1716
|
+
if (!pkg) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const filenames = new Set(
|
|
1720
|
+
[
|
|
1721
|
+
...typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {}),
|
|
1722
|
+
pkg.main,
|
|
1723
|
+
pkg.module,
|
|
1724
|
+
pkg.types,
|
|
1725
|
+
pkg.typings,
|
|
1726
|
+
...extractExportFilenames(pkg.exports).map((i) => i.file)
|
|
1727
|
+
].map((i) => i && resolve(rootDir, i.replace(/\/[^/]*\*.*$/, "")))
|
|
1728
|
+
);
|
|
1729
|
+
const missingOutputs = [];
|
|
1730
|
+
for (const filename of filenames) {
|
|
1731
|
+
if (filename && !filename.includes("*") && !existsSync5(filename)) {
|
|
1732
|
+
missingOutputs.push(filename.replace(rootDir + "/", ""));
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
if (missingOutputs.length > 0) {
|
|
1736
|
+
warn(
|
|
1737
|
+
ctx,
|
|
1738
|
+
`Potential missing package.json files: ${missingOutputs.map((o) => colors.cyan(o)).join(", ")}`
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
__name(validatePackage, "validatePackage");
|
|
1743
|
+
var SHEBANG_RE = /^#![^\n]*/;
|
|
1744
|
+
function shebangPlugin() {
|
|
1745
|
+
return {
|
|
1746
|
+
name: "unbuild-shebang",
|
|
1747
|
+
async writeBundle(options, bundle) {
|
|
1748
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1749
|
+
if (output.type !== "chunk") {
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
if (output.code?.match(SHEBANG_RE)) {
|
|
1753
|
+
const outFile = resolve(options.dir, fileName);
|
|
1754
|
+
await makeExecutable(outFile);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
__name(shebangPlugin, "shebangPlugin");
|
|
1761
|
+
function removeShebangPlugin() {
|
|
1762
|
+
return {
|
|
1763
|
+
name: "unbuild-remove-shebang",
|
|
1764
|
+
renderChunk(code) {
|
|
1765
|
+
return code.replace(SHEBANG_RE, "");
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
__name(removeShebangPlugin, "removeShebangPlugin");
|
|
1770
|
+
async function makeExecutable(filePath) {
|
|
1771
|
+
await promises.chmod(
|
|
1772
|
+
filePath,
|
|
1773
|
+
493
|
|
1774
|
+
/* rwx r-x r-x */
|
|
1775
|
+
).catch(() => {
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
__name(makeExecutable, "makeExecutable");
|
|
1779
|
+
function getShebang(code, append = "\n") {
|
|
1780
|
+
const m = code.match(SHEBANG_RE);
|
|
1781
|
+
return m ? m + append : "";
|
|
1782
|
+
}
|
|
1783
|
+
__name(getShebang, "getShebang");
|
|
1784
|
+
var DefaultLoaders = {
|
|
1785
|
+
".js": "js",
|
|
1786
|
+
".mjs": "js",
|
|
1787
|
+
".cjs": "js",
|
|
1788
|
+
".ts": "ts",
|
|
1789
|
+
".mts": "ts",
|
|
1790
|
+
".cts": "ts",
|
|
1791
|
+
".tsx": "tsx",
|
|
1792
|
+
".jsx": "jsx"
|
|
1793
|
+
};
|
|
1794
|
+
function esbuild(options) {
|
|
1795
|
+
const {
|
|
1796
|
+
include = new RegExp(Object.keys(DefaultLoaders).join("|")),
|
|
1797
|
+
exclude = /node_modules/,
|
|
1798
|
+
loaders: loaderOptions,
|
|
1799
|
+
...esbuildOptions
|
|
1800
|
+
} = options;
|
|
1801
|
+
const loaders = { ...DefaultLoaders };
|
|
1802
|
+
if (loaderOptions) {
|
|
1803
|
+
for (const [key, value] of Object.entries(loaderOptions)) {
|
|
1804
|
+
if (typeof value === "string") {
|
|
1805
|
+
loaders[key] = value;
|
|
1806
|
+
} else if (value === false) {
|
|
1807
|
+
delete loaders[key];
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const getLoader = /* @__PURE__ */ __name((id = "") => {
|
|
1812
|
+
return loaders[extname(id)];
|
|
1813
|
+
}, "getLoader");
|
|
1814
|
+
const filter = createFilter(include, exclude);
|
|
1815
|
+
return {
|
|
1816
|
+
name: "esbuild",
|
|
1817
|
+
async transform(code, id) {
|
|
1818
|
+
if (!filter(id)) {
|
|
1819
|
+
return null;
|
|
1820
|
+
}
|
|
1821
|
+
const loader = getLoader(id);
|
|
1822
|
+
if (!loader) {
|
|
1823
|
+
return null;
|
|
1824
|
+
}
|
|
1825
|
+
const result = await transform2(code, {
|
|
1826
|
+
...esbuildOptions,
|
|
1827
|
+
loader,
|
|
1828
|
+
sourcefile: id
|
|
1829
|
+
});
|
|
1830
|
+
printWarnings(id, result, this);
|
|
1831
|
+
return {
|
|
1832
|
+
code: result.code || "",
|
|
1833
|
+
map: result.map || null
|
|
1834
|
+
};
|
|
1835
|
+
},
|
|
1836
|
+
async renderChunk(code, { fileName }) {
|
|
1837
|
+
if (!options.minify) {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1840
|
+
if (/\.d\.(c|m)?tsx?$/.test(fileName)) {
|
|
1841
|
+
return null;
|
|
1842
|
+
}
|
|
1843
|
+
const loader = getLoader(fileName);
|
|
1844
|
+
if (!loader) {
|
|
1845
|
+
return null;
|
|
1846
|
+
}
|
|
1847
|
+
const result = await transform2(code, {
|
|
1848
|
+
...esbuildOptions,
|
|
1849
|
+
loader,
|
|
1850
|
+
sourcefile: fileName,
|
|
1851
|
+
minify: true
|
|
1852
|
+
});
|
|
1853
|
+
return {
|
|
1854
|
+
code: result.code || "",
|
|
1855
|
+
map: result.map || null
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
__name(esbuild, "esbuild");
|
|
1861
|
+
function printWarnings(id, result, plugin) {
|
|
1862
|
+
if (result.warnings) {
|
|
1863
|
+
for (const warning of result.warnings) {
|
|
1864
|
+
let message = "[esbuild]";
|
|
1865
|
+
if (warning.location) {
|
|
1866
|
+
message += ` (${relative2(process.cwd(), id)}:${warning.location.line}:${warning.location.column})`;
|
|
1867
|
+
}
|
|
1868
|
+
message += ` ${warning.text}`;
|
|
1869
|
+
plugin.warn(message);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
__name(printWarnings, "printWarnings");
|
|
1874
|
+
var EXPORT_DEFAULT = "export default ";
|
|
1875
|
+
function JSONPlugin(options) {
|
|
1876
|
+
const plugin = rollupJSONPlugin(options);
|
|
1877
|
+
return {
|
|
1878
|
+
...plugin,
|
|
1879
|
+
name: "unbuild-json",
|
|
1880
|
+
transform(code, id) {
|
|
1881
|
+
const res = plugin.transform.call(this, code, id);
|
|
1882
|
+
if (res && typeof res !== "string" && "code" in res && res.code && res.code.startsWith(EXPORT_DEFAULT)) {
|
|
1883
|
+
res.code = res.code.replace(EXPORT_DEFAULT, "module.exports = ");
|
|
1884
|
+
}
|
|
1885
|
+
return res;
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
__name(JSONPlugin, "JSONPlugin");
|
|
1890
|
+
var defaults = {
|
|
1891
|
+
include: [/\.(md|txt|css|htm|html)$/],
|
|
1892
|
+
exclude: []
|
|
1893
|
+
};
|
|
1894
|
+
function rawPlugin(opts = {}) {
|
|
1895
|
+
opts = { ...opts, ...defaults };
|
|
1896
|
+
const filter = createFilter(opts.include, opts.exclude);
|
|
1897
|
+
return {
|
|
1898
|
+
name: "unbuild-raw",
|
|
1899
|
+
transform(code, id) {
|
|
1900
|
+
if (filter(id)) {
|
|
1901
|
+
return {
|
|
1902
|
+
code: `export default ${JSON.stringify(code)}`,
|
|
1903
|
+
map: null
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
__name(rawPlugin, "rawPlugin");
|
|
1910
|
+
function cjsPlugin(_opts) {
|
|
1911
|
+
return {
|
|
1912
|
+
name: "unbuild-cjs",
|
|
1913
|
+
renderChunk(code, _chunk, opts) {
|
|
1914
|
+
if (opts.format === "es") {
|
|
1915
|
+
return CJSToESM(code);
|
|
1916
|
+
}
|
|
1917
|
+
return null;
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
__name(cjsPlugin, "cjsPlugin");
|
|
1922
|
+
function fixCJSExportTypePlugin() {
|
|
1923
|
+
return {
|
|
1924
|
+
name: "unbuild-fix-cjs-export-type",
|
|
1925
|
+
renderChunk(code, info, opts) {
|
|
1926
|
+
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || info.exports?.length !== 1 || info.exports[0] !== "default") {
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1929
|
+
return code.replace(
|
|
1930
|
+
/(?<=(?<=[;}]|^)\s*export\s*){\s*([\w$]+)\s*as\s+default\s*}/,
|
|
1931
|
+
`= $1`
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
__name(fixCJSExportTypePlugin, "fixCJSExportTypePlugin");
|
|
1937
|
+
var CJSyntaxRe = /__filename|__dirname|require\(|require\.resolve\(/;
|
|
1938
|
+
var CJSShim = `
|
|
1939
|
+
|
|
1940
|
+
// -- Unbuild CommonJS Shims --
|
|
1941
|
+
import __cjs_url__ from 'url';
|
|
1942
|
+
import __cjs_path__ from 'path';
|
|
1943
|
+
import __cjs_mod__ from 'module';
|
|
1944
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
1945
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
1946
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
1947
|
+
`;
|
|
1948
|
+
function CJSToESM(code) {
|
|
1949
|
+
if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) {
|
|
1950
|
+
return null;
|
|
1951
|
+
}
|
|
1952
|
+
const lastESMImport = findStaticImports(code).pop();
|
|
1953
|
+
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
|
|
1954
|
+
const s = new MagicString(code);
|
|
1955
|
+
s.appendRight(indexToAppend, CJSShim);
|
|
1956
|
+
return {
|
|
1957
|
+
code: s.toString(),
|
|
1958
|
+
map: s.generateMap()
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
__name(CJSToESM, "CJSToESM");
|
|
1962
|
+
var DEFAULT_EXTENSIONS = [
|
|
1963
|
+
".ts",
|
|
1964
|
+
".tsx",
|
|
1965
|
+
".mts",
|
|
1966
|
+
".cts",
|
|
1967
|
+
".mjs",
|
|
1968
|
+
".cjs",
|
|
1969
|
+
".js",
|
|
1970
|
+
".jsx",
|
|
1971
|
+
".json"
|
|
1972
|
+
];
|
|
1973
|
+
function resolveAliases(ctx) {
|
|
1974
|
+
const aliases = {
|
|
1975
|
+
[ctx.pkg.name]: ctx.options.rootDir,
|
|
1976
|
+
...ctx.options.alias
|
|
1977
|
+
};
|
|
1978
|
+
if (ctx.options.rollup.alias) {
|
|
1979
|
+
if (Array.isArray(ctx.options.rollup.alias.entries)) {
|
|
1980
|
+
Object.assign(
|
|
1981
|
+
aliases,
|
|
1982
|
+
Object.fromEntries(
|
|
1983
|
+
ctx.options.rollup.alias.entries.map((entry) => {
|
|
1984
|
+
return [entry.find, entry.replacement];
|
|
1985
|
+
})
|
|
1986
|
+
)
|
|
1987
|
+
);
|
|
1988
|
+
} else {
|
|
1989
|
+
Object.assign(
|
|
1990
|
+
aliases,
|
|
1991
|
+
ctx.options.rollup.alias.entries || ctx.options.rollup.alias
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return aliases;
|
|
1996
|
+
}
|
|
1997
|
+
__name(resolveAliases, "resolveAliases");
|
|
1998
|
+
function getChunkFilename(ctx, chunk, ext) {
|
|
1999
|
+
if (chunk.isDynamicEntry) {
|
|
2000
|
+
return `chunks/[name].${ext}`;
|
|
2001
|
+
}
|
|
2002
|
+
return `shared/${ctx.options.name}.[hash].${ext}`;
|
|
2003
|
+
}
|
|
2004
|
+
__name(getChunkFilename, "getChunkFilename");
|
|
2005
|
+
function getRollupOptions(ctx) {
|
|
2006
|
+
const _aliases = resolveAliases(ctx);
|
|
2007
|
+
return {
|
|
2008
|
+
input: Object.fromEntries(
|
|
2009
|
+
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [
|
|
2010
|
+
entry.name,
|
|
2011
|
+
resolve(ctx.options.rootDir, entry.input)
|
|
2012
|
+
])
|
|
2013
|
+
),
|
|
2014
|
+
output: [
|
|
2015
|
+
ctx.options.rollup.emitCJS && {
|
|
2016
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2017
|
+
entryFileNames: "[name].cjs",
|
|
2018
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "cjs"), "chunkFileNames"),
|
|
2019
|
+
format: "cjs",
|
|
2020
|
+
exports: "auto",
|
|
2021
|
+
interop: "compat",
|
|
2022
|
+
generatedCode: { constBindings: true },
|
|
2023
|
+
externalLiveBindings: false,
|
|
2024
|
+
freeze: false,
|
|
2025
|
+
sourcemap: ctx.options.sourcemap,
|
|
2026
|
+
...ctx.options.rollup.output
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2030
|
+
entryFileNames: "[name].mjs",
|
|
2031
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "mjs"), "chunkFileNames"),
|
|
2032
|
+
format: "esm",
|
|
2033
|
+
exports: "auto",
|
|
2034
|
+
generatedCode: { constBindings: true },
|
|
2035
|
+
externalLiveBindings: false,
|
|
2036
|
+
freeze: false,
|
|
2037
|
+
sourcemap: ctx.options.sourcemap,
|
|
2038
|
+
...ctx.options.rollup.output
|
|
2039
|
+
}
|
|
2040
|
+
].filter(Boolean),
|
|
2041
|
+
external(originalId) {
|
|
2042
|
+
const resolvedId = resolveAlias(originalId, _aliases);
|
|
2043
|
+
const pkgName = parseNodeModulePath(resolvedId)?.name || parseNodeModulePath(originalId)?.name || getpkg(originalId);
|
|
2044
|
+
if (arrayIncludes(ctx.options.externals, pkgName) || arrayIncludes(ctx.options.externals, originalId) || arrayIncludes(ctx.options.externals, resolvedId)) {
|
|
2045
|
+
return true;
|
|
2046
|
+
}
|
|
2047
|
+
for (const id of [originalId, resolvedId]) {
|
|
2048
|
+
if (id[0] === "." || isAbsolute(id) || /src[/\\]/.test(id) || id.startsWith(ctx.pkg.name)) {
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
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))) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
warn(ctx, `Implicitly bundling "${originalId}"`);
|
|
2056
|
+
return false;
|
|
2057
|
+
},
|
|
2058
|
+
onwarn(warning, rollupWarn) {
|
|
2059
|
+
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
2060
|
+
rollupWarn(warning);
|
|
2061
|
+
}
|
|
2062
|
+
},
|
|
2063
|
+
plugins: [
|
|
2064
|
+
ctx.options.rollup.replace && replace({
|
|
2065
|
+
...ctx.options.rollup.replace,
|
|
2066
|
+
values: {
|
|
2067
|
+
...ctx.options.replace,
|
|
2068
|
+
...ctx.options.rollup.replace.values
|
|
2069
|
+
}
|
|
2070
|
+
}),
|
|
2071
|
+
ctx.options.rollup.alias && alias({
|
|
2072
|
+
...ctx.options.rollup.alias,
|
|
2073
|
+
entries: _aliases
|
|
2074
|
+
}),
|
|
2075
|
+
ctx.options.rollup.resolve && nodeResolve({
|
|
2076
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2077
|
+
exportConditions: ["production"],
|
|
2078
|
+
...ctx.options.rollup.resolve
|
|
2079
|
+
}),
|
|
2080
|
+
ctx.options.rollup.json && JSONPlugin({
|
|
2081
|
+
...ctx.options.rollup.json
|
|
2082
|
+
}),
|
|
2083
|
+
shebangPlugin(),
|
|
2084
|
+
ctx.options.rollup.esbuild && esbuild({
|
|
2085
|
+
sourcemap: ctx.options.sourcemap,
|
|
2086
|
+
...ctx.options.rollup.esbuild
|
|
2087
|
+
}),
|
|
2088
|
+
ctx.options.rollup.commonjs && commonjs({
|
|
2089
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2090
|
+
...ctx.options.rollup.commonjs
|
|
2091
|
+
}),
|
|
2092
|
+
ctx.options.rollup.preserveDynamicImports && {
|
|
2093
|
+
renderDynamicImport() {
|
|
2094
|
+
return { left: "import(", right: ")" };
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
ctx.options.rollup.cjsBridge && cjsPlugin(),
|
|
2098
|
+
rawPlugin()
|
|
2099
|
+
].filter(Boolean)
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
__name(getRollupOptions, "getRollupOptions");
|
|
2103
|
+
async function rollupStub(ctx) {
|
|
2104
|
+
const babelPlugins = ctx.options.stubOptions.jiti.transformOptions?.babel?.plugins;
|
|
2105
|
+
const importedBabelPlugins = [];
|
|
2106
|
+
const serializedJitiOptions = JSON.stringify(
|
|
2107
|
+
{
|
|
2108
|
+
...ctx.options.stubOptions.jiti,
|
|
2109
|
+
alias: {
|
|
2110
|
+
...resolveAliases(ctx),
|
|
2111
|
+
...ctx.options.stubOptions.jiti.alias
|
|
2112
|
+
},
|
|
2113
|
+
transformOptions: {
|
|
2114
|
+
...ctx.options.stubOptions.jiti.transformOptions,
|
|
2115
|
+
babel: {
|
|
2116
|
+
...ctx.options.stubOptions.jiti.transformOptions?.babel,
|
|
2117
|
+
plugins: "__$BABEL_PLUGINS"
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
},
|
|
2121
|
+
null,
|
|
2122
|
+
2
|
|
2123
|
+
).replace(
|
|
2124
|
+
'"__$BABEL_PLUGINS"',
|
|
2125
|
+
Array.isArray(babelPlugins) ? "[" + babelPlugins.map((plugin, i) => {
|
|
2126
|
+
if (Array.isArray(plugin)) {
|
|
2127
|
+
const [name, ...args] = plugin;
|
|
2128
|
+
importedBabelPlugins.push(name);
|
|
2129
|
+
return `[` + [
|
|
2130
|
+
`plugin${i}`,
|
|
2131
|
+
...args.map((val) => JSON.stringify(val))
|
|
2132
|
+
].join(", ") + "]";
|
|
2133
|
+
} else {
|
|
2134
|
+
importedBabelPlugins.push(plugin);
|
|
2135
|
+
return `plugin${i}`;
|
|
2136
|
+
}
|
|
2137
|
+
}).join(",") + "]" : "[]"
|
|
2138
|
+
);
|
|
2139
|
+
for (const entry of ctx.options.entries.filter(
|
|
2140
|
+
(entry2) => entry2.builder === "rollup"
|
|
2141
|
+
)) {
|
|
2142
|
+
const output = resolve(
|
|
2143
|
+
ctx.options.rootDir,
|
|
2144
|
+
ctx.options.outDir,
|
|
2145
|
+
entry.name
|
|
2146
|
+
);
|
|
2147
|
+
const isESM = ctx.pkg.type === "module";
|
|
2148
|
+
const resolvedEntry = fileURLToPath(ctx.jiti.esmResolve(entry.input));
|
|
2149
|
+
const resolvedEntryWithoutExt = resolvedEntry.slice(
|
|
2150
|
+
0,
|
|
2151
|
+
Math.max(0, resolvedEntry.length - extname(resolvedEntry).length)
|
|
2152
|
+
);
|
|
2153
|
+
const resolvedEntryForTypeImport = isESM ? `${resolvedEntry.replace(/(\.m?)(ts)$/, "$1js")}` : resolvedEntryWithoutExt;
|
|
2154
|
+
const code = await promises.readFile(resolvedEntry, "utf8");
|
|
2155
|
+
const shebang = getShebang(code);
|
|
2156
|
+
await mkdir(dirname(output), { recursive: true });
|
|
2157
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2158
|
+
const jitiCJSPath = relative2(
|
|
2159
|
+
dirname(output),
|
|
2160
|
+
await resolvePath("jiti", {
|
|
2161
|
+
url: import.meta.url,
|
|
2162
|
+
conditions: ["node", "require"]
|
|
2163
|
+
})
|
|
2164
|
+
);
|
|
2165
|
+
await writeFile2(
|
|
2166
|
+
output + ".cjs",
|
|
2167
|
+
shebang + [
|
|
2168
|
+
`const { createJiti } = require(${JSON.stringify(jitiCJSPath)})`,
|
|
2169
|
+
...importedBabelPlugins.map(
|
|
2170
|
+
(plugin, i) => `const plugin${i} = require(${JSON.stringify(plugin)})`
|
|
2171
|
+
),
|
|
2172
|
+
"",
|
|
2173
|
+
`const jiti = createJiti(__filename, ${serializedJitiOptions})`,
|
|
2174
|
+
"",
|
|
2175
|
+
`/** @type {import(${JSON.stringify(
|
|
2176
|
+
resolvedEntryForTypeImport
|
|
2177
|
+
)})} */`,
|
|
2178
|
+
`module.exports = jiti(${JSON.stringify(resolvedEntry)})`
|
|
2179
|
+
].join("\n")
|
|
2180
|
+
);
|
|
2181
|
+
}
|
|
2182
|
+
const namedExports = await resolveModuleExportNames(
|
|
2183
|
+
resolvedEntry,
|
|
2184
|
+
{
|
|
2185
|
+
extensions: DEFAULT_EXTENSIONS
|
|
2186
|
+
}
|
|
2187
|
+
).catch((error) => {
|
|
2188
|
+
warn(ctx, `Cannot analyze ${resolvedEntry} for exports:` + error);
|
|
2189
|
+
return [];
|
|
2190
|
+
});
|
|
2191
|
+
const hasDefaultExport = namedExports.includes("default") || namedExports.length === 0;
|
|
2192
|
+
const jitiESMPath = relative2(
|
|
2193
|
+
dirname(output),
|
|
2194
|
+
await resolvePath("jiti", {
|
|
2195
|
+
url: import.meta.url,
|
|
2196
|
+
conditions: ["node", "import"]
|
|
2197
|
+
})
|
|
2198
|
+
);
|
|
2199
|
+
await writeFile2(
|
|
2200
|
+
output + ".mjs",
|
|
2201
|
+
shebang + [
|
|
2202
|
+
`import { createJiti } from ${JSON.stringify(jitiESMPath)};`,
|
|
2203
|
+
...importedBabelPlugins.map(
|
|
2204
|
+
(plugin, i) => `import plugin${i} from ${JSON.stringify(plugin)}`
|
|
2205
|
+
),
|
|
2206
|
+
"",
|
|
2207
|
+
`const jiti = createJiti(import.meta.url, ${serializedJitiOptions})`,
|
|
2208
|
+
"",
|
|
2209
|
+
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
2210
|
+
`const _module = await jiti.import(${JSON.stringify(
|
|
2211
|
+
resolvedEntry
|
|
2212
|
+
)});`,
|
|
2213
|
+
hasDefaultExport ? "\nexport default _module?.default ?? _module;" : "",
|
|
2214
|
+
...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)
|
|
2215
|
+
].join("\n")
|
|
2216
|
+
);
|
|
2217
|
+
if (ctx.options.declaration) {
|
|
2218
|
+
const dtsContent = [
|
|
2219
|
+
`export * from ${JSON.stringify(resolvedEntryForTypeImport)};`,
|
|
2220
|
+
hasDefaultExport ? `export { default } from ${JSON.stringify(resolvedEntryForTypeImport)};` : ""
|
|
2221
|
+
].join("\n");
|
|
2222
|
+
await writeFile2(output + ".d.cts", dtsContent);
|
|
2223
|
+
await writeFile2(output + ".d.mts", dtsContent);
|
|
2224
|
+
if (ctx.options.declaration === "compatible" || ctx.options.declaration === true) {
|
|
2225
|
+
await writeFile2(output + ".d.ts", dtsContent);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
if (shebang) {
|
|
2229
|
+
await makeExecutable(output + ".cjs");
|
|
2230
|
+
await makeExecutable(output + ".mjs");
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
__name(rollupStub, "rollupStub");
|
|
2235
|
+
function rollupWatch(rollupOptions) {
|
|
2236
|
+
const watcher = watch(rollupOptions);
|
|
2237
|
+
let inputs;
|
|
2238
|
+
if (Array.isArray(rollupOptions.input)) {
|
|
2239
|
+
inputs = rollupOptions.input;
|
|
2240
|
+
} else if (typeof rollupOptions.input === "string") {
|
|
2241
|
+
inputs = [rollupOptions.input];
|
|
2242
|
+
} else {
|
|
2243
|
+
inputs = Object.keys(rollupOptions.input || {});
|
|
2244
|
+
}
|
|
2245
|
+
consola$1.info(
|
|
2246
|
+
`[unbuild] [rollup] Starting watchers for entries: ${inputs.map((input) => "./" + relative2(process.cwd(), input)).join(", ")}`
|
|
2247
|
+
);
|
|
2248
|
+
consola$1.warn(
|
|
2249
|
+
"[unbuild] [rollup] Watch mode is experimental and may be unstable"
|
|
2250
|
+
);
|
|
2251
|
+
watcher.on("change", (id, { event }) => {
|
|
2252
|
+
consola$1.info(`${colors.cyan(relative2(".", id))} was ${event}d`);
|
|
2253
|
+
});
|
|
2254
|
+
watcher.on("restart", () => {
|
|
2255
|
+
consola$1.info(colors.gray("[unbuild] [rollup] Rebuilding bundle"));
|
|
2256
|
+
});
|
|
2257
|
+
watcher.on("event", (event) => {
|
|
2258
|
+
if (event.code === "END") {
|
|
2259
|
+
consola$1.success(colors.green("[unbuild] [rollup] Rebuild finished\n"));
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
__name(rollupWatch, "rollupWatch");
|
|
2264
|
+
async function rollupBuild(ctx) {
|
|
2265
|
+
if (ctx.options.stub) {
|
|
2266
|
+
await rollupStub(ctx);
|
|
2267
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
const rollupOptions = getRollupOptions(ctx);
|
|
2271
|
+
await ctx.hooks.callHook("rollup:options", ctx, rollupOptions);
|
|
2272
|
+
if (Object.keys(rollupOptions.input).length === 0) {
|
|
2273
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
const buildResult = await rollup(rollupOptions);
|
|
2277
|
+
await ctx.hooks.callHook("rollup:build", ctx, buildResult);
|
|
2278
|
+
const allOutputOptions = rollupOptions.output;
|
|
2279
|
+
for (const outputOptions of allOutputOptions) {
|
|
2280
|
+
const { output } = await buildResult.write(outputOptions);
|
|
2281
|
+
const chunkFileNames = /* @__PURE__ */ new Set();
|
|
2282
|
+
const outputChunks = output.filter(
|
|
2283
|
+
(e) => e.type === "chunk"
|
|
2284
|
+
);
|
|
2285
|
+
for (const entry of outputChunks) {
|
|
2286
|
+
chunkFileNames.add(entry.fileName);
|
|
2287
|
+
for (const id of entry.imports) {
|
|
2288
|
+
ctx.usedImports.add(id);
|
|
2289
|
+
}
|
|
2290
|
+
if (entry.isEntry) {
|
|
2291
|
+
ctx.buildEntries.push({
|
|
2292
|
+
chunks: entry.imports.filter(
|
|
2293
|
+
(i) => outputChunks.find((c) => c.fileName === i)
|
|
2294
|
+
),
|
|
2295
|
+
modules: Object.entries(entry.modules).map(([id, mod]) => ({
|
|
2296
|
+
id,
|
|
2297
|
+
bytes: mod.renderedLength
|
|
2298
|
+
})),
|
|
2299
|
+
path: entry.fileName,
|
|
2300
|
+
bytes: Buffer.byteLength(entry.code, "utf8"),
|
|
2301
|
+
exports: entry.exports
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
for (const chunkFileName of chunkFileNames) {
|
|
2306
|
+
ctx.usedImports.delete(chunkFileName);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
if (ctx.options.watch) {
|
|
2310
|
+
rollupWatch(rollupOptions);
|
|
2311
|
+
if (ctx.options.declaration && ctx.options.watch) {
|
|
2312
|
+
consola$1.warn("`rollup` DTS builder does not support watch mode yet.");
|
|
2313
|
+
}
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
if (ctx.options.declaration) {
|
|
2317
|
+
rollupOptions.plugins = [
|
|
2318
|
+
...rollupOptions.plugins,
|
|
2319
|
+
dts(ctx.options.rollup.dts),
|
|
2320
|
+
removeShebangPlugin(),
|
|
2321
|
+
ctx.options.rollup.emitCJS && fixCJSExportTypePlugin()
|
|
2322
|
+
].filter(Boolean);
|
|
2323
|
+
await ctx.hooks.callHook("rollup:dts:options", ctx, rollupOptions);
|
|
2324
|
+
const typesBuild2 = await rollup(rollupOptions);
|
|
2325
|
+
await ctx.hooks.callHook("rollup:dts:build", ctx, typesBuild2);
|
|
2326
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2327
|
+
await typesBuild2.write({
|
|
2328
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2329
|
+
entryFileNames: "[name].d.cts",
|
|
2330
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.cts"), "chunkFileNames")
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
await typesBuild2.write({
|
|
2334
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2335
|
+
entryFileNames: "[name].d.mts",
|
|
2336
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.mts"), "chunkFileNames")
|
|
2337
|
+
});
|
|
2338
|
+
if (ctx.options.declaration === true || ctx.options.declaration === "compatible") {
|
|
2339
|
+
await typesBuild2.write({
|
|
2340
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2341
|
+
entryFileNames: "[name].d.ts",
|
|
2342
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.ts"), "chunkFileNames")
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2347
|
+
}
|
|
2348
|
+
__name(rollupBuild, "rollupBuild");
|
|
2349
|
+
async function typesBuild(ctx) {
|
|
2350
|
+
const entries = ctx.options.entries.filter(
|
|
2351
|
+
(entry) => entry.builder === "untyped"
|
|
2352
|
+
);
|
|
2353
|
+
await ctx.hooks.callHook("untyped:entries", ctx, entries);
|
|
2354
|
+
for (const entry of entries) {
|
|
2355
|
+
const options = {
|
|
2356
|
+
jiti: {
|
|
2357
|
+
interopDefault: true,
|
|
2358
|
+
transformOptions: {
|
|
2359
|
+
babel: {
|
|
2360
|
+
plugins: [untypedPlugin]
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
await ctx.hooks.callHook("untyped:entry:options", ctx, entry, options);
|
|
2366
|
+
const untypedJiti = createJiti(ctx.options.rootDir, options.jiti);
|
|
2367
|
+
const distDir = entry.outDir;
|
|
2368
|
+
let rawSchema = await untypedJiti.import(resolve(ctx.options.rootDir, entry.input), {
|
|
2369
|
+
try: true
|
|
2370
|
+
}) || {};
|
|
2371
|
+
const rawSchemaKeys = Object.keys(rawSchema);
|
|
2372
|
+
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
|
|
2373
|
+
rawSchema = rawSchema.default;
|
|
2374
|
+
}
|
|
2375
|
+
const defaults2 = entry.defaults || {};
|
|
2376
|
+
const schema = await resolveSchema(rawSchema, defaults2);
|
|
2377
|
+
await ctx.hooks.callHook("untyped:entry:schema", ctx, entry, schema);
|
|
2378
|
+
const outputs = {
|
|
2379
|
+
markdown: {
|
|
2380
|
+
fileName: resolve(distDir, `${entry.name}.md`),
|
|
2381
|
+
contents: generateMarkdown(schema)
|
|
2382
|
+
},
|
|
2383
|
+
schema: {
|
|
2384
|
+
fileName: `${entry.name}.schema.json`,
|
|
2385
|
+
contents: JSON.stringify(schema, null, 2)
|
|
2386
|
+
},
|
|
2387
|
+
defaults: {
|
|
2388
|
+
fileName: `${entry.name}.defaults.json`,
|
|
2389
|
+
contents: JSON.stringify(defaults2, null, 2)
|
|
2390
|
+
},
|
|
2391
|
+
declaration: entry.declaration ? {
|
|
2392
|
+
fileName: `${entry.name}.d.ts`,
|
|
2393
|
+
contents: generateTypes(schema, {
|
|
2394
|
+
interfaceName: pascalCase(entry.name + "-schema")
|
|
2395
|
+
})
|
|
2396
|
+
} : void 0
|
|
2397
|
+
};
|
|
2398
|
+
await ctx.hooks.callHook("untyped:entry:outputs", ctx, entry, outputs);
|
|
2399
|
+
for (const output of Object.values(outputs)) {
|
|
2400
|
+
if (!output) continue;
|
|
2401
|
+
await writeFile2(
|
|
2402
|
+
resolve(distDir, output.fileName),
|
|
2403
|
+
output.contents,
|
|
2404
|
+
"utf8"
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
await ctx.hooks.callHook("untyped:done", ctx);
|
|
2409
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2410
|
+
consola$1.warn("`untyped` builder does not support watch mode yet.");
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
__name(typesBuild, "typesBuild");
|
|
2414
|
+
async function mkdistBuild(ctx) {
|
|
2415
|
+
const entries = ctx.options.entries.filter(
|
|
2416
|
+
(e) => e.builder === "mkdist"
|
|
2417
|
+
);
|
|
2418
|
+
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
2419
|
+
for (const entry of entries) {
|
|
2420
|
+
const distDir = entry.outDir;
|
|
2421
|
+
if (ctx.options.stub) {
|
|
2422
|
+
await rmdir(distDir);
|
|
2423
|
+
await symlink(entry.input, distDir);
|
|
2424
|
+
} else {
|
|
2425
|
+
const mkdistOptions = {
|
|
2426
|
+
rootDir: ctx.options.rootDir,
|
|
2427
|
+
srcDir: entry.input,
|
|
2428
|
+
distDir,
|
|
2429
|
+
cleanDist: false,
|
|
2430
|
+
...entry
|
|
2431
|
+
};
|
|
2432
|
+
await ctx.hooks.callHook(
|
|
2433
|
+
"mkdist:entry:options",
|
|
2434
|
+
ctx,
|
|
2435
|
+
entry,
|
|
2436
|
+
mkdistOptions
|
|
2437
|
+
);
|
|
2438
|
+
const output = await mkdist(mkdistOptions);
|
|
2439
|
+
ctx.buildEntries.push({
|
|
2440
|
+
path: distDir,
|
|
2441
|
+
chunks: output.writtenFiles.map((p) => relative2(ctx.options.outDir, p))
|
|
2442
|
+
});
|
|
2443
|
+
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
2444
|
+
if (output.errors) {
|
|
2445
|
+
for (const error of output.errors) {
|
|
2446
|
+
warn(
|
|
2447
|
+
ctx,
|
|
2448
|
+
`mkdist build failed for \`${relative2(ctx.options.rootDir, error.filename)}\`:
|
|
2449
|
+
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
2456
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2457
|
+
consola$1.warn("`mkdist` builder does not support watch mode yet.");
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
__name(mkdistBuild, "mkdistBuild");
|
|
2461
|
+
var copy = promises.cp || promises.copyFile;
|
|
2462
|
+
async function copyBuild(ctx) {
|
|
2463
|
+
const entries = ctx.options.entries.filter(
|
|
2464
|
+
(e) => e.builder === "copy"
|
|
2465
|
+
);
|
|
2466
|
+
await ctx.hooks.callHook("copy:entries", ctx, entries);
|
|
2467
|
+
for (const entry of entries) {
|
|
2468
|
+
const distDir = entry.outDir;
|
|
2469
|
+
if (ctx.options.stub) {
|
|
2470
|
+
await rmdir(distDir);
|
|
2471
|
+
await symlink(entry.input, distDir);
|
|
2472
|
+
} else {
|
|
2473
|
+
const patterns = Array.isArray(entry.pattern) ? entry.pattern : [entry.pattern || "**"];
|
|
2474
|
+
const paths = await glob3(patterns, {
|
|
2475
|
+
cwd: resolve(ctx.options.rootDir, entry.input),
|
|
2476
|
+
absolute: false
|
|
2477
|
+
});
|
|
2478
|
+
const outputList = await Promise.allSettled(
|
|
2479
|
+
paths.map(async (path3) => {
|
|
2480
|
+
const src = resolve(ctx.options.rootDir, entry.input, path3);
|
|
2481
|
+
const dist = resolve(ctx.options.rootDir, distDir, path3);
|
|
2482
|
+
await copy(src, dist);
|
|
2483
|
+
return dist;
|
|
2484
|
+
})
|
|
2485
|
+
);
|
|
2486
|
+
for (const output of outputList) {
|
|
2487
|
+
if (output.status === "rejected") {
|
|
2488
|
+
warn(ctx, output.reason);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
ctx.buildEntries.push({
|
|
2492
|
+
path: distDir,
|
|
2493
|
+
chunks: outputList.filter(({ status }) => status === "fulfilled").map(
|
|
2494
|
+
(p) => relative2(
|
|
2495
|
+
ctx.options.outDir,
|
|
2496
|
+
p.value
|
|
2497
|
+
)
|
|
2498
|
+
)
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
await ctx.hooks.callHook("copy:done", ctx);
|
|
2503
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2504
|
+
consola$1.warn("`untyped` builder does not support watch mode yet.");
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
__name(copyBuild, "copyBuild");
|
|
2508
|
+
async function build(rootDir, stub, inputConfig = {}) {
|
|
2509
|
+
rootDir = resolve(process.cwd(), rootDir || ".");
|
|
2510
|
+
const jiti = createJiti(rootDir);
|
|
2511
|
+
const _buildConfig = await jiti.import(inputConfig?.config || "./build.config", {
|
|
2512
|
+
try: !inputConfig.config,
|
|
2513
|
+
default: true
|
|
2514
|
+
}) || {};
|
|
2515
|
+
const buildConfigs = (Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]).filter(Boolean);
|
|
2516
|
+
const pkg = await jiti.import("./package.json", {
|
|
2517
|
+
try: true,
|
|
2518
|
+
default: true
|
|
2519
|
+
}) || {};
|
|
2520
|
+
const cleanedDirs = [];
|
|
2521
|
+
const _watchMode = inputConfig.watch === true;
|
|
2522
|
+
const _stubMode = !_watchMode && (stub || inputConfig.stub === true);
|
|
2523
|
+
for (const buildConfig of buildConfigs) {
|
|
2524
|
+
await _build(
|
|
2525
|
+
rootDir,
|
|
2526
|
+
inputConfig,
|
|
2527
|
+
buildConfig,
|
|
2528
|
+
pkg,
|
|
2529
|
+
cleanedDirs,
|
|
2530
|
+
_stubMode,
|
|
2531
|
+
_watchMode
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
__name(build, "build");
|
|
2536
|
+
async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs, _stubMode, _watchMode) {
|
|
2537
|
+
const preset = await resolvePreset(
|
|
2538
|
+
buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || inputConfig.preset || "auto",
|
|
2539
|
+
rootDir
|
|
2540
|
+
);
|
|
2541
|
+
const options = defu3(
|
|
2542
|
+
buildConfig,
|
|
2543
|
+
pkg.unbuild || pkg.build,
|
|
2544
|
+
inputConfig,
|
|
2545
|
+
preset,
|
|
2546
|
+
{
|
|
2547
|
+
name: (pkg?.name || "").split("/").pop() || "default",
|
|
2548
|
+
rootDir,
|
|
2549
|
+
entries: [],
|
|
2550
|
+
clean: true,
|
|
2551
|
+
declaration: void 0,
|
|
2552
|
+
outDir: "dist",
|
|
2553
|
+
stub: _stubMode,
|
|
2554
|
+
stubOptions: {
|
|
2555
|
+
/**
|
|
2556
|
+
* See https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
2557
|
+
*/
|
|
2558
|
+
jiti: {
|
|
2559
|
+
interopDefault: true,
|
|
2560
|
+
alias: {}
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
watch: _watchMode,
|
|
2564
|
+
watchOptions: _watchMode ? {
|
|
2565
|
+
exclude: "node_modules/**",
|
|
2566
|
+
include: "src/**"
|
|
2567
|
+
} : void 0,
|
|
2568
|
+
externals: [
|
|
2569
|
+
...Module.builtinModules,
|
|
2570
|
+
...Module.builtinModules.map((m) => "node:" + m)
|
|
2571
|
+
],
|
|
2572
|
+
dependencies: [],
|
|
2573
|
+
devDependencies: [],
|
|
2574
|
+
peerDependencies: [],
|
|
2575
|
+
alias: {},
|
|
2576
|
+
replace: {},
|
|
2577
|
+
failOnWarn: true,
|
|
2578
|
+
sourcemap: false,
|
|
2579
|
+
rollup: {
|
|
2580
|
+
emitCJS: false,
|
|
2581
|
+
watch: false,
|
|
2582
|
+
cjsBridge: false,
|
|
2583
|
+
inlineDependencies: false,
|
|
2584
|
+
preserveDynamicImports: true,
|
|
2585
|
+
output: {
|
|
2586
|
+
// https://v8.dev/features/import-attributes
|
|
2587
|
+
importAttributesKey: "with"
|
|
2588
|
+
},
|
|
2589
|
+
// Plugins
|
|
2590
|
+
replace: {
|
|
2591
|
+
preventAssignment: true
|
|
2592
|
+
},
|
|
2593
|
+
alias: {},
|
|
2594
|
+
resolve: {
|
|
2595
|
+
preferBuiltins: true
|
|
2596
|
+
},
|
|
2597
|
+
json: {
|
|
2598
|
+
preferConst: true
|
|
2599
|
+
},
|
|
2600
|
+
commonjs: {
|
|
2601
|
+
ignoreTryCatch: true
|
|
2602
|
+
},
|
|
2603
|
+
esbuild: { target: "esnext" },
|
|
2604
|
+
dts: {
|
|
2605
|
+
// https://github.com/Swatinem/rollup-plugin-dts/issues/143
|
|
2606
|
+
compilerOptions: { preserveSymlinks: false },
|
|
2607
|
+
respectExternal: true
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
parallel: false
|
|
2611
|
+
}
|
|
2612
|
+
);
|
|
2613
|
+
options.outDir = resolve(options.rootDir, options.outDir);
|
|
2614
|
+
const jiti = createJiti(options.rootDir, { interopDefault: true });
|
|
2615
|
+
const ctx = {
|
|
2616
|
+
options,
|
|
2617
|
+
jiti,
|
|
2618
|
+
warnings: /* @__PURE__ */ new Set(),
|
|
2619
|
+
pkg,
|
|
2620
|
+
buildEntries: [],
|
|
2621
|
+
usedImports: /* @__PURE__ */ new Set(),
|
|
2622
|
+
hooks: createHooks()
|
|
2623
|
+
};
|
|
2624
|
+
if (preset.hooks) {
|
|
2625
|
+
ctx.hooks.addHooks(preset.hooks);
|
|
2626
|
+
}
|
|
2627
|
+
if (inputConfig.hooks) {
|
|
2628
|
+
ctx.hooks.addHooks(inputConfig.hooks);
|
|
2629
|
+
}
|
|
2630
|
+
if (buildConfig.hooks) {
|
|
2631
|
+
ctx.hooks.addHooks(buildConfig.hooks);
|
|
2632
|
+
}
|
|
2633
|
+
await ctx.hooks.callHook("build:prepare", ctx);
|
|
2634
|
+
options.entries = options.entries.map(
|
|
2635
|
+
(entry) => typeof entry === "string" ? { input: entry } : entry
|
|
2636
|
+
);
|
|
2637
|
+
for (const entry of options.entries) {
|
|
2638
|
+
if (typeof entry.name !== "string") {
|
|
2639
|
+
let relativeInput = isAbsolute(entry.input) ? relative2(rootDir, entry.input) : normalize(entry.input);
|
|
2640
|
+
if (relativeInput.startsWith("./")) {
|
|
2641
|
+
relativeInput = relativeInput.slice(2);
|
|
2642
|
+
}
|
|
2643
|
+
entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
|
|
2644
|
+
}
|
|
2645
|
+
if (!entry.input) {
|
|
2646
|
+
throw new Error("Missing entry input: " + dumpObject(entry));
|
|
2647
|
+
}
|
|
2648
|
+
if (!entry.builder) {
|
|
2649
|
+
entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
|
|
2650
|
+
}
|
|
2651
|
+
if (options.declaration !== void 0 && entry.declaration === void 0) {
|
|
2652
|
+
entry.declaration = options.declaration;
|
|
2653
|
+
}
|
|
2654
|
+
entry.input = resolve(options.rootDir, entry.input);
|
|
2655
|
+
entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
|
|
2656
|
+
}
|
|
2657
|
+
options.dependencies = Object.keys(pkg.dependencies || {});
|
|
2658
|
+
options.peerDependencies = Object.keys(pkg.peerDependencies || {});
|
|
2659
|
+
options.devDependencies = Object.keys(pkg.devDependencies || {});
|
|
2660
|
+
options.externals.push(...inferPkgExternals(pkg));
|
|
2661
|
+
options.externals = [...new Set(options.externals)];
|
|
2662
|
+
await ctx.hooks.callHook("build:before", ctx);
|
|
2663
|
+
consola.info(
|
|
2664
|
+
colors.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`)
|
|
2665
|
+
);
|
|
2666
|
+
if (process.env.DEBUG) {
|
|
2667
|
+
consola.info(`${colors.bold("Root dir:")} ${options.rootDir}
|
|
2668
|
+
${colors.bold("Entries:")}
|
|
2669
|
+
${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")}
|
|
2670
|
+
`);
|
|
2671
|
+
}
|
|
2672
|
+
if (options.clean) {
|
|
2673
|
+
for (const dir of new Set(
|
|
2674
|
+
options.entries.map((e) => e.outDir).filter(Boolean).sort()
|
|
2675
|
+
)) {
|
|
2676
|
+
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
2677
|
+
continue;
|
|
2678
|
+
}
|
|
2679
|
+
cleanedDirs.push(dir);
|
|
2680
|
+
consola.info(
|
|
2681
|
+
`Cleaning dist directory: \`./${relative2(process.cwd(), dir)}\``
|
|
2682
|
+
);
|
|
2683
|
+
await rmdir(dir);
|
|
2684
|
+
await promises.mkdir(dir, { recursive: true });
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
const buildTasks = [
|
|
2688
|
+
typesBuild,
|
|
2689
|
+
// untyped
|
|
2690
|
+
mkdistBuild,
|
|
2691
|
+
// mkdist
|
|
2692
|
+
rollupBuild,
|
|
2693
|
+
// rollup
|
|
2694
|
+
copyBuild
|
|
2695
|
+
// copy
|
|
2696
|
+
];
|
|
2697
|
+
if (options.parallel) {
|
|
2698
|
+
await Promise.all(buildTasks.map((task) => task(ctx)));
|
|
2699
|
+
} else {
|
|
2700
|
+
for (const task of buildTasks) {
|
|
2701
|
+
await task(ctx);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
if (options.stub || options.watch) {
|
|
2705
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
consola.success(colors.green("Build succeeded for " + options.name));
|
|
2709
|
+
const outFiles = await glob3(["**"], { cwd: options.outDir });
|
|
2710
|
+
for (const file of outFiles) {
|
|
2711
|
+
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
2712
|
+
if (!entry) {
|
|
2713
|
+
entry = {
|
|
2714
|
+
path: file,
|
|
2715
|
+
chunk: true
|
|
2716
|
+
};
|
|
2717
|
+
ctx.buildEntries.push(entry);
|
|
2718
|
+
}
|
|
2719
|
+
if (!entry.bytes) {
|
|
2720
|
+
const stat = await promises.stat(resolve(options.outDir, file));
|
|
2721
|
+
entry.bytes = stat.size;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
const rPath = /* @__PURE__ */ __name((p) => relative2(process.cwd(), resolve(options.outDir, p)), "rPath");
|
|
2725
|
+
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
2726
|
+
let totalBytes = entry.bytes || 0;
|
|
2727
|
+
for (const chunk of entry.chunks || []) {
|
|
2728
|
+
totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
|
|
2729
|
+
}
|
|
2730
|
+
let line = ` ${colors.bold(rPath(entry.path))} (` + [
|
|
2731
|
+
totalBytes && `total size: ${colors.cyan(prettyBytes(totalBytes))}`,
|
|
2732
|
+
entry.bytes && `chunk size: ${colors.cyan(prettyBytes(entry.bytes))}`,
|
|
2733
|
+
entry.exports?.length && `exports: ${colors.gray(entry.exports.join(", "))}`
|
|
2734
|
+
].filter(Boolean).join(", ") + ")";
|
|
2735
|
+
if (entry.chunks?.length) {
|
|
2736
|
+
line += "\n" + entry.chunks.map((p) => {
|
|
2737
|
+
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
2738
|
+
return colors.gray(
|
|
2739
|
+
" \u2514\u2500 " + rPath(p) + colors.bold(
|
|
2740
|
+
chunk.bytes ? ` (${prettyBytes(chunk?.bytes)})` : ""
|
|
2741
|
+
)
|
|
2742
|
+
);
|
|
2743
|
+
}).join("\n");
|
|
2744
|
+
}
|
|
2745
|
+
if (entry.modules?.length) {
|
|
2746
|
+
line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
2747
|
+
return colors.gray(
|
|
2748
|
+
" \u{1F4E6} " + rPath(m.id) + colors.bold(m.bytes ? ` (${prettyBytes(m.bytes)})` : "")
|
|
2749
|
+
);
|
|
2750
|
+
}).join("\n");
|
|
2751
|
+
}
|
|
2752
|
+
consola.log(entry.chunk ? colors.gray(line) : line);
|
|
2753
|
+
}
|
|
2754
|
+
console.log(
|
|
2755
|
+
"\u03A3 Total dist size (byte size):",
|
|
2756
|
+
colors.cyan(
|
|
2757
|
+
prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))
|
|
2758
|
+
)
|
|
2759
|
+
);
|
|
2760
|
+
validateDependencies(ctx);
|
|
2761
|
+
validatePackage(pkg, rootDir, ctx);
|
|
2762
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2763
|
+
consola.log("");
|
|
2764
|
+
if (ctx.warnings.size > 0) {
|
|
2765
|
+
consola.warn(
|
|
2766
|
+
"Build is done with some warnings:\n\n" + [...ctx.warnings].map((msg) => "- " + msg).join("\n")
|
|
2767
|
+
);
|
|
2768
|
+
if (ctx.options.failOnWarn) {
|
|
2769
|
+
consola.error(
|
|
2770
|
+
"Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ."
|
|
2771
|
+
);
|
|
2772
|
+
process.exit(1);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
__name(_build, "_build");
|
|
2777
|
+
|
|
2778
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/index.mjs
|
|
2779
|
+
import "node:module";
|
|
2780
|
+
import "node:fs";
|
|
2781
|
+
import "pathe";
|
|
2782
|
+
import "consola/utils";
|
|
2783
|
+
import "consola";
|
|
2784
|
+
import "defu";
|
|
2785
|
+
import "hookable";
|
|
2786
|
+
import "pretty-bytes";
|
|
2787
|
+
import "tinyglobby";
|
|
2788
|
+
import "node:fs/promises";
|
|
2789
|
+
import "jiti";
|
|
2790
|
+
import "rollup";
|
|
2791
|
+
import "rollup-plugin-dts";
|
|
2792
|
+
import "@rollup/plugin-commonjs";
|
|
2793
|
+
import "@rollup/plugin-node-resolve";
|
|
2794
|
+
import "@rollup/plugin-alias";
|
|
2795
|
+
import "@rollup/plugin-replace";
|
|
2796
|
+
import "pathe/utils";
|
|
2797
|
+
import "mlly";
|
|
2798
|
+
import "esbuild";
|
|
2799
|
+
import "@rollup/pluginutils";
|
|
2800
|
+
import "@rollup/plugin-json";
|
|
2801
|
+
import "magic-string";
|
|
2802
|
+
import "untyped";
|
|
2803
|
+
import "untyped/babel-plugin";
|
|
2804
|
+
import "scule";
|
|
2805
|
+
import "mkdist";
|
|
1376
2806
|
|
|
1377
2807
|
// src/clean.ts
|
|
1378
2808
|
import { rm } from "node:fs/promises";
|
|
@@ -1440,23 +2870,23 @@ import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler
|
|
|
1440
2870
|
|
|
1441
2871
|
// ../../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
|
|
1442
2872
|
import * as require$$0 from "path";
|
|
1443
|
-
import require$$0__default, { dirname, normalize as
|
|
2873
|
+
import require$$0__default, { dirname as dirname2, normalize as normalize3, resolve as resolve2, relative as relative3 } from "path";
|
|
1444
2874
|
import { normalizePath, createFilter as createFilter$1 } from "@rollup/pluginutils";
|
|
1445
2875
|
import require$$2 from "util";
|
|
1446
2876
|
import require$$0$1 from "os";
|
|
1447
2877
|
import require$$3, { satisfies } from "semver";
|
|
1448
|
-
import require$$0$2, { existsSync as
|
|
2878
|
+
import require$$0$2, { existsSync as existsSync6, readdirSync as readdirSync2, renameSync, readFileSync as readFileSync2 } from "fs";
|
|
1449
2879
|
import * as fs$4 from "fs-extra";
|
|
1450
2880
|
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync as removeSync2 } from "fs-extra";
|
|
1451
2881
|
import require$$0$3 from "crypto";
|
|
1452
2882
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1453
2883
|
function adopt(value) {
|
|
1454
|
-
return value instanceof P ? value : new P(function(
|
|
1455
|
-
|
|
2884
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
2885
|
+
resolve3(value);
|
|
1456
2886
|
});
|
|
1457
2887
|
}
|
|
1458
2888
|
__name(adopt, "adopt");
|
|
1459
|
-
return new (P || (P = Promise))(function(
|
|
2889
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1460
2890
|
function fulfilled(value) {
|
|
1461
2891
|
try {
|
|
1462
2892
|
step(generator.next(value));
|
|
@@ -1474,7 +2904,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
1474
2904
|
}
|
|
1475
2905
|
__name(rejected, "rejected");
|
|
1476
2906
|
function step(result) {
|
|
1477
|
-
result.done ?
|
|
2907
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1478
2908
|
}
|
|
1479
2909
|
__name(step, "step");
|
|
1480
2910
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -1485,7 +2915,7 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
|
|
|
1485
2915
|
var safe = {
|
|
1486
2916
|
exports: {}
|
|
1487
2917
|
};
|
|
1488
|
-
var
|
|
2918
|
+
var colors2 = {
|
|
1489
2919
|
exports: {}
|
|
1490
2920
|
};
|
|
1491
2921
|
var styles = {
|
|
@@ -2202,16 +3632,16 @@ function requireAmerica() {
|
|
|
2202
3632
|
if (hasRequiredAmerica) return america.exports;
|
|
2203
3633
|
hasRequiredAmerica = 1;
|
|
2204
3634
|
(function(module) {
|
|
2205
|
-
module["exports"] = function(
|
|
3635
|
+
module["exports"] = function(colors3) {
|
|
2206
3636
|
return function(letter, i, exploded) {
|
|
2207
3637
|
if (letter === " ") return letter;
|
|
2208
3638
|
switch (i % 3) {
|
|
2209
3639
|
case 0:
|
|
2210
|
-
return
|
|
3640
|
+
return colors3.red(letter);
|
|
2211
3641
|
case 1:
|
|
2212
|
-
return
|
|
3642
|
+
return colors3.white(letter);
|
|
2213
3643
|
case 2:
|
|
2214
|
-
return
|
|
3644
|
+
return colors3.blue(letter);
|
|
2215
3645
|
}
|
|
2216
3646
|
};
|
|
2217
3647
|
};
|
|
@@ -2227,9 +3657,9 @@ function requireZebra() {
|
|
|
2227
3657
|
if (hasRequiredZebra) return zebra.exports;
|
|
2228
3658
|
hasRequiredZebra = 1;
|
|
2229
3659
|
(function(module) {
|
|
2230
|
-
module["exports"] = function(
|
|
3660
|
+
module["exports"] = function(colors3) {
|
|
2231
3661
|
return function(letter, i, exploded) {
|
|
2232
|
-
return i % 2 === 0 ? letter :
|
|
3662
|
+
return i % 2 === 0 ? letter : colors3.inverse(letter);
|
|
2233
3663
|
};
|
|
2234
3664
|
};
|
|
2235
3665
|
})(zebra);
|
|
@@ -2244,7 +3674,7 @@ function requireRainbow() {
|
|
|
2244
3674
|
if (hasRequiredRainbow) return rainbow.exports;
|
|
2245
3675
|
hasRequiredRainbow = 1;
|
|
2246
3676
|
(function(module) {
|
|
2247
|
-
module["exports"] = function(
|
|
3677
|
+
module["exports"] = function(colors3) {
|
|
2248
3678
|
var rainbowColors = [
|
|
2249
3679
|
"red",
|
|
2250
3680
|
"yellow",
|
|
@@ -2256,7 +3686,7 @@ function requireRainbow() {
|
|
|
2256
3686
|
if (letter === " ") {
|
|
2257
3687
|
return letter;
|
|
2258
3688
|
} else {
|
|
2259
|
-
return
|
|
3689
|
+
return colors3[rainbowColors[i++ % rainbowColors.length]](letter);
|
|
2260
3690
|
}
|
|
2261
3691
|
};
|
|
2262
3692
|
};
|
|
@@ -2272,7 +3702,7 @@ function requireRandom() {
|
|
|
2272
3702
|
if (hasRequiredRandom) return random.exports;
|
|
2273
3703
|
hasRequiredRandom = 1;
|
|
2274
3704
|
(function(module) {
|
|
2275
|
-
module["exports"] = function(
|
|
3705
|
+
module["exports"] = function(colors3) {
|
|
2276
3706
|
var available = [
|
|
2277
3707
|
"underline",
|
|
2278
3708
|
"inverse",
|
|
@@ -2293,7 +3723,7 @@ function requireRandom() {
|
|
|
2293
3723
|
"brightMagenta"
|
|
2294
3724
|
];
|
|
2295
3725
|
return function(letter, i, exploded) {
|
|
2296
|
-
return letter === " " ? letter :
|
|
3726
|
+
return letter === " " ? letter : colors3[available[Math.round(Math.random() * (available.length - 2))]](letter);
|
|
2297
3727
|
};
|
|
2298
3728
|
};
|
|
2299
3729
|
})(random);
|
|
@@ -2301,33 +3731,33 @@ function requireRandom() {
|
|
|
2301
3731
|
}
|
|
2302
3732
|
__name(requireRandom, "requireRandom");
|
|
2303
3733
|
(function(module) {
|
|
2304
|
-
var
|
|
2305
|
-
module["exports"] =
|
|
2306
|
-
|
|
3734
|
+
var colors3 = {};
|
|
3735
|
+
module["exports"] = colors3;
|
|
3736
|
+
colors3.themes = {};
|
|
2307
3737
|
var util = require$$2;
|
|
2308
|
-
var ansiStyles =
|
|
3738
|
+
var ansiStyles = colors3.styles = styles.exports;
|
|
2309
3739
|
var defineProps = Object.defineProperties;
|
|
2310
3740
|
var newLineRegex = new RegExp(/[\r\n]+/g);
|
|
2311
|
-
|
|
2312
|
-
if (typeof
|
|
2313
|
-
|
|
3741
|
+
colors3.supportsColor = supportsColors.supportsColor;
|
|
3742
|
+
if (typeof colors3.enabled === "undefined") {
|
|
3743
|
+
colors3.enabled = colors3.supportsColor() !== false;
|
|
2314
3744
|
}
|
|
2315
|
-
|
|
2316
|
-
|
|
3745
|
+
colors3.enable = function() {
|
|
3746
|
+
colors3.enabled = true;
|
|
2317
3747
|
};
|
|
2318
|
-
|
|
2319
|
-
|
|
3748
|
+
colors3.disable = function() {
|
|
3749
|
+
colors3.enabled = false;
|
|
2320
3750
|
};
|
|
2321
|
-
|
|
3751
|
+
colors3.stripColors = colors3.strip = function(str) {
|
|
2322
3752
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
2323
3753
|
};
|
|
2324
|
-
|
|
2325
|
-
if (!
|
|
3754
|
+
colors3.stylize = /* @__PURE__ */ __name(function stylize(str, style) {
|
|
3755
|
+
if (!colors3.enabled) {
|
|
2326
3756
|
return str + "";
|
|
2327
3757
|
}
|
|
2328
3758
|
var styleMap = ansiStyles[style];
|
|
2329
|
-
if (!styleMap && style in
|
|
2330
|
-
return
|
|
3759
|
+
if (!styleMap && style in colors3) {
|
|
3760
|
+
return colors3[style](str);
|
|
2331
3761
|
}
|
|
2332
3762
|
return styleMap.open + str + styleMap.close;
|
|
2333
3763
|
}, "stylize");
|
|
@@ -2338,7 +3768,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2338
3768
|
}
|
|
2339
3769
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
2340
3770
|
}, "escapeStringRegexp");
|
|
2341
|
-
function
|
|
3771
|
+
function build3(_styles) {
|
|
2342
3772
|
var builder = /* @__PURE__ */ __name(function builder2() {
|
|
2343
3773
|
return applyStyle.apply(builder2, arguments);
|
|
2344
3774
|
}, "builder");
|
|
@@ -2346,7 +3776,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2346
3776
|
builder.__proto__ = proto;
|
|
2347
3777
|
return builder;
|
|
2348
3778
|
}
|
|
2349
|
-
__name(
|
|
3779
|
+
__name(build3, "build");
|
|
2350
3780
|
var styles$1 = function() {
|
|
2351
3781
|
var ret = {};
|
|
2352
3782
|
ansiStyles.grey = ansiStyles.gray;
|
|
@@ -2354,13 +3784,13 @@ __name(requireRandom, "requireRandom");
|
|
|
2354
3784
|
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
|
|
2355
3785
|
ret[key] = {
|
|
2356
3786
|
get: /* @__PURE__ */ __name(function() {
|
|
2357
|
-
return
|
|
3787
|
+
return build3(this._styles.concat(key));
|
|
2358
3788
|
}, "get")
|
|
2359
3789
|
};
|
|
2360
3790
|
});
|
|
2361
3791
|
return ret;
|
|
2362
3792
|
}();
|
|
2363
|
-
var proto = defineProps(/* @__PURE__ */ __name(function
|
|
3793
|
+
var proto = defineProps(/* @__PURE__ */ __name(function colors4() {
|
|
2364
3794
|
}, "colors"), styles$1);
|
|
2365
3795
|
function applyStyle() {
|
|
2366
3796
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -2371,7 +3801,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2371
3801
|
return util.inspect(arg);
|
|
2372
3802
|
}
|
|
2373
3803
|
}).join(" ");
|
|
2374
|
-
if (!
|
|
3804
|
+
if (!colors3.enabled || !str) {
|
|
2375
3805
|
return str;
|
|
2376
3806
|
}
|
|
2377
3807
|
var newLinesPresent = str.indexOf("\n") != -1;
|
|
@@ -2389,22 +3819,22 @@ __name(requireRandom, "requireRandom");
|
|
|
2389
3819
|
return str;
|
|
2390
3820
|
}
|
|
2391
3821
|
__name(applyStyle, "applyStyle");
|
|
2392
|
-
|
|
3822
|
+
colors3.setTheme = function(theme) {
|
|
2393
3823
|
if (typeof theme === "string") {
|
|
2394
3824
|
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'));");
|
|
2395
3825
|
return;
|
|
2396
3826
|
}
|
|
2397
3827
|
for (var style in theme) {
|
|
2398
3828
|
(function(style2) {
|
|
2399
|
-
|
|
3829
|
+
colors3[style2] = function(str) {
|
|
2400
3830
|
if (typeof theme[style2] === "object") {
|
|
2401
3831
|
var out = str;
|
|
2402
3832
|
for (var i in theme[style2]) {
|
|
2403
|
-
out =
|
|
3833
|
+
out = colors3[theme[style2][i]](out);
|
|
2404
3834
|
}
|
|
2405
3835
|
return out;
|
|
2406
3836
|
}
|
|
2407
|
-
return
|
|
3837
|
+
return colors3[theme[style2]](str);
|
|
2408
3838
|
};
|
|
2409
3839
|
})(style);
|
|
2410
3840
|
}
|
|
@@ -2414,7 +3844,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2414
3844
|
Object.keys(styles$1).forEach(function(name) {
|
|
2415
3845
|
ret[name] = {
|
|
2416
3846
|
get: /* @__PURE__ */ __name(function() {
|
|
2417
|
-
return
|
|
3847
|
+
return build3([
|
|
2418
3848
|
name
|
|
2419
3849
|
]);
|
|
2420
3850
|
}, "get")
|
|
@@ -2428,24 +3858,24 @@ __name(requireRandom, "requireRandom");
|
|
|
2428
3858
|
exploded = exploded.map(map2);
|
|
2429
3859
|
return exploded.join("");
|
|
2430
3860
|
}, "sequencer");
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
for (var map in
|
|
3861
|
+
colors3.trap = requireTrap();
|
|
3862
|
+
colors3.zalgo = requireZalgo();
|
|
3863
|
+
colors3.maps = {};
|
|
3864
|
+
colors3.maps.america = requireAmerica()(colors3);
|
|
3865
|
+
colors3.maps.zebra = requireZebra()(colors3);
|
|
3866
|
+
colors3.maps.rainbow = requireRainbow()(colors3);
|
|
3867
|
+
colors3.maps.random = requireRandom()(colors3);
|
|
3868
|
+
for (var map in colors3.maps) {
|
|
2439
3869
|
(function(map2) {
|
|
2440
|
-
|
|
2441
|
-
return sequencer(
|
|
3870
|
+
colors3[map2] = function(str) {
|
|
3871
|
+
return sequencer(colors3.maps[map2], str);
|
|
2442
3872
|
};
|
|
2443
3873
|
})(map);
|
|
2444
3874
|
}
|
|
2445
|
-
defineProps(
|
|
2446
|
-
})(
|
|
3875
|
+
defineProps(colors3, init());
|
|
3876
|
+
})(colors2);
|
|
2447
3877
|
(function(module) {
|
|
2448
|
-
var colors$1 =
|
|
3878
|
+
var colors$1 = colors2.exports;
|
|
2449
3879
|
module["exports"] = colors$1;
|
|
2450
3880
|
})(safe);
|
|
2451
3881
|
var path$4 = require$$0__default;
|
|
@@ -2485,8 +3915,8 @@ var pLimit$2 = {
|
|
|
2485
3915
|
var pTry$2 = {
|
|
2486
3916
|
exports: {}
|
|
2487
3917
|
};
|
|
2488
|
-
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((
|
|
2489
|
-
|
|
3918
|
+
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((resolve3) => {
|
|
3919
|
+
resolve3(fn(...arguments_));
|
|
2490
3920
|
}), "pTry$1");
|
|
2491
3921
|
pTry$2.exports = pTry$1;
|
|
2492
3922
|
pTry$2.exports.default = pTry$1;
|
|
@@ -2503,20 +3933,20 @@ var pLimit$1 = /* @__PURE__ */ __name((concurrency) => {
|
|
|
2503
3933
|
queue.shift()();
|
|
2504
3934
|
}
|
|
2505
3935
|
}, "next");
|
|
2506
|
-
const run = /* @__PURE__ */ __name((fn,
|
|
3936
|
+
const run = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2507
3937
|
activeCount++;
|
|
2508
3938
|
const result = pTry(fn, ...args);
|
|
2509
|
-
|
|
3939
|
+
resolve3(result);
|
|
2510
3940
|
result.then(next, next);
|
|
2511
3941
|
}, "run");
|
|
2512
|
-
const enqueue = /* @__PURE__ */ __name((fn,
|
|
3942
|
+
const enqueue = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2513
3943
|
if (activeCount < concurrency) {
|
|
2514
|
-
run(fn,
|
|
3944
|
+
run(fn, resolve3, ...args);
|
|
2515
3945
|
} else {
|
|
2516
|
-
queue.push(run.bind(null, fn,
|
|
3946
|
+
queue.push(run.bind(null, fn, resolve3, ...args));
|
|
2517
3947
|
}
|
|
2518
3948
|
}, "enqueue");
|
|
2519
|
-
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((
|
|
3949
|
+
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve3) => enqueue(fn, resolve3, ...args)), "generator");
|
|
2520
3950
|
Object.defineProperties(generator, {
|
|
2521
3951
|
activeCount: {
|
|
2522
3952
|
get: /* @__PURE__ */ __name(() => activeCount, "get")
|
|
@@ -2759,12 +4189,12 @@ var checkPath = /* @__PURE__ */ __name((pth) => {
|
|
|
2759
4189
|
}
|
|
2760
4190
|
}, "checkPath");
|
|
2761
4191
|
var processOptions = /* @__PURE__ */ __name((options) => {
|
|
2762
|
-
const
|
|
4192
|
+
const defaults2 = {
|
|
2763
4193
|
mode: 511 & ~process.umask(),
|
|
2764
4194
|
fs: fs$1
|
|
2765
4195
|
};
|
|
2766
4196
|
return {
|
|
2767
|
-
...
|
|
4197
|
+
...defaults2,
|
|
2768
4198
|
...options
|
|
2769
4199
|
};
|
|
2770
4200
|
}, "processOptions");
|
|
@@ -2779,11 +4209,11 @@ var permissionError = /* @__PURE__ */ __name((pth) => {
|
|
|
2779
4209
|
var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
2780
4210
|
checkPath(input);
|
|
2781
4211
|
options = processOptions(options);
|
|
2782
|
-
const
|
|
4212
|
+
const mkdir2 = promisify(options.fs.mkdir);
|
|
2783
4213
|
const stat = promisify(options.fs.stat);
|
|
2784
4214
|
if (useNativeRecursiveOption && options.fs.mkdir === fs$1.mkdir) {
|
|
2785
4215
|
const pth = path$1.resolve(input);
|
|
2786
|
-
await
|
|
4216
|
+
await mkdir2(pth, {
|
|
2787
4217
|
mode: options.mode,
|
|
2788
4218
|
recursive: true
|
|
2789
4219
|
});
|
|
@@ -2791,7 +4221,7 @@ var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
|
2791
4221
|
}
|
|
2792
4222
|
const make = /* @__PURE__ */ __name(async (pth) => {
|
|
2793
4223
|
try {
|
|
2794
|
-
await
|
|
4224
|
+
await mkdir2(pth, options.mode);
|
|
2795
4225
|
return pth;
|
|
2796
4226
|
} catch (error) {
|
|
2797
4227
|
if (error.code === "EPERM") {
|
|
@@ -3486,11 +4916,11 @@ var lodash$1 = {
|
|
|
3486
4916
|
return result;
|
|
3487
4917
|
}
|
|
3488
4918
|
__name(arrayFilter, "arrayFilter");
|
|
3489
|
-
function
|
|
4919
|
+
function arrayIncludes2(array, value) {
|
|
3490
4920
|
var length = array == null ? 0 : array.length;
|
|
3491
4921
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
3492
4922
|
}
|
|
3493
|
-
__name(
|
|
4923
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
3494
4924
|
function arrayIncludesWith(array, value, comparator) {
|
|
3495
4925
|
var index = -1, length = array == null ? 0 : array.length;
|
|
3496
4926
|
while (++index < length) {
|
|
@@ -3739,9 +5169,9 @@ var lodash$1 = {
|
|
|
3739
5169
|
return result;
|
|
3740
5170
|
}
|
|
3741
5171
|
__name(mapToArray, "mapToArray");
|
|
3742
|
-
function overArg(func,
|
|
5172
|
+
function overArg(func, transform3) {
|
|
3743
5173
|
return function(arg) {
|
|
3744
|
-
return func(
|
|
5174
|
+
return func(transform3(arg));
|
|
3745
5175
|
};
|
|
3746
5176
|
}
|
|
3747
5177
|
__name(overArg, "overArg");
|
|
@@ -4415,7 +5845,7 @@ var lodash$1 = {
|
|
|
4415
5845
|
}
|
|
4416
5846
|
__name(baseDelay, "baseDelay");
|
|
4417
5847
|
function baseDifference(array, values2, iteratee2, comparator) {
|
|
4418
|
-
var index = -1, includes2 =
|
|
5848
|
+
var index = -1, includes2 = arrayIncludes2, isCommon = true, length = array.length, result2 = [], valuesLength = values2.length;
|
|
4419
5849
|
if (!length) {
|
|
4420
5850
|
return result2;
|
|
4421
5851
|
}
|
|
@@ -4570,7 +6000,7 @@ var lodash$1 = {
|
|
|
4570
6000
|
}
|
|
4571
6001
|
__name(baseInRange, "baseInRange");
|
|
4572
6002
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
4573
|
-
var includes2 = comparator ? arrayIncludesWith :
|
|
6003
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes2, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array1(othLength), maxLength = Infinity, result2 = [];
|
|
4574
6004
|
while (othIndex--) {
|
|
4575
6005
|
var array = arrays[othIndex];
|
|
4576
6006
|
if (othIndex && iteratee2) {
|
|
@@ -5151,7 +6581,7 @@ var lodash$1 = {
|
|
|
5151
6581
|
}
|
|
5152
6582
|
__name(baseToString, "baseToString");
|
|
5153
6583
|
function baseUniq(array, iteratee2, comparator) {
|
|
5154
|
-
var index = -1, includes2 =
|
|
6584
|
+
var index = -1, includes2 = arrayIncludes2, length = array.length, isCommon = true, result2 = [], seen = result2;
|
|
5155
6585
|
if (comparator) {
|
|
5156
6586
|
isCommon = false;
|
|
5157
6587
|
includes2 = arrayIncludesWith;
|
|
@@ -6349,7 +7779,7 @@ var lodash$1 = {
|
|
|
6349
7779
|
return nativeObjectToString.call(value);
|
|
6350
7780
|
}
|
|
6351
7781
|
__name(objectToString, "objectToString");
|
|
6352
|
-
function overRest(func, start,
|
|
7782
|
+
function overRest(func, start, transform4) {
|
|
6353
7783
|
start = nativeMax(start === undefined$1 ? func.length - 1 : start, 0);
|
|
6354
7784
|
return function() {
|
|
6355
7785
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array1(length);
|
|
@@ -6361,7 +7791,7 @@ var lodash$1 = {
|
|
|
6361
7791
|
while (++index < start) {
|
|
6362
7792
|
otherArgs[index] = args[index];
|
|
6363
7793
|
}
|
|
6364
|
-
otherArgs[start] =
|
|
7794
|
+
otherArgs[start] = transform4(array);
|
|
6365
7795
|
return apply(func, this, otherArgs);
|
|
6366
7796
|
};
|
|
6367
7797
|
}
|
|
@@ -6462,7 +7892,7 @@ var lodash$1 = {
|
|
|
6462
7892
|
function updateWrapDetails(details, bitmask) {
|
|
6463
7893
|
arrayEach(wrapFlags, function(pair) {
|
|
6464
7894
|
var value = "_." + pair[0];
|
|
6465
|
-
if (bitmask & pair[1] && !
|
|
7895
|
+
if (bitmask & pair[1] && !arrayIncludes2(details, value)) {
|
|
6466
7896
|
details.push(value);
|
|
6467
7897
|
}
|
|
6468
7898
|
});
|
|
@@ -6673,10 +8103,10 @@ var lodash$1 = {
|
|
|
6673
8103
|
}
|
|
6674
8104
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined$1, comparator) : [];
|
|
6675
8105
|
});
|
|
6676
|
-
function
|
|
8106
|
+
function join5(array, separator) {
|
|
6677
8107
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
6678
8108
|
}
|
|
6679
|
-
__name(
|
|
8109
|
+
__name(join5, "join");
|
|
6680
8110
|
function last(array) {
|
|
6681
8111
|
var length = array == null ? 0 : array.length;
|
|
6682
8112
|
return length ? array[length - 1] : undefined$1;
|
|
@@ -7781,7 +9211,7 @@ var lodash$1 = {
|
|
|
7781
9211
|
return properties == null ? result2 : baseAssign(result2, properties);
|
|
7782
9212
|
}
|
|
7783
9213
|
__name(create, "create");
|
|
7784
|
-
var
|
|
9214
|
+
var defaults2 = baseRest(function(object, sources) {
|
|
7785
9215
|
object = Object1(object);
|
|
7786
9216
|
var index = -1;
|
|
7787
9217
|
var length = sources.length;
|
|
@@ -7976,7 +9406,7 @@ var lodash$1 = {
|
|
|
7976
9406
|
__name(setWith, "setWith");
|
|
7977
9407
|
var toPairs = createToPairs(keys);
|
|
7978
9408
|
var toPairsIn = createToPairs(keysIn);
|
|
7979
|
-
function
|
|
9409
|
+
function transform3(object, iteratee2, accumulator) {
|
|
7980
9410
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
7981
9411
|
iteratee2 = getIteratee(iteratee2, 4);
|
|
7982
9412
|
if (accumulator == null) {
|
|
@@ -7994,7 +9424,7 @@ var lodash$1 = {
|
|
|
7994
9424
|
});
|
|
7995
9425
|
return accumulator;
|
|
7996
9426
|
}
|
|
7997
|
-
__name(
|
|
9427
|
+
__name(transform3, "transform");
|
|
7998
9428
|
function unset(object, path3) {
|
|
7999
9429
|
return object == null ? true : baseUnset(object, path3);
|
|
8000
9430
|
}
|
|
@@ -8164,11 +9594,11 @@ var lodash$1 = {
|
|
|
8164
9594
|
return baseRepeat(toString(string), n);
|
|
8165
9595
|
}
|
|
8166
9596
|
__name(repeat, "repeat");
|
|
8167
|
-
function
|
|
9597
|
+
function replace2() {
|
|
8168
9598
|
var args = arguments, string = toString(args[0]);
|
|
8169
9599
|
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
8170
9600
|
}
|
|
8171
|
-
__name(
|
|
9601
|
+
__name(replace2, "replace");
|
|
8172
9602
|
var snakeCase = createCompounder(function(result2, word, index) {
|
|
8173
9603
|
return result2 + (index ? "_" : "") + word.toLowerCase();
|
|
8174
9604
|
});
|
|
@@ -8621,7 +10051,7 @@ var lodash$1 = {
|
|
|
8621
10051
|
lodash2.curry = curry;
|
|
8622
10052
|
lodash2.curryRight = curryRight;
|
|
8623
10053
|
lodash2.debounce = debounce;
|
|
8624
|
-
lodash2.defaults =
|
|
10054
|
+
lodash2.defaults = defaults2;
|
|
8625
10055
|
lodash2.defaultsDeep = defaultsDeep;
|
|
8626
10056
|
lodash2.defer = defer;
|
|
8627
10057
|
lodash2.delay = delay;
|
|
@@ -8721,7 +10151,7 @@ var lodash$1 = {
|
|
|
8721
10151
|
lodash2.toPairsIn = toPairsIn;
|
|
8722
10152
|
lodash2.toPath = toPath;
|
|
8723
10153
|
lodash2.toPlainObject = toPlainObject;
|
|
8724
|
-
lodash2.transform =
|
|
10154
|
+
lodash2.transform = transform3;
|
|
8725
10155
|
lodash2.unary = unary;
|
|
8726
10156
|
lodash2.union = union;
|
|
8727
10157
|
lodash2.unionBy = unionBy;
|
|
@@ -8831,7 +10261,7 @@ var lodash$1 = {
|
|
|
8831
10261
|
lodash2.isUndefined = isUndefined;
|
|
8832
10262
|
lodash2.isWeakMap = isWeakMap;
|
|
8833
10263
|
lodash2.isWeakSet = isWeakSet;
|
|
8834
|
-
lodash2.join =
|
|
10264
|
+
lodash2.join = join5;
|
|
8835
10265
|
lodash2.kebabCase = kebabCase;
|
|
8836
10266
|
lodash2.last = last;
|
|
8837
10267
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -8863,7 +10293,7 @@ var lodash$1 = {
|
|
|
8863
10293
|
lodash2.reduce = reduce;
|
|
8864
10294
|
lodash2.reduceRight = reduceRight;
|
|
8865
10295
|
lodash2.repeat = repeat;
|
|
8866
|
-
lodash2.replace =
|
|
10296
|
+
lodash2.replace = replace2;
|
|
8867
10297
|
lodash2.result = result;
|
|
8868
10298
|
lodash2.round = round;
|
|
8869
10299
|
lodash2.runInContext = runInContext2;
|
|
@@ -10255,9 +11685,9 @@ var hasRequired_overArg;
|
|
|
10255
11685
|
function require_overArg() {
|
|
10256
11686
|
if (hasRequired_overArg) return _overArg;
|
|
10257
11687
|
hasRequired_overArg = 1;
|
|
10258
|
-
function overArg(func,
|
|
11688
|
+
function overArg(func, transform3) {
|
|
10259
11689
|
return function(arg) {
|
|
10260
|
-
return func(
|
|
11690
|
+
return func(transform3(arg));
|
|
10261
11691
|
};
|
|
10262
11692
|
}
|
|
10263
11693
|
__name(overArg, "overArg");
|
|
@@ -12378,7 +13808,7 @@ function requireTransform() {
|
|
|
12378
13808
|
if (hasRequiredTransform) return transform_1;
|
|
12379
13809
|
hasRequiredTransform = 1;
|
|
12380
13810
|
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();
|
|
12381
|
-
function
|
|
13811
|
+
function transform3(object, iteratee, accumulator) {
|
|
12382
13812
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
12383
13813
|
iteratee = baseIteratee(iteratee, 4);
|
|
12384
13814
|
if (accumulator == null) {
|
|
@@ -12396,8 +13826,8 @@ function requireTransform() {
|
|
|
12396
13826
|
});
|
|
12397
13827
|
return accumulator;
|
|
12398
13828
|
}
|
|
12399
|
-
__name(
|
|
12400
|
-
transform_1 =
|
|
13829
|
+
__name(transform3, "transform");
|
|
13830
|
+
transform_1 = transform3;
|
|
12401
13831
|
return transform_1;
|
|
12402
13832
|
}
|
|
12403
13833
|
__name(requireTransform, "requireTransform");
|
|
@@ -12475,7 +13905,7 @@ function require_overRest() {
|
|
|
12475
13905
|
hasRequired_overRest = 1;
|
|
12476
13906
|
var apply = require_apply();
|
|
12477
13907
|
var nativeMax = Math.max;
|
|
12478
|
-
function overRest(func, start,
|
|
13908
|
+
function overRest(func, start, transform3) {
|
|
12479
13909
|
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
12480
13910
|
return function() {
|
|
12481
13911
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
|
|
@@ -12487,7 +13917,7 @@ function require_overRest() {
|
|
|
12487
13917
|
while (++index < start) {
|
|
12488
13918
|
otherArgs[index] = args[index];
|
|
12489
13919
|
}
|
|
12490
|
-
otherArgs[start] =
|
|
13920
|
+
otherArgs[start] = transform3(array);
|
|
12491
13921
|
return apply(func, this, otherArgs);
|
|
12492
13922
|
};
|
|
12493
13923
|
}
|
|
@@ -12637,12 +14067,12 @@ function require_arrayIncludes() {
|
|
|
12637
14067
|
if (hasRequired_arrayIncludes) return _arrayIncludes;
|
|
12638
14068
|
hasRequired_arrayIncludes = 1;
|
|
12639
14069
|
var baseIndexOf = require_baseIndexOf();
|
|
12640
|
-
function
|
|
14070
|
+
function arrayIncludes2(array, value) {
|
|
12641
14071
|
var length = array == null ? 0 : array.length;
|
|
12642
14072
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
12643
14073
|
}
|
|
12644
|
-
__name(
|
|
12645
|
-
_arrayIncludes =
|
|
14074
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
14075
|
+
_arrayIncludes = arrayIncludes2;
|
|
12646
14076
|
return _arrayIncludes;
|
|
12647
14077
|
}
|
|
12648
14078
|
__name(require_arrayIncludes, "require_arrayIncludes");
|
|
@@ -12699,10 +14129,10 @@ var hasRequired_baseUniq;
|
|
|
12699
14129
|
function require_baseUniq() {
|
|
12700
14130
|
if (hasRequired_baseUniq) return _baseUniq;
|
|
12701
14131
|
hasRequired_baseUniq = 1;
|
|
12702
|
-
var SetCache = require_SetCache(),
|
|
14132
|
+
var SetCache = require_SetCache(), arrayIncludes2 = require_arrayIncludes(), arrayIncludesWith = require_arrayIncludesWith(), cacheHas = require_cacheHas(), createSet = require_createSet(), setToArray = require_setToArray();
|
|
12703
14133
|
var LARGE_ARRAY_SIZE = 200;
|
|
12704
14134
|
function baseUniq(array, iteratee, comparator) {
|
|
12705
|
-
var index = -1, includes =
|
|
14135
|
+
var index = -1, includes = arrayIncludes2, length = array.length, isCommon = true, result = [], seen = result;
|
|
12706
14136
|
if (comparator) {
|
|
12707
14137
|
isCommon = false;
|
|
12708
14138
|
includes = arrayIncludesWith;
|
|
@@ -13037,27 +14467,27 @@ Graph$2.prototype.isLeaf = function(v) {
|
|
|
13037
14467
|
return neighbors.length === 0;
|
|
13038
14468
|
};
|
|
13039
14469
|
Graph$2.prototype.filterNodes = function(filter) {
|
|
13040
|
-
var
|
|
14470
|
+
var copy2 = new this.constructor({
|
|
13041
14471
|
directed: this._isDirected,
|
|
13042
14472
|
multigraph: this._isMultigraph,
|
|
13043
14473
|
compound: this._isCompound
|
|
13044
14474
|
});
|
|
13045
|
-
|
|
14475
|
+
copy2.setGraph(this.graph());
|
|
13046
14476
|
var self1 = this;
|
|
13047
14477
|
_$b.each(this._nodes, function(value, v) {
|
|
13048
14478
|
if (filter(v)) {
|
|
13049
|
-
|
|
14479
|
+
copy2.setNode(v, value);
|
|
13050
14480
|
}
|
|
13051
14481
|
});
|
|
13052
14482
|
_$b.each(this._edgeObjs, function(e) {
|
|
13053
|
-
if (
|
|
13054
|
-
|
|
14483
|
+
if (copy2.hasNode(e.v) && copy2.hasNode(e.w)) {
|
|
14484
|
+
copy2.setEdge(e, self1.edge(e));
|
|
13055
14485
|
}
|
|
13056
14486
|
});
|
|
13057
14487
|
var parents = {};
|
|
13058
14488
|
function findParent(v) {
|
|
13059
14489
|
var parent = self1.parent(v);
|
|
13060
|
-
if (parent === void 0 ||
|
|
14490
|
+
if (parent === void 0 || copy2.hasNode(parent)) {
|
|
13061
14491
|
parents[v] = parent;
|
|
13062
14492
|
return parent;
|
|
13063
14493
|
} else if (parent in parents) {
|
|
@@ -13068,11 +14498,11 @@ Graph$2.prototype.filterNodes = function(filter) {
|
|
|
13068
14498
|
}
|
|
13069
14499
|
__name(findParent, "findParent");
|
|
13070
14500
|
if (this._isCompound) {
|
|
13071
|
-
_$b.each(
|
|
13072
|
-
|
|
14501
|
+
_$b.each(copy2.nodes(), function(v) {
|
|
14502
|
+
copy2.setParent(v, findParent(v));
|
|
13073
14503
|
});
|
|
13074
14504
|
}
|
|
13075
|
-
return
|
|
14505
|
+
return copy2;
|
|
13076
14506
|
};
|
|
13077
14507
|
Graph$2.prototype.setDefaultEdgeLabel = function(newDefault) {
|
|
13078
14508
|
if (!_$b.isFunction(newDefault)) {
|
|
@@ -14191,8 +15621,8 @@ var RollingCache = class RollingCache2 {
|
|
|
14191
15621
|
/** @returns true if name exists in either old cache or new cache */
|
|
14192
15622
|
exists(name) {
|
|
14193
15623
|
if (this.rolled) return false;
|
|
14194
|
-
if (
|
|
14195
|
-
return
|
|
15624
|
+
if (existsSync6(`${this.newCacheRoot}/${name}`)) return true;
|
|
15625
|
+
return existsSync6(`${this.oldCacheRoot}/${name}`);
|
|
14196
15626
|
}
|
|
14197
15627
|
path(name) {
|
|
14198
15628
|
return `${this.oldCacheRoot}/${name}`;
|
|
@@ -14200,12 +15630,12 @@ var RollingCache = class RollingCache2 {
|
|
|
14200
15630
|
/** @returns true if old cache contains all names and nothing more */
|
|
14201
15631
|
match(names) {
|
|
14202
15632
|
if (this.rolled) return false;
|
|
14203
|
-
if (!
|
|
14204
|
-
return lodash$1.exports.isEqual(
|
|
15633
|
+
if (!existsSync6(this.oldCacheRoot)) return names.length === 0;
|
|
15634
|
+
return lodash$1.exports.isEqual(readdirSync2(this.oldCacheRoot).sort(), names.sort());
|
|
14205
15635
|
}
|
|
14206
15636
|
/** @returns data for name, must exist in either old cache or new cache */
|
|
14207
15637
|
read(name) {
|
|
14208
|
-
if (
|
|
15638
|
+
if (existsSync6(`${this.newCacheRoot}/${name}`)) return readJsonSync(`${this.newCacheRoot}/${name}`, {
|
|
14209
15639
|
encoding: "utf8",
|
|
14210
15640
|
throws: false
|
|
14211
15641
|
});
|
|
@@ -14228,7 +15658,7 @@ var RollingCache = class RollingCache2 {
|
|
|
14228
15658
|
if (this.rolled) return;
|
|
14229
15659
|
this.rolled = true;
|
|
14230
15660
|
removeSync2(this.oldCacheRoot);
|
|
14231
|
-
if (
|
|
15661
|
+
if (existsSync6(this.newCacheRoot)) {
|
|
14232
15662
|
renameSync(this.newCacheRoot, this.oldCacheRoot);
|
|
14233
15663
|
}
|
|
14234
15664
|
}
|
|
@@ -14397,9 +15827,9 @@ var TsCache = class TsCache2 {
|
|
|
14397
15827
|
this.syntacticDiagnosticsCache.roll();
|
|
14398
15828
|
this.typesCache.roll();
|
|
14399
15829
|
}
|
|
14400
|
-
getCompiled(id, snapshot,
|
|
15830
|
+
getCompiled(id, snapshot, transform3) {
|
|
14401
15831
|
this.context.info(`${safe.exports.blue("transpiling")} '${id}'`);
|
|
14402
|
-
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration),
|
|
15832
|
+
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration), transform3);
|
|
14403
15833
|
}
|
|
14404
15834
|
getSyntacticDiagnostics(id, snapshot, check) {
|
|
14405
15835
|
return this.getDiagnostics("syntax", this.syntacticDiagnosticsCache, id, snapshot, check);
|
|
@@ -14503,7 +15933,7 @@ function expandIncludeWithDirs(include, dirs) {
|
|
|
14503
15933
|
return newDirs;
|
|
14504
15934
|
}
|
|
14505
15935
|
__name(expandIncludeWithDirs, "expandIncludeWithDirs");
|
|
14506
|
-
function
|
|
15936
|
+
function createFilter2(context, pluginOptions, parsedConfig) {
|
|
14507
15937
|
let included = pluginOptions.include;
|
|
14508
15938
|
let excluded = pluginOptions.exclude;
|
|
14509
15939
|
if (parsedConfig.options.rootDirs) {
|
|
@@ -14522,7 +15952,7 @@ ${JSON.stringify(excluded, void 0, 4)}`);
|
|
|
14522
15952
|
resolve: parsedConfig.options.rootDir
|
|
14523
15953
|
});
|
|
14524
15954
|
}
|
|
14525
|
-
__name(
|
|
15955
|
+
__name(createFilter2, "createFilter");
|
|
14526
15956
|
function parseTsConfig(context, pluginOptions) {
|
|
14527
15957
|
var _a, _b;
|
|
14528
15958
|
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
|
|
@@ -14542,7 +15972,7 @@ function parseTsConfig(context, pluginOptions) {
|
|
|
14542
15972
|
context.error(`failed to parse '${fileName}'`);
|
|
14543
15973
|
}
|
|
14544
15974
|
loadedConfig = result.config;
|
|
14545
|
-
baseDir =
|
|
15975
|
+
baseDir = dirname2(fileName);
|
|
14546
15976
|
configFileName = fileName;
|
|
14547
15977
|
}
|
|
14548
15978
|
const mergedConfig = {};
|
|
@@ -14693,7 +16123,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14693
16123
|
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.`);
|
|
14694
16124
|
if (pluginOptions.rollupCommonJSResolveHack) context.warn(() => `${safe.exports.yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
|
|
14695
16125
|
if (watchMode) context.info(`running in watch mode`);
|
|
14696
|
-
filter =
|
|
16126
|
+
filter = createFilter2(context, pluginOptions, parsedConfig);
|
|
14697
16127
|
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
|
|
14698
16128
|
service = tsModule.createLanguageService(servicesHost, documentRegistry);
|
|
14699
16129
|
servicesHost.setLanguageService(service);
|
|
@@ -14724,7 +16154,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14724
16154
|
cache.setDependency(resolved, importer);
|
|
14725
16155
|
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
|
|
14726
16156
|
context.debug(() => ` to '${resolved}'`);
|
|
14727
|
-
return
|
|
16157
|
+
return normalize3(resolved);
|
|
14728
16158
|
},
|
|
14729
16159
|
load(id) {
|
|
14730
16160
|
if (id === TSLIB_VIRTUAL) return tslibSource;
|
|
@@ -14833,15 +16263,15 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14833
16263
|
let entryText = entry.text;
|
|
14834
16264
|
const cachePlaceholder = `${pluginOptions.cacheRoot}/placeholder`;
|
|
14835
16265
|
if (extension === ".d.ts.map" && ((_output === null || _output === void 0 ? void 0 : _output.file) || (_output === null || _output === void 0 ? void 0 : _output.dir))) {
|
|
14836
|
-
const declarationDir = _output.file ?
|
|
16266
|
+
const declarationDir = _output.file ? dirname2(_output.file) : _output.dir;
|
|
14837
16267
|
const parsedText = JSON.parse(entryText);
|
|
14838
16268
|
parsedText.sources = parsedText.sources.map((source) => {
|
|
14839
|
-
const absolutePath =
|
|
14840
|
-
return normalizePath(
|
|
16269
|
+
const absolutePath = resolve2(cachePlaceholder, source);
|
|
16270
|
+
return normalizePath(relative3(declarationDir, absolutePath));
|
|
14841
16271
|
});
|
|
14842
16272
|
entryText = JSON.stringify(parsedText);
|
|
14843
16273
|
}
|
|
14844
|
-
const relativePath = normalizePath(
|
|
16274
|
+
const relativePath = normalizePath(relative3(cachePlaceholder, fileName));
|
|
14845
16275
|
context.debug(() => `${safe.exports.blue("emitting declarations")} for '${key}' to '${relativePath}'`);
|
|
14846
16276
|
this.emitFile({
|
|
14847
16277
|
type: "asset",
|
|
@@ -14862,11 +16292,11 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14862
16292
|
// src/utilities/helpers.ts
|
|
14863
16293
|
import { joinPathFragments as joinPathFragments2 } from "@nx/devkit";
|
|
14864
16294
|
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
14865
|
-
import { dirname as
|
|
16295
|
+
import { dirname as dirname3, extname as extname2 } from "node:path";
|
|
14866
16296
|
import { pathToFileURL } from "node:url";
|
|
14867
16297
|
import ts from "typescript";
|
|
14868
16298
|
async function loadConfig2(configPath) {
|
|
14869
|
-
if (!/\.(js|mjs)$/.test(
|
|
16299
|
+
if (!/\.(js|mjs)$/.test(extname2(configPath))) {
|
|
14870
16300
|
throw new Error("Unsupported config file format");
|
|
14871
16301
|
}
|
|
14872
16302
|
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
@@ -14874,7 +16304,7 @@ async function loadConfig2(configPath) {
|
|
|
14874
16304
|
__name(loadConfig2, "loadConfig");
|
|
14875
16305
|
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
14876
16306
|
const tsConfigFile = ts.readConfigFile(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
14877
|
-
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys,
|
|
16307
|
+
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname3(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
14878
16308
|
const compilerOptions = {
|
|
14879
16309
|
rootDir: projectRoot,
|
|
14880
16310
|
declaration: true,
|
|
@@ -14905,7 +16335,7 @@ var tscPlugin = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
|
|
|
14905
16335
|
}, "tscPlugin");
|
|
14906
16336
|
|
|
14907
16337
|
// src/plugins/type-definitions.ts
|
|
14908
|
-
import { relative as
|
|
16338
|
+
import { relative as relative4 } from "node:path";
|
|
14909
16339
|
function typeDefinitions(projectRoot) {
|
|
14910
16340
|
return {
|
|
14911
16341
|
name: "storm:dts-bundle",
|
|
@@ -14915,7 +16345,7 @@ function typeDefinitions(projectRoot) {
|
|
|
14915
16345
|
continue;
|
|
14916
16346
|
}
|
|
14917
16347
|
const hasDefaultExport = file.exports.includes("default");
|
|
14918
|
-
const entrySourceFileName =
|
|
16348
|
+
const entrySourceFileName = relative4(projectRoot, file.facadeModuleId);
|
|
14919
16349
|
const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
|
|
14920
16350
|
const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
|
|
14921
16351
|
const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
|
|
@@ -14960,19 +16390,19 @@ async function resolveOptions(options) {
|
|
|
14960
16390
|
if (options.configPath) {
|
|
14961
16391
|
const configFile = await loadConfig2(options.configPath);
|
|
14962
16392
|
if (configFile) {
|
|
14963
|
-
options =
|
|
16393
|
+
options = defu4(options, configFile);
|
|
14964
16394
|
}
|
|
14965
16395
|
}
|
|
14966
16396
|
const projectGraph = readCachedProjectGraph4();
|
|
14967
16397
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
14968
|
-
if (!
|
|
16398
|
+
if (!existsSync7(projectJsonPath)) {
|
|
14969
16399
|
throw new Error("Cannot find project.json configuration");
|
|
14970
16400
|
}
|
|
14971
16401
|
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
14972
16402
|
const projectJson = JSON.parse(projectJsonContent);
|
|
14973
16403
|
const projectName = projectJson.name;
|
|
14974
16404
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
14975
|
-
if (!
|
|
16405
|
+
if (!existsSync7(packageJsonPath)) {
|
|
14976
16406
|
throw new Error("Cannot find package.json configuration");
|
|
14977
16407
|
}
|
|
14978
16408
|
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
@@ -14981,14 +16411,14 @@ async function resolveOptions(options) {
|
|
|
14981
16411
|
if (!tsconfig) {
|
|
14982
16412
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
14983
16413
|
}
|
|
14984
|
-
if (!
|
|
16414
|
+
if (!existsSync7(tsconfig)) {
|
|
14985
16415
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
14986
16416
|
}
|
|
14987
16417
|
let sourceRoot = projectJson.sourceRoot;
|
|
14988
16418
|
if (!sourceRoot) {
|
|
14989
16419
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
14990
16420
|
}
|
|
14991
|
-
if (!
|
|
16421
|
+
if (!existsSync7(sourceRoot)) {
|
|
14992
16422
|
throw new Error("Cannot find sourceRoot directory");
|
|
14993
16423
|
}
|
|
14994
16424
|
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -15010,14 +16440,14 @@ async function resolveOptions(options) {
|
|
|
15010
16440
|
{
|
|
15011
16441
|
builder: "mkdist",
|
|
15012
16442
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
15013
|
-
outDir: joinPaths(
|
|
16443
|
+
outDir: joinPaths(relative5(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
15014
16444
|
declaration: options.emitTypes !== false,
|
|
15015
16445
|
format: "esm"
|
|
15016
16446
|
},
|
|
15017
16447
|
{
|
|
15018
16448
|
builder: "mkdist",
|
|
15019
16449
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
15020
|
-
outDir: joinPaths(
|
|
16450
|
+
outDir: joinPaths(relative5(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
15021
16451
|
declaration: options.emitTypes !== false,
|
|
15022
16452
|
format: "cjs",
|
|
15023
16453
|
ext: "cjs"
|
|
@@ -15090,16 +16520,16 @@ async function resolveOptions(options) {
|
|
|
15090
16520
|
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
15091
16521
|
}
|
|
15092
16522
|
if (options.rollup) {
|
|
15093
|
-
let
|
|
16523
|
+
let rollup2 = {};
|
|
15094
16524
|
if (typeof options.rollup === "string") {
|
|
15095
16525
|
const rollupFile = await loadConfig2(options.rollup);
|
|
15096
16526
|
if (rollupFile) {
|
|
15097
|
-
|
|
16527
|
+
rollup2 = rollupFile;
|
|
15098
16528
|
}
|
|
15099
16529
|
} else {
|
|
15100
|
-
|
|
16530
|
+
rollup2 = options.rollup;
|
|
15101
16531
|
}
|
|
15102
|
-
resolvedOptions.rollup =
|
|
16532
|
+
resolvedOptions.rollup = defu4(resolvedOptions.rollup ?? {}, rollup2);
|
|
15103
16533
|
}
|
|
15104
16534
|
resolvedOptions.hooks = {
|
|
15105
16535
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
@@ -15111,11 +16541,11 @@ async function resolveOptions(options) {
|
|
|
15111
16541
|
}
|
|
15112
16542
|
__name(resolveOptions, "resolveOptions");
|
|
15113
16543
|
async function generatePackageJson(options) {
|
|
15114
|
-
if (options.generatePackageJson !== false &&
|
|
16544
|
+
if (options.generatePackageJson !== false && existsSync7(joinPaths(options.projectRoot, "package.json"))) {
|
|
15115
16545
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
15116
16546
|
const stopwatch = getStopwatch("Write package.json file");
|
|
15117
16547
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
15118
|
-
if (!
|
|
16548
|
+
if (!existsSync7(packageJsonPath)) {
|
|
15119
16549
|
throw new Error("Cannot find package.json configuration");
|
|
15120
16550
|
}
|
|
15121
16551
|
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
@@ -15135,7 +16565,7 @@ async function executeUnbuild(options) {
|
|
|
15135
16565
|
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
15136
16566
|
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
15137
16567
|
try {
|
|
15138
|
-
await
|
|
16568
|
+
await build(options.projectRoot, false, {
|
|
15139
16569
|
...options,
|
|
15140
16570
|
rootDir: options.projectRoot
|
|
15141
16571
|
});
|
|
@@ -15160,7 +16590,7 @@ async function cleanOutputPath(options) {
|
|
|
15160
16590
|
return options;
|
|
15161
16591
|
}
|
|
15162
16592
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
15163
|
-
async function
|
|
16593
|
+
async function build2(options) {
|
|
15164
16594
|
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
|
|
15165
16595
|
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
15166
16596
|
try {
|
|
@@ -15177,7 +16607,7 @@ async function build(options) {
|
|
|
15177
16607
|
stopwatch();
|
|
15178
16608
|
}
|
|
15179
16609
|
}
|
|
15180
|
-
__name(
|
|
16610
|
+
__name(build2, "build");
|
|
15181
16611
|
|
|
15182
16612
|
// bin/unbuild.ts
|
|
15183
16613
|
async function createProgram(config) {
|
|
@@ -15255,7 +16685,7 @@ async function createProgram(config) {
|
|
|
15255
16685
|
__name(createProgram, "createProgram");
|
|
15256
16686
|
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
15257
16687
|
try {
|
|
15258
|
-
await
|
|
16688
|
+
await build2({
|
|
15259
16689
|
...options,
|
|
15260
16690
|
sourcemap: !!options.debug,
|
|
15261
16691
|
replace: {},
|