@storm-software/unbuild 0.22.0 → 0.23.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 +184 -1599
- package/bin/unbuild.mjs +184 -1595
- package/dist/build.d.mts +1 -0
- package/dist/build.d.ts +1 -0
- package/dist/build.js +10 -10
- package/dist/build.mjs +1 -1
- package/dist/chunk-3GQAWCBQ.js +13 -0
- package/dist/{chunk-E73BVQF5.js → chunk-3OJD7CO4.js} +5 -5
- package/dist/chunk-AW52DUNE.mjs +1043 -0
- package/dist/chunk-AYRYNROK.js +27 -0
- package/dist/{chunk-B2WY6JG2.js → chunk-DFIGNXGY.js} +1035 -1035
- package/dist/{chunk-UUI4UWA4.js → chunk-OQPSH7GE.js} +37 -37
- package/dist/{chunk-RUNO4F6F.js → chunk-RCEWRXM5.js} +2 -2
- package/dist/chunk-T2OTJN2D.js +1043 -0
- package/dist/{chunk-BMAXMHJB.js → chunk-WPOEGALQ.js} +5 -5
- package/dist/{chunk-6KE6SIPQ.js → chunk-XEAFTDQ7.js} +5 -5
- package/dist/clean.js +4 -4
- package/dist/config.d.mts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +8 -8
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -10
- package/dist/index.mjs +1 -1
- package/dist/types.d.mts +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +0 -1
- package/package.json +190 -1
- package/dist/chunk-2Q67L63A.js +0 -2456
- package/dist/chunk-4WKFVYTI.js +0 -18
- package/dist/chunk-J5YBLOB7.js +0 -27
- package/dist/chunk-SGIQJ2OU.mjs +0 -2455
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 colors2 = !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(colors2.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(colors2.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(colors2.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(colors2.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(colors2.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(colors2.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(colors2.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
549
549
|
`);
|
|
550
550
|
};
|
|
551
551
|
}, "getLogFn");
|
|
@@ -636,7 +636,7 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
636
636
|
envName: fileName?.toUpperCase(),
|
|
637
637
|
jitiOptions: {
|
|
638
638
|
debug: false,
|
|
639
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "
|
|
639
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
640
640
|
},
|
|
641
641
|
...options
|
|
642
642
|
});
|
|
@@ -648,7 +648,7 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
648
648
|
envName: fileName?.toUpperCase(),
|
|
649
649
|
jitiOptions: {
|
|
650
650
|
debug: false,
|
|
651
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "
|
|
651
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
|
|
652
652
|
},
|
|
653
653
|
configFile: fileName,
|
|
654
654
|
...options
|
|
@@ -1367,1443 +1367,13 @@ 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 {
|
|
1370
|
+
import defu3 from "defu";
|
|
1371
|
+
import { createJiti } from "jiti";
|
|
1372
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
1372
1373
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
1373
|
-
import { relative as
|
|
1374
|
+
import { relative as relative4 } from "node:path";
|
|
1374
1375
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
1375
1376
|
|
|
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";
|
|
2806
|
-
|
|
2807
1377
|
// src/clean.ts
|
|
2808
1378
|
import { rm } from "node:fs/promises";
|
|
2809
1379
|
async function clean(name = "Unbuild", directory, config) {
|
|
@@ -2870,23 +1440,23 @@ import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler
|
|
|
2870
1440
|
|
|
2871
1441
|
// ../../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
|
|
2872
1442
|
import * as require$$0 from "path";
|
|
2873
|
-
import require$$0__default, { dirname
|
|
1443
|
+
import require$$0__default, { dirname, normalize as normalize2, resolve, relative as relative2 } from "path";
|
|
2874
1444
|
import { normalizePath, createFilter as createFilter$1 } from "@rollup/pluginutils";
|
|
2875
1445
|
import require$$2 from "util";
|
|
2876
1446
|
import require$$0$1 from "os";
|
|
2877
1447
|
import require$$3, { satisfies } from "semver";
|
|
2878
|
-
import require$$0$2, { existsSync as
|
|
1448
|
+
import require$$0$2, { existsSync as existsSync5, readdirSync, renameSync, readFileSync as readFileSync2 } from "fs";
|
|
2879
1449
|
import * as fs$4 from "fs-extra";
|
|
2880
1450
|
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync as removeSync2 } from "fs-extra";
|
|
2881
1451
|
import require$$0$3 from "crypto";
|
|
2882
1452
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2883
1453
|
function adopt(value) {
|
|
2884
|
-
return value instanceof P ? value : new P(function(
|
|
2885
|
-
|
|
1454
|
+
return value instanceof P ? value : new P(function(resolve2) {
|
|
1455
|
+
resolve2(value);
|
|
2886
1456
|
});
|
|
2887
1457
|
}
|
|
2888
1458
|
__name(adopt, "adopt");
|
|
2889
|
-
return new (P || (P = Promise))(function(
|
|
1459
|
+
return new (P || (P = Promise))(function(resolve2, reject) {
|
|
2890
1460
|
function fulfilled(value) {
|
|
2891
1461
|
try {
|
|
2892
1462
|
step(generator.next(value));
|
|
@@ -2904,7 +1474,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
2904
1474
|
}
|
|
2905
1475
|
__name(rejected, "rejected");
|
|
2906
1476
|
function step(result) {
|
|
2907
|
-
result.done ?
|
|
1477
|
+
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2908
1478
|
}
|
|
2909
1479
|
__name(step, "step");
|
|
2910
1480
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -2915,7 +1485,7 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
|
|
|
2915
1485
|
var safe = {
|
|
2916
1486
|
exports: {}
|
|
2917
1487
|
};
|
|
2918
|
-
var
|
|
1488
|
+
var colors = {
|
|
2919
1489
|
exports: {}
|
|
2920
1490
|
};
|
|
2921
1491
|
var styles = {
|
|
@@ -3632,16 +2202,16 @@ function requireAmerica() {
|
|
|
3632
2202
|
if (hasRequiredAmerica) return america.exports;
|
|
3633
2203
|
hasRequiredAmerica = 1;
|
|
3634
2204
|
(function(module) {
|
|
3635
|
-
module["exports"] = function(
|
|
2205
|
+
module["exports"] = function(colors2) {
|
|
3636
2206
|
return function(letter, i, exploded) {
|
|
3637
2207
|
if (letter === " ") return letter;
|
|
3638
2208
|
switch (i % 3) {
|
|
3639
2209
|
case 0:
|
|
3640
|
-
return
|
|
2210
|
+
return colors2.red(letter);
|
|
3641
2211
|
case 1:
|
|
3642
|
-
return
|
|
2212
|
+
return colors2.white(letter);
|
|
3643
2213
|
case 2:
|
|
3644
|
-
return
|
|
2214
|
+
return colors2.blue(letter);
|
|
3645
2215
|
}
|
|
3646
2216
|
};
|
|
3647
2217
|
};
|
|
@@ -3657,9 +2227,9 @@ function requireZebra() {
|
|
|
3657
2227
|
if (hasRequiredZebra) return zebra.exports;
|
|
3658
2228
|
hasRequiredZebra = 1;
|
|
3659
2229
|
(function(module) {
|
|
3660
|
-
module["exports"] = function(
|
|
2230
|
+
module["exports"] = function(colors2) {
|
|
3661
2231
|
return function(letter, i, exploded) {
|
|
3662
|
-
return i % 2 === 0 ? letter :
|
|
2232
|
+
return i % 2 === 0 ? letter : colors2.inverse(letter);
|
|
3663
2233
|
};
|
|
3664
2234
|
};
|
|
3665
2235
|
})(zebra);
|
|
@@ -3674,7 +2244,7 @@ function requireRainbow() {
|
|
|
3674
2244
|
if (hasRequiredRainbow) return rainbow.exports;
|
|
3675
2245
|
hasRequiredRainbow = 1;
|
|
3676
2246
|
(function(module) {
|
|
3677
|
-
module["exports"] = function(
|
|
2247
|
+
module["exports"] = function(colors2) {
|
|
3678
2248
|
var rainbowColors = [
|
|
3679
2249
|
"red",
|
|
3680
2250
|
"yellow",
|
|
@@ -3686,7 +2256,7 @@ function requireRainbow() {
|
|
|
3686
2256
|
if (letter === " ") {
|
|
3687
2257
|
return letter;
|
|
3688
2258
|
} else {
|
|
3689
|
-
return
|
|
2259
|
+
return colors2[rainbowColors[i++ % rainbowColors.length]](letter);
|
|
3690
2260
|
}
|
|
3691
2261
|
};
|
|
3692
2262
|
};
|
|
@@ -3702,7 +2272,7 @@ function requireRandom() {
|
|
|
3702
2272
|
if (hasRequiredRandom) return random.exports;
|
|
3703
2273
|
hasRequiredRandom = 1;
|
|
3704
2274
|
(function(module) {
|
|
3705
|
-
module["exports"] = function(
|
|
2275
|
+
module["exports"] = function(colors2) {
|
|
3706
2276
|
var available = [
|
|
3707
2277
|
"underline",
|
|
3708
2278
|
"inverse",
|
|
@@ -3723,7 +2293,7 @@ function requireRandom() {
|
|
|
3723
2293
|
"brightMagenta"
|
|
3724
2294
|
];
|
|
3725
2295
|
return function(letter, i, exploded) {
|
|
3726
|
-
return letter === " " ? letter :
|
|
2296
|
+
return letter === " " ? letter : colors2[available[Math.round(Math.random() * (available.length - 2))]](letter);
|
|
3727
2297
|
};
|
|
3728
2298
|
};
|
|
3729
2299
|
})(random);
|
|
@@ -3731,33 +2301,33 @@ function requireRandom() {
|
|
|
3731
2301
|
}
|
|
3732
2302
|
__name(requireRandom, "requireRandom");
|
|
3733
2303
|
(function(module) {
|
|
3734
|
-
var
|
|
3735
|
-
module["exports"] =
|
|
3736
|
-
|
|
2304
|
+
var colors2 = {};
|
|
2305
|
+
module["exports"] = colors2;
|
|
2306
|
+
colors2.themes = {};
|
|
3737
2307
|
var util = require$$2;
|
|
3738
|
-
var ansiStyles =
|
|
2308
|
+
var ansiStyles = colors2.styles = styles.exports;
|
|
3739
2309
|
var defineProps = Object.defineProperties;
|
|
3740
2310
|
var newLineRegex = new RegExp(/[\r\n]+/g);
|
|
3741
|
-
|
|
3742
|
-
if (typeof
|
|
3743
|
-
|
|
2311
|
+
colors2.supportsColor = supportsColors.supportsColor;
|
|
2312
|
+
if (typeof colors2.enabled === "undefined") {
|
|
2313
|
+
colors2.enabled = colors2.supportsColor() !== false;
|
|
3744
2314
|
}
|
|
3745
|
-
|
|
3746
|
-
|
|
2315
|
+
colors2.enable = function() {
|
|
2316
|
+
colors2.enabled = true;
|
|
3747
2317
|
};
|
|
3748
|
-
|
|
3749
|
-
|
|
2318
|
+
colors2.disable = function() {
|
|
2319
|
+
colors2.enabled = false;
|
|
3750
2320
|
};
|
|
3751
|
-
|
|
2321
|
+
colors2.stripColors = colors2.strip = function(str) {
|
|
3752
2322
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
3753
2323
|
};
|
|
3754
|
-
|
|
3755
|
-
if (!
|
|
2324
|
+
colors2.stylize = /* @__PURE__ */ __name(function stylize(str, style) {
|
|
2325
|
+
if (!colors2.enabled) {
|
|
3756
2326
|
return str + "";
|
|
3757
2327
|
}
|
|
3758
2328
|
var styleMap = ansiStyles[style];
|
|
3759
|
-
if (!styleMap && style in
|
|
3760
|
-
return
|
|
2329
|
+
if (!styleMap && style in colors2) {
|
|
2330
|
+
return colors2[style](str);
|
|
3761
2331
|
}
|
|
3762
2332
|
return styleMap.open + str + styleMap.close;
|
|
3763
2333
|
}, "stylize");
|
|
@@ -3768,7 +2338,7 @@ __name(requireRandom, "requireRandom");
|
|
|
3768
2338
|
}
|
|
3769
2339
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
3770
2340
|
}, "escapeStringRegexp");
|
|
3771
|
-
function
|
|
2341
|
+
function build2(_styles) {
|
|
3772
2342
|
var builder = /* @__PURE__ */ __name(function builder2() {
|
|
3773
2343
|
return applyStyle.apply(builder2, arguments);
|
|
3774
2344
|
}, "builder");
|
|
@@ -3776,7 +2346,7 @@ __name(requireRandom, "requireRandom");
|
|
|
3776
2346
|
builder.__proto__ = proto;
|
|
3777
2347
|
return builder;
|
|
3778
2348
|
}
|
|
3779
|
-
__name(
|
|
2349
|
+
__name(build2, "build");
|
|
3780
2350
|
var styles$1 = function() {
|
|
3781
2351
|
var ret = {};
|
|
3782
2352
|
ansiStyles.grey = ansiStyles.gray;
|
|
@@ -3784,13 +2354,13 @@ __name(requireRandom, "requireRandom");
|
|
|
3784
2354
|
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
|
|
3785
2355
|
ret[key] = {
|
|
3786
2356
|
get: /* @__PURE__ */ __name(function() {
|
|
3787
|
-
return
|
|
2357
|
+
return build2(this._styles.concat(key));
|
|
3788
2358
|
}, "get")
|
|
3789
2359
|
};
|
|
3790
2360
|
});
|
|
3791
2361
|
return ret;
|
|
3792
2362
|
}();
|
|
3793
|
-
var proto = defineProps(/* @__PURE__ */ __name(function
|
|
2363
|
+
var proto = defineProps(/* @__PURE__ */ __name(function colors3() {
|
|
3794
2364
|
}, "colors"), styles$1);
|
|
3795
2365
|
function applyStyle() {
|
|
3796
2366
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -3801,7 +2371,7 @@ __name(requireRandom, "requireRandom");
|
|
|
3801
2371
|
return util.inspect(arg);
|
|
3802
2372
|
}
|
|
3803
2373
|
}).join(" ");
|
|
3804
|
-
if (!
|
|
2374
|
+
if (!colors2.enabled || !str) {
|
|
3805
2375
|
return str;
|
|
3806
2376
|
}
|
|
3807
2377
|
var newLinesPresent = str.indexOf("\n") != -1;
|
|
@@ -3819,22 +2389,22 @@ __name(requireRandom, "requireRandom");
|
|
|
3819
2389
|
return str;
|
|
3820
2390
|
}
|
|
3821
2391
|
__name(applyStyle, "applyStyle");
|
|
3822
|
-
|
|
2392
|
+
colors2.setTheme = function(theme) {
|
|
3823
2393
|
if (typeof theme === "string") {
|
|
3824
2394
|
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'));");
|
|
3825
2395
|
return;
|
|
3826
2396
|
}
|
|
3827
2397
|
for (var style in theme) {
|
|
3828
2398
|
(function(style2) {
|
|
3829
|
-
|
|
2399
|
+
colors2[style2] = function(str) {
|
|
3830
2400
|
if (typeof theme[style2] === "object") {
|
|
3831
2401
|
var out = str;
|
|
3832
2402
|
for (var i in theme[style2]) {
|
|
3833
|
-
out =
|
|
2403
|
+
out = colors2[theme[style2][i]](out);
|
|
3834
2404
|
}
|
|
3835
2405
|
return out;
|
|
3836
2406
|
}
|
|
3837
|
-
return
|
|
2407
|
+
return colors2[theme[style2]](str);
|
|
3838
2408
|
};
|
|
3839
2409
|
})(style);
|
|
3840
2410
|
}
|
|
@@ -3844,7 +2414,7 @@ __name(requireRandom, "requireRandom");
|
|
|
3844
2414
|
Object.keys(styles$1).forEach(function(name) {
|
|
3845
2415
|
ret[name] = {
|
|
3846
2416
|
get: /* @__PURE__ */ __name(function() {
|
|
3847
|
-
return
|
|
2417
|
+
return build2([
|
|
3848
2418
|
name
|
|
3849
2419
|
]);
|
|
3850
2420
|
}, "get")
|
|
@@ -3858,24 +2428,24 @@ __name(requireRandom, "requireRandom");
|
|
|
3858
2428
|
exploded = exploded.map(map2);
|
|
3859
2429
|
return exploded.join("");
|
|
3860
2430
|
}, "sequencer");
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
for (var map in
|
|
2431
|
+
colors2.trap = requireTrap();
|
|
2432
|
+
colors2.zalgo = requireZalgo();
|
|
2433
|
+
colors2.maps = {};
|
|
2434
|
+
colors2.maps.america = requireAmerica()(colors2);
|
|
2435
|
+
colors2.maps.zebra = requireZebra()(colors2);
|
|
2436
|
+
colors2.maps.rainbow = requireRainbow()(colors2);
|
|
2437
|
+
colors2.maps.random = requireRandom()(colors2);
|
|
2438
|
+
for (var map in colors2.maps) {
|
|
3869
2439
|
(function(map2) {
|
|
3870
|
-
|
|
3871
|
-
return sequencer(
|
|
2440
|
+
colors2[map2] = function(str) {
|
|
2441
|
+
return sequencer(colors2.maps[map2], str);
|
|
3872
2442
|
};
|
|
3873
2443
|
})(map);
|
|
3874
2444
|
}
|
|
3875
|
-
defineProps(
|
|
3876
|
-
})(
|
|
2445
|
+
defineProps(colors2, init());
|
|
2446
|
+
})(colors);
|
|
3877
2447
|
(function(module) {
|
|
3878
|
-
var colors$1 =
|
|
2448
|
+
var colors$1 = colors.exports;
|
|
3879
2449
|
module["exports"] = colors$1;
|
|
3880
2450
|
})(safe);
|
|
3881
2451
|
var path$4 = require$$0__default;
|
|
@@ -3915,8 +2485,8 @@ var pLimit$2 = {
|
|
|
3915
2485
|
var pTry$2 = {
|
|
3916
2486
|
exports: {}
|
|
3917
2487
|
};
|
|
3918
|
-
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((
|
|
3919
|
-
|
|
2488
|
+
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((resolve2) => {
|
|
2489
|
+
resolve2(fn(...arguments_));
|
|
3920
2490
|
}), "pTry$1");
|
|
3921
2491
|
pTry$2.exports = pTry$1;
|
|
3922
2492
|
pTry$2.exports.default = pTry$1;
|
|
@@ -3933,20 +2503,20 @@ var pLimit$1 = /* @__PURE__ */ __name((concurrency) => {
|
|
|
3933
2503
|
queue.shift()();
|
|
3934
2504
|
}
|
|
3935
2505
|
}, "next");
|
|
3936
|
-
const run = /* @__PURE__ */ __name((fn,
|
|
2506
|
+
const run = /* @__PURE__ */ __name((fn, resolve2, ...args) => {
|
|
3937
2507
|
activeCount++;
|
|
3938
2508
|
const result = pTry(fn, ...args);
|
|
3939
|
-
|
|
2509
|
+
resolve2(result);
|
|
3940
2510
|
result.then(next, next);
|
|
3941
2511
|
}, "run");
|
|
3942
|
-
const enqueue = /* @__PURE__ */ __name((fn,
|
|
2512
|
+
const enqueue = /* @__PURE__ */ __name((fn, resolve2, ...args) => {
|
|
3943
2513
|
if (activeCount < concurrency) {
|
|
3944
|
-
run(fn,
|
|
2514
|
+
run(fn, resolve2, ...args);
|
|
3945
2515
|
} else {
|
|
3946
|
-
queue.push(run.bind(null, fn,
|
|
2516
|
+
queue.push(run.bind(null, fn, resolve2, ...args));
|
|
3947
2517
|
}
|
|
3948
2518
|
}, "enqueue");
|
|
3949
|
-
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((
|
|
2519
|
+
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve2) => enqueue(fn, resolve2, ...args)), "generator");
|
|
3950
2520
|
Object.defineProperties(generator, {
|
|
3951
2521
|
activeCount: {
|
|
3952
2522
|
get: /* @__PURE__ */ __name(() => activeCount, "get")
|
|
@@ -4189,12 +2759,12 @@ var checkPath = /* @__PURE__ */ __name((pth) => {
|
|
|
4189
2759
|
}
|
|
4190
2760
|
}, "checkPath");
|
|
4191
2761
|
var processOptions = /* @__PURE__ */ __name((options) => {
|
|
4192
|
-
const
|
|
2762
|
+
const defaults = {
|
|
4193
2763
|
mode: 511 & ~process.umask(),
|
|
4194
2764
|
fs: fs$1
|
|
4195
2765
|
};
|
|
4196
2766
|
return {
|
|
4197
|
-
...
|
|
2767
|
+
...defaults,
|
|
4198
2768
|
...options
|
|
4199
2769
|
};
|
|
4200
2770
|
}, "processOptions");
|
|
@@ -4209,11 +2779,11 @@ var permissionError = /* @__PURE__ */ __name((pth) => {
|
|
|
4209
2779
|
var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
4210
2780
|
checkPath(input);
|
|
4211
2781
|
options = processOptions(options);
|
|
4212
|
-
const
|
|
2782
|
+
const mkdir = promisify(options.fs.mkdir);
|
|
4213
2783
|
const stat = promisify(options.fs.stat);
|
|
4214
2784
|
if (useNativeRecursiveOption && options.fs.mkdir === fs$1.mkdir) {
|
|
4215
2785
|
const pth = path$1.resolve(input);
|
|
4216
|
-
await
|
|
2786
|
+
await mkdir(pth, {
|
|
4217
2787
|
mode: options.mode,
|
|
4218
2788
|
recursive: true
|
|
4219
2789
|
});
|
|
@@ -4221,7 +2791,7 @@ var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
|
4221
2791
|
}
|
|
4222
2792
|
const make = /* @__PURE__ */ __name(async (pth) => {
|
|
4223
2793
|
try {
|
|
4224
|
-
await
|
|
2794
|
+
await mkdir(pth, options.mode);
|
|
4225
2795
|
return pth;
|
|
4226
2796
|
} catch (error) {
|
|
4227
2797
|
if (error.code === "EPERM") {
|
|
@@ -4916,11 +3486,11 @@ var lodash$1 = {
|
|
|
4916
3486
|
return result;
|
|
4917
3487
|
}
|
|
4918
3488
|
__name(arrayFilter, "arrayFilter");
|
|
4919
|
-
function
|
|
3489
|
+
function arrayIncludes(array, value) {
|
|
4920
3490
|
var length = array == null ? 0 : array.length;
|
|
4921
3491
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
4922
3492
|
}
|
|
4923
|
-
__name(
|
|
3493
|
+
__name(arrayIncludes, "arrayIncludes");
|
|
4924
3494
|
function arrayIncludesWith(array, value, comparator) {
|
|
4925
3495
|
var index = -1, length = array == null ? 0 : array.length;
|
|
4926
3496
|
while (++index < length) {
|
|
@@ -5169,9 +3739,9 @@ var lodash$1 = {
|
|
|
5169
3739
|
return result;
|
|
5170
3740
|
}
|
|
5171
3741
|
__name(mapToArray, "mapToArray");
|
|
5172
|
-
function overArg(func,
|
|
3742
|
+
function overArg(func, transform2) {
|
|
5173
3743
|
return function(arg) {
|
|
5174
|
-
return func(
|
|
3744
|
+
return func(transform2(arg));
|
|
5175
3745
|
};
|
|
5176
3746
|
}
|
|
5177
3747
|
__name(overArg, "overArg");
|
|
@@ -5845,7 +4415,7 @@ var lodash$1 = {
|
|
|
5845
4415
|
}
|
|
5846
4416
|
__name(baseDelay, "baseDelay");
|
|
5847
4417
|
function baseDifference(array, values2, iteratee2, comparator) {
|
|
5848
|
-
var index = -1, includes2 =
|
|
4418
|
+
var index = -1, includes2 = arrayIncludes, isCommon = true, length = array.length, result2 = [], valuesLength = values2.length;
|
|
5849
4419
|
if (!length) {
|
|
5850
4420
|
return result2;
|
|
5851
4421
|
}
|
|
@@ -6000,7 +4570,7 @@ var lodash$1 = {
|
|
|
6000
4570
|
}
|
|
6001
4571
|
__name(baseInRange, "baseInRange");
|
|
6002
4572
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
6003
|
-
var includes2 = comparator ? arrayIncludesWith :
|
|
4573
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array1(othLength), maxLength = Infinity, result2 = [];
|
|
6004
4574
|
while (othIndex--) {
|
|
6005
4575
|
var array = arrays[othIndex];
|
|
6006
4576
|
if (othIndex && iteratee2) {
|
|
@@ -6581,7 +5151,7 @@ var lodash$1 = {
|
|
|
6581
5151
|
}
|
|
6582
5152
|
__name(baseToString, "baseToString");
|
|
6583
5153
|
function baseUniq(array, iteratee2, comparator) {
|
|
6584
|
-
var index = -1, includes2 =
|
|
5154
|
+
var index = -1, includes2 = arrayIncludes, length = array.length, isCommon = true, result2 = [], seen = result2;
|
|
6585
5155
|
if (comparator) {
|
|
6586
5156
|
isCommon = false;
|
|
6587
5157
|
includes2 = arrayIncludesWith;
|
|
@@ -7779,7 +6349,7 @@ var lodash$1 = {
|
|
|
7779
6349
|
return nativeObjectToString.call(value);
|
|
7780
6350
|
}
|
|
7781
6351
|
__name(objectToString, "objectToString");
|
|
7782
|
-
function overRest(func, start,
|
|
6352
|
+
function overRest(func, start, transform3) {
|
|
7783
6353
|
start = nativeMax(start === undefined$1 ? func.length - 1 : start, 0);
|
|
7784
6354
|
return function() {
|
|
7785
6355
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array1(length);
|
|
@@ -7791,7 +6361,7 @@ var lodash$1 = {
|
|
|
7791
6361
|
while (++index < start) {
|
|
7792
6362
|
otherArgs[index] = args[index];
|
|
7793
6363
|
}
|
|
7794
|
-
otherArgs[start] =
|
|
6364
|
+
otherArgs[start] = transform3(array);
|
|
7795
6365
|
return apply(func, this, otherArgs);
|
|
7796
6366
|
};
|
|
7797
6367
|
}
|
|
@@ -7892,7 +6462,7 @@ var lodash$1 = {
|
|
|
7892
6462
|
function updateWrapDetails(details, bitmask) {
|
|
7893
6463
|
arrayEach(wrapFlags, function(pair) {
|
|
7894
6464
|
var value = "_." + pair[0];
|
|
7895
|
-
if (bitmask & pair[1] && !
|
|
6465
|
+
if (bitmask & pair[1] && !arrayIncludes(details, value)) {
|
|
7896
6466
|
details.push(value);
|
|
7897
6467
|
}
|
|
7898
6468
|
});
|
|
@@ -8103,10 +6673,10 @@ var lodash$1 = {
|
|
|
8103
6673
|
}
|
|
8104
6674
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined$1, comparator) : [];
|
|
8105
6675
|
});
|
|
8106
|
-
function
|
|
6676
|
+
function join4(array, separator) {
|
|
8107
6677
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
8108
6678
|
}
|
|
8109
|
-
__name(
|
|
6679
|
+
__name(join4, "join");
|
|
8110
6680
|
function last(array) {
|
|
8111
6681
|
var length = array == null ? 0 : array.length;
|
|
8112
6682
|
return length ? array[length - 1] : undefined$1;
|
|
@@ -9211,7 +7781,7 @@ var lodash$1 = {
|
|
|
9211
7781
|
return properties == null ? result2 : baseAssign(result2, properties);
|
|
9212
7782
|
}
|
|
9213
7783
|
__name(create, "create");
|
|
9214
|
-
var
|
|
7784
|
+
var defaults = baseRest(function(object, sources) {
|
|
9215
7785
|
object = Object1(object);
|
|
9216
7786
|
var index = -1;
|
|
9217
7787
|
var length = sources.length;
|
|
@@ -9406,7 +7976,7 @@ var lodash$1 = {
|
|
|
9406
7976
|
__name(setWith, "setWith");
|
|
9407
7977
|
var toPairs = createToPairs(keys);
|
|
9408
7978
|
var toPairsIn = createToPairs(keysIn);
|
|
9409
|
-
function
|
|
7979
|
+
function transform2(object, iteratee2, accumulator) {
|
|
9410
7980
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
9411
7981
|
iteratee2 = getIteratee(iteratee2, 4);
|
|
9412
7982
|
if (accumulator == null) {
|
|
@@ -9424,7 +7994,7 @@ var lodash$1 = {
|
|
|
9424
7994
|
});
|
|
9425
7995
|
return accumulator;
|
|
9426
7996
|
}
|
|
9427
|
-
__name(
|
|
7997
|
+
__name(transform2, "transform");
|
|
9428
7998
|
function unset(object, path3) {
|
|
9429
7999
|
return object == null ? true : baseUnset(object, path3);
|
|
9430
8000
|
}
|
|
@@ -9594,11 +8164,11 @@ var lodash$1 = {
|
|
|
9594
8164
|
return baseRepeat(toString(string), n);
|
|
9595
8165
|
}
|
|
9596
8166
|
__name(repeat, "repeat");
|
|
9597
|
-
function
|
|
8167
|
+
function replace() {
|
|
9598
8168
|
var args = arguments, string = toString(args[0]);
|
|
9599
8169
|
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
9600
8170
|
}
|
|
9601
|
-
__name(
|
|
8171
|
+
__name(replace, "replace");
|
|
9602
8172
|
var snakeCase = createCompounder(function(result2, word, index) {
|
|
9603
8173
|
return result2 + (index ? "_" : "") + word.toLowerCase();
|
|
9604
8174
|
});
|
|
@@ -10051,7 +8621,7 @@ var lodash$1 = {
|
|
|
10051
8621
|
lodash2.curry = curry;
|
|
10052
8622
|
lodash2.curryRight = curryRight;
|
|
10053
8623
|
lodash2.debounce = debounce;
|
|
10054
|
-
lodash2.defaults =
|
|
8624
|
+
lodash2.defaults = defaults;
|
|
10055
8625
|
lodash2.defaultsDeep = defaultsDeep;
|
|
10056
8626
|
lodash2.defer = defer;
|
|
10057
8627
|
lodash2.delay = delay;
|
|
@@ -10151,7 +8721,7 @@ var lodash$1 = {
|
|
|
10151
8721
|
lodash2.toPairsIn = toPairsIn;
|
|
10152
8722
|
lodash2.toPath = toPath;
|
|
10153
8723
|
lodash2.toPlainObject = toPlainObject;
|
|
10154
|
-
lodash2.transform =
|
|
8724
|
+
lodash2.transform = transform2;
|
|
10155
8725
|
lodash2.unary = unary;
|
|
10156
8726
|
lodash2.union = union;
|
|
10157
8727
|
lodash2.unionBy = unionBy;
|
|
@@ -10261,7 +8831,7 @@ var lodash$1 = {
|
|
|
10261
8831
|
lodash2.isUndefined = isUndefined;
|
|
10262
8832
|
lodash2.isWeakMap = isWeakMap;
|
|
10263
8833
|
lodash2.isWeakSet = isWeakSet;
|
|
10264
|
-
lodash2.join =
|
|
8834
|
+
lodash2.join = join4;
|
|
10265
8835
|
lodash2.kebabCase = kebabCase;
|
|
10266
8836
|
lodash2.last = last;
|
|
10267
8837
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -10293,7 +8863,7 @@ var lodash$1 = {
|
|
|
10293
8863
|
lodash2.reduce = reduce;
|
|
10294
8864
|
lodash2.reduceRight = reduceRight;
|
|
10295
8865
|
lodash2.repeat = repeat;
|
|
10296
|
-
lodash2.replace =
|
|
8866
|
+
lodash2.replace = replace;
|
|
10297
8867
|
lodash2.result = result;
|
|
10298
8868
|
lodash2.round = round;
|
|
10299
8869
|
lodash2.runInContext = runInContext2;
|
|
@@ -11685,9 +10255,9 @@ var hasRequired_overArg;
|
|
|
11685
10255
|
function require_overArg() {
|
|
11686
10256
|
if (hasRequired_overArg) return _overArg;
|
|
11687
10257
|
hasRequired_overArg = 1;
|
|
11688
|
-
function overArg(func,
|
|
10258
|
+
function overArg(func, transform2) {
|
|
11689
10259
|
return function(arg) {
|
|
11690
|
-
return func(
|
|
10260
|
+
return func(transform2(arg));
|
|
11691
10261
|
};
|
|
11692
10262
|
}
|
|
11693
10263
|
__name(overArg, "overArg");
|
|
@@ -13808,7 +12378,7 @@ function requireTransform() {
|
|
|
13808
12378
|
if (hasRequiredTransform) return transform_1;
|
|
13809
12379
|
hasRequiredTransform = 1;
|
|
13810
12380
|
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();
|
|
13811
|
-
function
|
|
12381
|
+
function transform2(object, iteratee, accumulator) {
|
|
13812
12382
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
13813
12383
|
iteratee = baseIteratee(iteratee, 4);
|
|
13814
12384
|
if (accumulator == null) {
|
|
@@ -13826,8 +12396,8 @@ function requireTransform() {
|
|
|
13826
12396
|
});
|
|
13827
12397
|
return accumulator;
|
|
13828
12398
|
}
|
|
13829
|
-
__name(
|
|
13830
|
-
transform_1 =
|
|
12399
|
+
__name(transform2, "transform");
|
|
12400
|
+
transform_1 = transform2;
|
|
13831
12401
|
return transform_1;
|
|
13832
12402
|
}
|
|
13833
12403
|
__name(requireTransform, "requireTransform");
|
|
@@ -13905,7 +12475,7 @@ function require_overRest() {
|
|
|
13905
12475
|
hasRequired_overRest = 1;
|
|
13906
12476
|
var apply = require_apply();
|
|
13907
12477
|
var nativeMax = Math.max;
|
|
13908
|
-
function overRest(func, start,
|
|
12478
|
+
function overRest(func, start, transform2) {
|
|
13909
12479
|
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
13910
12480
|
return function() {
|
|
13911
12481
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
|
|
@@ -13917,7 +12487,7 @@ function require_overRest() {
|
|
|
13917
12487
|
while (++index < start) {
|
|
13918
12488
|
otherArgs[index] = args[index];
|
|
13919
12489
|
}
|
|
13920
|
-
otherArgs[start] =
|
|
12490
|
+
otherArgs[start] = transform2(array);
|
|
13921
12491
|
return apply(func, this, otherArgs);
|
|
13922
12492
|
};
|
|
13923
12493
|
}
|
|
@@ -14067,12 +12637,12 @@ function require_arrayIncludes() {
|
|
|
14067
12637
|
if (hasRequired_arrayIncludes) return _arrayIncludes;
|
|
14068
12638
|
hasRequired_arrayIncludes = 1;
|
|
14069
12639
|
var baseIndexOf = require_baseIndexOf();
|
|
14070
|
-
function
|
|
12640
|
+
function arrayIncludes(array, value) {
|
|
14071
12641
|
var length = array == null ? 0 : array.length;
|
|
14072
12642
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
14073
12643
|
}
|
|
14074
|
-
__name(
|
|
14075
|
-
_arrayIncludes =
|
|
12644
|
+
__name(arrayIncludes, "arrayIncludes");
|
|
12645
|
+
_arrayIncludes = arrayIncludes;
|
|
14076
12646
|
return _arrayIncludes;
|
|
14077
12647
|
}
|
|
14078
12648
|
__name(require_arrayIncludes, "require_arrayIncludes");
|
|
@@ -14129,10 +12699,10 @@ var hasRequired_baseUniq;
|
|
|
14129
12699
|
function require_baseUniq() {
|
|
14130
12700
|
if (hasRequired_baseUniq) return _baseUniq;
|
|
14131
12701
|
hasRequired_baseUniq = 1;
|
|
14132
|
-
var SetCache = require_SetCache(),
|
|
12702
|
+
var SetCache = require_SetCache(), arrayIncludes = require_arrayIncludes(), arrayIncludesWith = require_arrayIncludesWith(), cacheHas = require_cacheHas(), createSet = require_createSet(), setToArray = require_setToArray();
|
|
14133
12703
|
var LARGE_ARRAY_SIZE = 200;
|
|
14134
12704
|
function baseUniq(array, iteratee, comparator) {
|
|
14135
|
-
var index = -1, includes =
|
|
12705
|
+
var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
|
|
14136
12706
|
if (comparator) {
|
|
14137
12707
|
isCommon = false;
|
|
14138
12708
|
includes = arrayIncludesWith;
|
|
@@ -14467,27 +13037,27 @@ Graph$2.prototype.isLeaf = function(v) {
|
|
|
14467
13037
|
return neighbors.length === 0;
|
|
14468
13038
|
};
|
|
14469
13039
|
Graph$2.prototype.filterNodes = function(filter) {
|
|
14470
|
-
var
|
|
13040
|
+
var copy = new this.constructor({
|
|
14471
13041
|
directed: this._isDirected,
|
|
14472
13042
|
multigraph: this._isMultigraph,
|
|
14473
13043
|
compound: this._isCompound
|
|
14474
13044
|
});
|
|
14475
|
-
|
|
13045
|
+
copy.setGraph(this.graph());
|
|
14476
13046
|
var self1 = this;
|
|
14477
13047
|
_$b.each(this._nodes, function(value, v) {
|
|
14478
13048
|
if (filter(v)) {
|
|
14479
|
-
|
|
13049
|
+
copy.setNode(v, value);
|
|
14480
13050
|
}
|
|
14481
13051
|
});
|
|
14482
13052
|
_$b.each(this._edgeObjs, function(e) {
|
|
14483
|
-
if (
|
|
14484
|
-
|
|
13053
|
+
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
|
|
13054
|
+
copy.setEdge(e, self1.edge(e));
|
|
14485
13055
|
}
|
|
14486
13056
|
});
|
|
14487
13057
|
var parents = {};
|
|
14488
13058
|
function findParent(v) {
|
|
14489
13059
|
var parent = self1.parent(v);
|
|
14490
|
-
if (parent === void 0 ||
|
|
13060
|
+
if (parent === void 0 || copy.hasNode(parent)) {
|
|
14491
13061
|
parents[v] = parent;
|
|
14492
13062
|
return parent;
|
|
14493
13063
|
} else if (parent in parents) {
|
|
@@ -14498,11 +13068,11 @@ Graph$2.prototype.filterNodes = function(filter) {
|
|
|
14498
13068
|
}
|
|
14499
13069
|
__name(findParent, "findParent");
|
|
14500
13070
|
if (this._isCompound) {
|
|
14501
|
-
_$b.each(
|
|
14502
|
-
|
|
13071
|
+
_$b.each(copy.nodes(), function(v) {
|
|
13072
|
+
copy.setParent(v, findParent(v));
|
|
14503
13073
|
});
|
|
14504
13074
|
}
|
|
14505
|
-
return
|
|
13075
|
+
return copy;
|
|
14506
13076
|
};
|
|
14507
13077
|
Graph$2.prototype.setDefaultEdgeLabel = function(newDefault) {
|
|
14508
13078
|
if (!_$b.isFunction(newDefault)) {
|
|
@@ -15621,8 +14191,8 @@ var RollingCache = class RollingCache2 {
|
|
|
15621
14191
|
/** @returns true if name exists in either old cache or new cache */
|
|
15622
14192
|
exists(name) {
|
|
15623
14193
|
if (this.rolled) return false;
|
|
15624
|
-
if (
|
|
15625
|
-
return
|
|
14194
|
+
if (existsSync5(`${this.newCacheRoot}/${name}`)) return true;
|
|
14195
|
+
return existsSync5(`${this.oldCacheRoot}/${name}`);
|
|
15626
14196
|
}
|
|
15627
14197
|
path(name) {
|
|
15628
14198
|
return `${this.oldCacheRoot}/${name}`;
|
|
@@ -15630,12 +14200,12 @@ var RollingCache = class RollingCache2 {
|
|
|
15630
14200
|
/** @returns true if old cache contains all names and nothing more */
|
|
15631
14201
|
match(names) {
|
|
15632
14202
|
if (this.rolled) return false;
|
|
15633
|
-
if (!
|
|
15634
|
-
return lodash$1.exports.isEqual(
|
|
14203
|
+
if (!existsSync5(this.oldCacheRoot)) return names.length === 0;
|
|
14204
|
+
return lodash$1.exports.isEqual(readdirSync(this.oldCacheRoot).sort(), names.sort());
|
|
15635
14205
|
}
|
|
15636
14206
|
/** @returns data for name, must exist in either old cache or new cache */
|
|
15637
14207
|
read(name) {
|
|
15638
|
-
if (
|
|
14208
|
+
if (existsSync5(`${this.newCacheRoot}/${name}`)) return readJsonSync(`${this.newCacheRoot}/${name}`, {
|
|
15639
14209
|
encoding: "utf8",
|
|
15640
14210
|
throws: false
|
|
15641
14211
|
});
|
|
@@ -15658,7 +14228,7 @@ var RollingCache = class RollingCache2 {
|
|
|
15658
14228
|
if (this.rolled) return;
|
|
15659
14229
|
this.rolled = true;
|
|
15660
14230
|
removeSync2(this.oldCacheRoot);
|
|
15661
|
-
if (
|
|
14231
|
+
if (existsSync5(this.newCacheRoot)) {
|
|
15662
14232
|
renameSync(this.newCacheRoot, this.oldCacheRoot);
|
|
15663
14233
|
}
|
|
15664
14234
|
}
|
|
@@ -15827,9 +14397,9 @@ var TsCache = class TsCache2 {
|
|
|
15827
14397
|
this.syntacticDiagnosticsCache.roll();
|
|
15828
14398
|
this.typesCache.roll();
|
|
15829
14399
|
}
|
|
15830
|
-
getCompiled(id, snapshot,
|
|
14400
|
+
getCompiled(id, snapshot, transform2) {
|
|
15831
14401
|
this.context.info(`${safe.exports.blue("transpiling")} '${id}'`);
|
|
15832
|
-
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration),
|
|
14402
|
+
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration), transform2);
|
|
15833
14403
|
}
|
|
15834
14404
|
getSyntacticDiagnostics(id, snapshot, check) {
|
|
15835
14405
|
return this.getDiagnostics("syntax", this.syntacticDiagnosticsCache, id, snapshot, check);
|
|
@@ -15933,7 +14503,7 @@ function expandIncludeWithDirs(include, dirs) {
|
|
|
15933
14503
|
return newDirs;
|
|
15934
14504
|
}
|
|
15935
14505
|
__name(expandIncludeWithDirs, "expandIncludeWithDirs");
|
|
15936
|
-
function
|
|
14506
|
+
function createFilter(context, pluginOptions, parsedConfig) {
|
|
15937
14507
|
let included = pluginOptions.include;
|
|
15938
14508
|
let excluded = pluginOptions.exclude;
|
|
15939
14509
|
if (parsedConfig.options.rootDirs) {
|
|
@@ -15952,7 +14522,7 @@ ${JSON.stringify(excluded, void 0, 4)}`);
|
|
|
15952
14522
|
resolve: parsedConfig.options.rootDir
|
|
15953
14523
|
});
|
|
15954
14524
|
}
|
|
15955
|
-
__name(
|
|
14525
|
+
__name(createFilter, "createFilter");
|
|
15956
14526
|
function parseTsConfig(context, pluginOptions) {
|
|
15957
14527
|
var _a, _b;
|
|
15958
14528
|
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
|
|
@@ -15972,7 +14542,7 @@ function parseTsConfig(context, pluginOptions) {
|
|
|
15972
14542
|
context.error(`failed to parse '${fileName}'`);
|
|
15973
14543
|
}
|
|
15974
14544
|
loadedConfig = result.config;
|
|
15975
|
-
baseDir =
|
|
14545
|
+
baseDir = dirname(fileName);
|
|
15976
14546
|
configFileName = fileName;
|
|
15977
14547
|
}
|
|
15978
14548
|
const mergedConfig = {};
|
|
@@ -16123,7 +14693,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
16123
14693
|
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.`);
|
|
16124
14694
|
if (pluginOptions.rollupCommonJSResolveHack) context.warn(() => `${safe.exports.yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
|
|
16125
14695
|
if (watchMode) context.info(`running in watch mode`);
|
|
16126
|
-
filter =
|
|
14696
|
+
filter = createFilter(context, pluginOptions, parsedConfig);
|
|
16127
14697
|
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
|
|
16128
14698
|
service = tsModule.createLanguageService(servicesHost, documentRegistry);
|
|
16129
14699
|
servicesHost.setLanguageService(service);
|
|
@@ -16154,7 +14724,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
16154
14724
|
cache.setDependency(resolved, importer);
|
|
16155
14725
|
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
|
|
16156
14726
|
context.debug(() => ` to '${resolved}'`);
|
|
16157
|
-
return
|
|
14727
|
+
return normalize2(resolved);
|
|
16158
14728
|
},
|
|
16159
14729
|
load(id) {
|
|
16160
14730
|
if (id === TSLIB_VIRTUAL) return tslibSource;
|
|
@@ -16263,15 +14833,15 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
16263
14833
|
let entryText = entry.text;
|
|
16264
14834
|
const cachePlaceholder = `${pluginOptions.cacheRoot}/placeholder`;
|
|
16265
14835
|
if (extension === ".d.ts.map" && ((_output === null || _output === void 0 ? void 0 : _output.file) || (_output === null || _output === void 0 ? void 0 : _output.dir))) {
|
|
16266
|
-
const declarationDir = _output.file ?
|
|
14836
|
+
const declarationDir = _output.file ? dirname(_output.file) : _output.dir;
|
|
16267
14837
|
const parsedText = JSON.parse(entryText);
|
|
16268
14838
|
parsedText.sources = parsedText.sources.map((source) => {
|
|
16269
|
-
const absolutePath =
|
|
16270
|
-
return normalizePath(
|
|
14839
|
+
const absolutePath = resolve(cachePlaceholder, source);
|
|
14840
|
+
return normalizePath(relative2(declarationDir, absolutePath));
|
|
16271
14841
|
});
|
|
16272
14842
|
entryText = JSON.stringify(parsedText);
|
|
16273
14843
|
}
|
|
16274
|
-
const relativePath = normalizePath(
|
|
14844
|
+
const relativePath = normalizePath(relative2(cachePlaceholder, fileName));
|
|
16275
14845
|
context.debug(() => `${safe.exports.blue("emitting declarations")} for '${key}' to '${relativePath}'`);
|
|
16276
14846
|
this.emitFile({
|
|
16277
14847
|
type: "asset",
|
|
@@ -16292,11 +14862,11 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
16292
14862
|
// src/utilities/helpers.ts
|
|
16293
14863
|
import { joinPathFragments as joinPathFragments2 } from "@nx/devkit";
|
|
16294
14864
|
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
16295
|
-
import { dirname as
|
|
14865
|
+
import { dirname as dirname2, extname } from "node:path";
|
|
16296
14866
|
import { pathToFileURL } from "node:url";
|
|
16297
14867
|
import ts from "typescript";
|
|
16298
14868
|
async function loadConfig2(configPath) {
|
|
16299
|
-
if (!/\.(js|mjs)$/.test(
|
|
14869
|
+
if (!/\.(js|mjs)$/.test(extname(configPath))) {
|
|
16300
14870
|
throw new Error("Unsupported config file format");
|
|
16301
14871
|
}
|
|
16302
14872
|
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
@@ -16304,7 +14874,7 @@ async function loadConfig2(configPath) {
|
|
|
16304
14874
|
__name(loadConfig2, "loadConfig");
|
|
16305
14875
|
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
16306
14876
|
const tsConfigFile = ts.readConfigFile(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
16307
|
-
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys,
|
|
14877
|
+
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname2(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
16308
14878
|
const compilerOptions = {
|
|
16309
14879
|
rootDir: projectRoot,
|
|
16310
14880
|
declaration: true,
|
|
@@ -16335,7 +14905,7 @@ var tscPlugin = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
|
|
|
16335
14905
|
}, "tscPlugin");
|
|
16336
14906
|
|
|
16337
14907
|
// src/plugins/type-definitions.ts
|
|
16338
|
-
import { relative as
|
|
14908
|
+
import { relative as relative3 } from "node:path";
|
|
16339
14909
|
function typeDefinitions(projectRoot) {
|
|
16340
14910
|
return {
|
|
16341
14911
|
name: "storm:dts-bundle",
|
|
@@ -16345,7 +14915,7 @@ function typeDefinitions(projectRoot) {
|
|
|
16345
14915
|
continue;
|
|
16346
14916
|
}
|
|
16347
14917
|
const hasDefaultExport = file.exports.includes("default");
|
|
16348
|
-
const entrySourceFileName =
|
|
14918
|
+
const entrySourceFileName = relative3(projectRoot, file.facadeModuleId);
|
|
16349
14919
|
const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
|
|
16350
14920
|
const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
|
|
16351
14921
|
const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
|
|
@@ -16390,19 +14960,19 @@ async function resolveOptions(options) {
|
|
|
16390
14960
|
if (options.configPath) {
|
|
16391
14961
|
const configFile = await loadConfig2(options.configPath);
|
|
16392
14962
|
if (configFile) {
|
|
16393
|
-
options =
|
|
14963
|
+
options = defu3(options, configFile);
|
|
16394
14964
|
}
|
|
16395
14965
|
}
|
|
16396
14966
|
const projectGraph = readCachedProjectGraph4();
|
|
16397
14967
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
16398
|
-
if (!
|
|
14968
|
+
if (!existsSync6(projectJsonPath)) {
|
|
16399
14969
|
throw new Error("Cannot find project.json configuration");
|
|
16400
14970
|
}
|
|
16401
14971
|
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
16402
14972
|
const projectJson = JSON.parse(projectJsonContent);
|
|
16403
14973
|
const projectName = projectJson.name;
|
|
16404
14974
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
16405
|
-
if (!
|
|
14975
|
+
if (!existsSync6(packageJsonPath)) {
|
|
16406
14976
|
throw new Error("Cannot find package.json configuration");
|
|
16407
14977
|
}
|
|
16408
14978
|
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
@@ -16411,14 +14981,14 @@ async function resolveOptions(options) {
|
|
|
16411
14981
|
if (!tsconfig) {
|
|
16412
14982
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
16413
14983
|
}
|
|
16414
|
-
if (!
|
|
14984
|
+
if (!existsSync6(tsconfig)) {
|
|
16415
14985
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
16416
14986
|
}
|
|
16417
14987
|
let sourceRoot = projectJson.sourceRoot;
|
|
16418
14988
|
if (!sourceRoot) {
|
|
16419
14989
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
16420
14990
|
}
|
|
16421
|
-
if (!
|
|
14991
|
+
if (!existsSync6(sourceRoot)) {
|
|
16422
14992
|
throw new Error("Cannot find sourceRoot directory");
|
|
16423
14993
|
}
|
|
16424
14994
|
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -16428,6 +14998,11 @@ async function resolveOptions(options) {
|
|
|
16428
14998
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
16429
14999
|
dependencies.push(tsLibDependency);
|
|
16430
15000
|
}
|
|
15001
|
+
const jiti = createJiti(config.workspaceRoot, {
|
|
15002
|
+
cache: true,
|
|
15003
|
+
fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
|
|
15004
|
+
interopDefault: true
|
|
15005
|
+
});
|
|
16431
15006
|
const resolvedOptions = {
|
|
16432
15007
|
name: projectName,
|
|
16433
15008
|
config,
|
|
@@ -16435,19 +15010,20 @@ async function resolveOptions(options) {
|
|
|
16435
15010
|
sourceRoot,
|
|
16436
15011
|
projectName,
|
|
16437
15012
|
tsconfig,
|
|
15013
|
+
jiti,
|
|
16438
15014
|
clean: false,
|
|
16439
15015
|
entries: [
|
|
16440
15016
|
{
|
|
16441
15017
|
builder: "mkdist",
|
|
16442
15018
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
16443
|
-
outDir: joinPaths(
|
|
15019
|
+
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
16444
15020
|
declaration: options.emitTypes !== false,
|
|
16445
15021
|
format: "esm"
|
|
16446
15022
|
},
|
|
16447
15023
|
{
|
|
16448
15024
|
builder: "mkdist",
|
|
16449
15025
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
16450
|
-
outDir: joinPaths(
|
|
15026
|
+
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
16451
15027
|
declaration: options.emitTypes !== false,
|
|
16452
15028
|
format: "cjs",
|
|
16453
15029
|
ext: "cjs"
|
|
@@ -16501,7 +15077,7 @@ async function resolveOptions(options) {
|
|
|
16501
15077
|
]
|
|
16502
15078
|
},
|
|
16503
15079
|
esbuild: {
|
|
16504
|
-
minify:
|
|
15080
|
+
minify: options.minify !== false,
|
|
16505
15081
|
splitting: options.splitting !== false,
|
|
16506
15082
|
treeShaking: options.treeShaking !== false,
|
|
16507
15083
|
color: true,
|
|
@@ -16520,16 +15096,16 @@ async function resolveOptions(options) {
|
|
|
16520
15096
|
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
16521
15097
|
}
|
|
16522
15098
|
if (options.rollup) {
|
|
16523
|
-
let
|
|
15099
|
+
let rollup = {};
|
|
16524
15100
|
if (typeof options.rollup === "string") {
|
|
16525
15101
|
const rollupFile = await loadConfig2(options.rollup);
|
|
16526
15102
|
if (rollupFile) {
|
|
16527
|
-
|
|
15103
|
+
rollup = rollupFile;
|
|
16528
15104
|
}
|
|
16529
15105
|
} else {
|
|
16530
|
-
|
|
15106
|
+
rollup = options.rollup;
|
|
16531
15107
|
}
|
|
16532
|
-
resolvedOptions.rollup =
|
|
15108
|
+
resolvedOptions.rollup = defu3(resolvedOptions.rollup ?? {}, rollup);
|
|
16533
15109
|
}
|
|
16534
15110
|
resolvedOptions.hooks = {
|
|
16535
15111
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
@@ -16541,11 +15117,11 @@ async function resolveOptions(options) {
|
|
|
16541
15117
|
}
|
|
16542
15118
|
__name(resolveOptions, "resolveOptions");
|
|
16543
15119
|
async function generatePackageJson(options) {
|
|
16544
|
-
if (options.generatePackageJson !== false &&
|
|
15120
|
+
if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
|
|
16545
15121
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
16546
15122
|
const stopwatch = getStopwatch("Write package.json file");
|
|
16547
15123
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
16548
|
-
if (!
|
|
15124
|
+
if (!existsSync6(packageJsonPath)) {
|
|
16549
15125
|
throw new Error("Cannot find package.json configuration");
|
|
16550
15126
|
}
|
|
16551
15127
|
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
@@ -16561,11 +15137,24 @@ async function generatePackageJson(options) {
|
|
|
16561
15137
|
return options;
|
|
16562
15138
|
}
|
|
16563
15139
|
__name(generatePackageJson, "generatePackageJson");
|
|
15140
|
+
async function resolveUnbuild(options) {
|
|
15141
|
+
writeTrace(`Resolving Unbuild package with Jiti`, options.config);
|
|
15142
|
+
try {
|
|
15143
|
+
return options.jiti.import("unbuild");
|
|
15144
|
+
} catch (error) {
|
|
15145
|
+
writeError(" \u274C An error occurred while resolving the Unbuild package", options.config);
|
|
15146
|
+
throw new Error("An error occurred while resolving the Unbuild package", {
|
|
15147
|
+
cause: error
|
|
15148
|
+
});
|
|
15149
|
+
}
|
|
15150
|
+
}
|
|
15151
|
+
__name(resolveUnbuild, "resolveUnbuild");
|
|
16564
15152
|
async function executeUnbuild(options) {
|
|
16565
15153
|
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
16566
15154
|
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
16567
15155
|
try {
|
|
16568
|
-
await
|
|
15156
|
+
const unbuild = await resolveUnbuild(options);
|
|
15157
|
+
await unbuild.build(options.projectRoot, false, {
|
|
16569
15158
|
...options,
|
|
16570
15159
|
rootDir: options.projectRoot
|
|
16571
15160
|
});
|
|
@@ -16590,7 +15179,7 @@ async function cleanOutputPath(options) {
|
|
|
16590
15179
|
return options;
|
|
16591
15180
|
}
|
|
16592
15181
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
16593
|
-
async function
|
|
15182
|
+
async function build(options) {
|
|
16594
15183
|
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
|
|
16595
15184
|
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
16596
15185
|
try {
|
|
@@ -16607,7 +15196,7 @@ async function build2(options) {
|
|
|
16607
15196
|
stopwatch();
|
|
16608
15197
|
}
|
|
16609
15198
|
}
|
|
16610
|
-
__name(
|
|
15199
|
+
__name(build, "build");
|
|
16611
15200
|
|
|
16612
15201
|
// bin/unbuild.ts
|
|
16613
15202
|
async function createProgram(config) {
|
|
@@ -16685,7 +15274,7 @@ async function createProgram(config) {
|
|
|
16685
15274
|
__name(createProgram, "createProgram");
|
|
16686
15275
|
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
16687
15276
|
try {
|
|
16688
|
-
await
|
|
15277
|
+
await build({
|
|
16689
15278
|
...options,
|
|
16690
15279
|
sourcemap: !!options.debug,
|
|
16691
15280
|
replace: {},
|