@storm-software/unbuild 0.20.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/unbuild.js +1614 -191
- package/bin/unbuild.mjs +1620 -201
- package/dist/build.js +10 -10
- package/dist/build.mjs +1 -1
- package/dist/chunk-2Q67L63A.js +2456 -0
- package/dist/chunk-4WKFVYTI.js +18 -0
- package/dist/{chunk-XEAFTDQ7.js → chunk-6KE6SIPQ.js} +5 -5
- package/dist/{chunk-DFIGNXGY.js → chunk-B2WY6JG2.js} +1035 -1035
- package/dist/{chunk-WPOEGALQ.js → chunk-BMAXMHJB.js} +5 -5
- package/dist/{chunk-3OJD7CO4.js → chunk-E73BVQF5.js} +5 -5
- package/dist/chunk-J5YBLOB7.js +27 -0
- package/dist/{chunk-RCEWRXM5.js → chunk-RUNO4F6F.js} +2 -2
- package/dist/chunk-SGIQJ2OU.mjs +2455 -0
- package/dist/{chunk-OQPSH7GE.js → chunk-UUI4UWA4.js} +37 -37
- package/dist/clean.d.mts +12 -2
- package/dist/clean.d.ts +12 -2
- package/dist/clean.js +4 -4
- package/dist/config.js +8 -8
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +10 -10
- package/dist/index.mjs +1 -1
- package/dist/types.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-2345XTVS.js +0 -1036
- package/dist/chunk-3GQAWCBQ.js +0 -13
- package/dist/chunk-AYRYNROK.js +0 -27
- package/dist/chunk-WGFWMGCJ.mjs +0 -1036
- package/dist/clean-DDbna8D4.d.mts +0 -1194
- package/dist/clean-DDbna8D4.d.ts +0 -1194
package/bin/unbuild.mjs
CHANGED
|
@@ -495,7 +495,7 @@ var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
|
|
|
495
495
|
// ../config-tools/src/logger/console.ts
|
|
496
496
|
var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) => {
|
|
497
497
|
const _chalk = getChalk();
|
|
498
|
-
const
|
|
498
|
+
const colors3 = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
|
|
499
499
|
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
500
500
|
if (typeof logLevel === "number" && (logLevel >= getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(configLogLevel)) {
|
|
501
501
|
return (_2) => {
|
|
@@ -504,48 +504,48 @@ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}) =>
|
|
|
504
504
|
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
|
|
505
505
|
return (message) => {
|
|
506
506
|
console.error(`
|
|
507
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
507
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
508
508
|
`);
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
|
|
512
512
|
return (message) => {
|
|
513
513
|
console.error(`
|
|
514
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
514
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
515
515
|
`);
|
|
516
516
|
};
|
|
517
517
|
}
|
|
518
518
|
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
|
|
519
519
|
return (message) => {
|
|
520
520
|
console.warn(`
|
|
521
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
521
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
522
522
|
`);
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
525
|
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel || typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel)) {
|
|
526
526
|
return (message) => {
|
|
527
527
|
console.info(`
|
|
528
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
528
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
529
529
|
`);
|
|
530
530
|
};
|
|
531
531
|
}
|
|
532
532
|
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
|
|
533
533
|
return (message) => {
|
|
534
534
|
console.info(`
|
|
535
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
535
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
536
536
|
`);
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
539
|
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel || typeof logLevel === "string" && LogLevel.TRACE >= getLogLevel(logLevel)) {
|
|
540
540
|
return (message) => {
|
|
541
541
|
console.debug(`
|
|
542
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
542
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
543
543
|
`);
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
return (message) => {
|
|
547
547
|
console.log(`
|
|
548
|
-
${_chalk.gray(formatTimestamp())} ${_chalk.hex(
|
|
548
|
+
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors3.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
549
549
|
`);
|
|
550
550
|
};
|
|
551
551
|
}, "getLogFn");
|
|
@@ -1102,7 +1102,7 @@ ${formatLogMessage(config)}`, config);
|
|
|
1102
1102
|
import { Command, Option } from "commander";
|
|
1103
1103
|
|
|
1104
1104
|
// src/build.ts
|
|
1105
|
-
import { readCachedProjectGraph as
|
|
1105
|
+
import { readCachedProjectGraph as readCachedProjectGraph4, writeJsonFile } from "@nx/devkit";
|
|
1106
1106
|
import { getHelperDependency as getHelperDependency2, HelperDependency as HelperDependency2 } from "@nx/js";
|
|
1107
1107
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies3 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1108
1108
|
|
|
@@ -1120,13 +1120,14 @@ import { stripIndents } from "@nx/devkit";
|
|
|
1120
1120
|
import { relative } from "path";
|
|
1121
1121
|
|
|
1122
1122
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1123
|
-
import {
|
|
1124
|
-
import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
1123
|
+
import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
1125
1124
|
import { copyAssets as copyAssetsBase } from "@nx/js";
|
|
1126
1125
|
import { glob } from "glob";
|
|
1126
|
+
import { readFile as readFile2, writeFile } from "node:fs/promises";
|
|
1127
1127
|
|
|
1128
1128
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
1129
|
-
import {
|
|
1129
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
1130
|
+
import { readFile } from "node:fs/promises";
|
|
1130
1131
|
var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
1131
1132
|
let rootDir = workspaceRoot;
|
|
1132
1133
|
if (!rootDir) {
|
|
@@ -1134,10 +1135,11 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
1134
1135
|
rootDir = config.workspaceRoot;
|
|
1135
1136
|
}
|
|
1136
1137
|
const nxJsonPath = joinPaths(rootDir, "nx.json");
|
|
1137
|
-
if (!
|
|
1138
|
+
if (!existsSync3(nxJsonPath)) {
|
|
1138
1139
|
throw new Error("Cannot find project.json configuration");
|
|
1139
1140
|
}
|
|
1140
|
-
|
|
1141
|
+
const configContent = await readFile(nxJsonPath, "utf8");
|
|
1142
|
+
return JSON.parse(configContent);
|
|
1141
1143
|
}, "readNxConfig");
|
|
1142
1144
|
|
|
1143
1145
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
@@ -1172,14 +1174,12 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1172
1174
|
});
|
|
1173
1175
|
}
|
|
1174
1176
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
1175
|
-
const projectGraph =
|
|
1176
|
-
exitOnError: true
|
|
1177
|
-
});
|
|
1177
|
+
const projectGraph = readCachedProjectGraph();
|
|
1178
1178
|
const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
1179
1179
|
if (!projectsConfigurations?.projects?.[projectName]) {
|
|
1180
1180
|
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1181
1181
|
}
|
|
1182
|
-
const buildTarget = projectsConfigurations.projects[projectName]
|
|
1182
|
+
const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
|
|
1183
1183
|
if (!buildTarget) {
|
|
1184
1184
|
throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
|
|
1185
1185
|
}
|
|
@@ -1209,42 +1209,30 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1209
1209
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
1210
1210
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
1211
1211
|
]);
|
|
1212
|
-
await Promise.allSettled(files.map(async (file) =>
|
|
1212
|
+
await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
1213
1213
|
|
|
1214
|
-
${await
|
|
1214
|
+
${await readFile2(file, "utf8")}
|
|
1215
1215
|
|
|
1216
1216
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
1217
1217
|
}
|
|
1218
1218
|
}, "copyAssets");
|
|
1219
1219
|
|
|
1220
1220
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
1221
|
-
import { hfs as hfs3 } from "@humanfs/node";
|
|
1222
1221
|
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1223
1222
|
import { Glob } from "glob";
|
|
1224
|
-
import {
|
|
1223
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
1224
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
1225
|
+
import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
|
|
1225
1226
|
var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
1226
|
-
const
|
|
1227
|
-
exitOnError: true
|
|
1228
|
-
});
|
|
1229
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
1230
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1231
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1232
|
-
}
|
|
1233
|
-
const projectJsonPath = joinPaths(workspaceRoot, projectRoot, "project.json");
|
|
1234
|
-
if (!await hfs3.isFile(projectJsonPath)) {
|
|
1235
|
-
throw new Error("Cannot find project.json configuration");
|
|
1236
|
-
}
|
|
1237
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1238
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1239
|
-
}
|
|
1240
|
-
const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1227
|
+
const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1241
1228
|
const localPackages = [];
|
|
1242
1229
|
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
1243
1230
|
const projectNode = project.node;
|
|
1244
1231
|
if (projectNode.data.root) {
|
|
1245
1232
|
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
1246
|
-
if (
|
|
1247
|
-
const
|
|
1233
|
+
if (existsSync4(projectPackageJsonPath)) {
|
|
1234
|
+
const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
|
|
1235
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
1248
1236
|
if (projectPackageJson.private !== false) {
|
|
1249
1237
|
localPackages.push(projectPackageJson);
|
|
1250
1238
|
}
|
|
@@ -1280,7 +1268,8 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1280
1268
|
}, "addPackageDependencies");
|
|
1281
1269
|
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
1282
1270
|
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
1283
|
-
const
|
|
1271
|
+
const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
1272
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
1284
1273
|
packageJson.type ??= "module";
|
|
1285
1274
|
packageJson.sideEffects ??= false;
|
|
1286
1275
|
if (includeSrc === true) {
|
|
@@ -1378,12 +1367,1442 @@ import { glob as glob2 } from "glob";
|
|
|
1378
1367
|
import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
|
|
1379
1368
|
|
|
1380
1369
|
// src/build.ts
|
|
1381
|
-
import
|
|
1382
|
-
import { existsSync as
|
|
1383
|
-
import { readFile } from "node:fs/promises";
|
|
1384
|
-
import { relative as
|
|
1370
|
+
import defu4 from "defu";
|
|
1371
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
1372
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1373
|
+
import { relative as relative5 } from "node:path";
|
|
1385
1374
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
1386
|
-
|
|
1375
|
+
|
|
1376
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
1377
|
+
import Module from "node:module";
|
|
1378
|
+
import { existsSync as existsSync5, readdirSync, statSync, promises } from "node:fs";
|
|
1379
|
+
import { join as join3, resolve, normalize, dirname, relative as relative2, extname, isAbsolute } from "pathe";
|
|
1380
|
+
import { colors } from "consola/utils";
|
|
1381
|
+
import consola$1, { consola } from "consola";
|
|
1382
|
+
import { defu as defu3 } from "defu";
|
|
1383
|
+
import { createHooks } from "hookable";
|
|
1384
|
+
import prettyBytes from "pretty-bytes";
|
|
1385
|
+
import { glob as glob3 } from "tinyglobby";
|
|
1386
|
+
import fsp, { mkdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
1387
|
+
import { createJiti } from "jiti";
|
|
1388
|
+
import { watch, rollup } from "rollup";
|
|
1389
|
+
import dts from "rollup-plugin-dts";
|
|
1390
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
1391
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
1392
|
+
import alias from "@rollup/plugin-alias";
|
|
1393
|
+
import replace from "@rollup/plugin-replace";
|
|
1394
|
+
import { resolveAlias } from "pathe/utils";
|
|
1395
|
+
import { findStaticImports, parseNodeModulePath, fileURLToPath, resolvePath, resolveModuleExportNames } from "mlly";
|
|
1396
|
+
import { transform as transform2 } from "esbuild";
|
|
1397
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
1398
|
+
import rollupJSONPlugin from "@rollup/plugin-json";
|
|
1399
|
+
import MagicString from "magic-string";
|
|
1400
|
+
import { resolveSchema, generateMarkdown, generateTypes } from "untyped";
|
|
1401
|
+
import untypedPlugin from "untyped/babel-plugin";
|
|
1402
|
+
import { pascalCase } from "scule";
|
|
1403
|
+
import { mkdist } from "mkdist";
|
|
1404
|
+
function definePreset(preset) {
|
|
1405
|
+
return preset;
|
|
1406
|
+
}
|
|
1407
|
+
__name(definePreset, "definePreset");
|
|
1408
|
+
var autoPreset = definePreset(() => {
|
|
1409
|
+
return {
|
|
1410
|
+
hooks: {
|
|
1411
|
+
"build:prepare"(ctx) {
|
|
1412
|
+
if (!ctx.pkg || ctx.options.entries.length > 0) {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
const sourceFiles = listRecursively(join3(ctx.options.rootDir, "src"));
|
|
1416
|
+
const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir);
|
|
1417
|
+
for (const message of res.warnings) {
|
|
1418
|
+
warn(ctx, message);
|
|
1419
|
+
}
|
|
1420
|
+
ctx.options.entries.push(...res.entries);
|
|
1421
|
+
if (res.cjs) {
|
|
1422
|
+
ctx.options.rollup.emitCJS = true;
|
|
1423
|
+
}
|
|
1424
|
+
if (ctx.options.declaration === void 0) {
|
|
1425
|
+
ctx.options.declaration = res.dts ? "compatible" : false;
|
|
1426
|
+
}
|
|
1427
|
+
consola.info(
|
|
1428
|
+
"Automatically detected entries:",
|
|
1429
|
+
colors.cyan(
|
|
1430
|
+
ctx.options.entries.map(
|
|
1431
|
+
(e) => colors.bold(
|
|
1432
|
+
e.input.replace(ctx.options.rootDir + "/", "").replace(/\/$/, "/*")
|
|
1433
|
+
)
|
|
1434
|
+
).join(", ")
|
|
1435
|
+
),
|
|
1436
|
+
colors.gray(
|
|
1437
|
+
["esm", res.cjs && "cjs", res.dts && "dts"].filter(Boolean).map((tag) => `[${tag}]`).join(" ")
|
|
1438
|
+
)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
});
|
|
1444
|
+
function inferEntries(pkg, sourceFiles, rootDir) {
|
|
1445
|
+
const warnings = [];
|
|
1446
|
+
sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length);
|
|
1447
|
+
const outputs = extractExportFilenames(pkg.exports);
|
|
1448
|
+
if (pkg.bin) {
|
|
1449
|
+
const binaries = typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin);
|
|
1450
|
+
for (const file of binaries) {
|
|
1451
|
+
outputs.push({ file });
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
if (pkg.main) {
|
|
1455
|
+
outputs.push({ file: pkg.main });
|
|
1456
|
+
}
|
|
1457
|
+
if (pkg.module) {
|
|
1458
|
+
outputs.push({ type: "esm", file: pkg.module });
|
|
1459
|
+
}
|
|
1460
|
+
if (pkg.types || pkg.typings) {
|
|
1461
|
+
outputs.push({ file: pkg.types || pkg.typings });
|
|
1462
|
+
}
|
|
1463
|
+
const isESMPkg = pkg.type === "module";
|
|
1464
|
+
for (const output of outputs.filter((o) => !o.type)) {
|
|
1465
|
+
const isJS = output.file.endsWith(".js");
|
|
1466
|
+
if (isESMPkg && isJS || output.file.endsWith(".mjs")) {
|
|
1467
|
+
output.type = "esm";
|
|
1468
|
+
} else if (!isESMPkg && isJS || output.file.endsWith(".cjs")) {
|
|
1469
|
+
output.type = "cjs";
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
let cjs = false;
|
|
1473
|
+
let dts2 = false;
|
|
1474
|
+
const entries = [];
|
|
1475
|
+
for (const output of outputs) {
|
|
1476
|
+
const outputSlug = output.file.replace(
|
|
1477
|
+
/(\*[^/\\]*|\.d\.(m|c)?ts|\.\w+)$/,
|
|
1478
|
+
""
|
|
1479
|
+
);
|
|
1480
|
+
const isDir = outputSlug.endsWith("/");
|
|
1481
|
+
if (isDir && ["./", "/"].includes(outputSlug)) {
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
const possiblePaths = getEntrypointPaths(outputSlug);
|
|
1485
|
+
const input = possiblePaths.reduce((source, d) => {
|
|
1486
|
+
if (source) {
|
|
1487
|
+
return source;
|
|
1488
|
+
}
|
|
1489
|
+
const SOURCE_RE = new RegExp(
|
|
1490
|
+
`(?<=/|$)${d}${isDir ? "" : String.raw`\.\w+`}$`
|
|
1491
|
+
);
|
|
1492
|
+
return sourceFiles.find((i) => SOURCE_RE.test(i))?.replace(/(\.d\.(m|c)?ts|\.\w+)$/, "");
|
|
1493
|
+
}, void 0);
|
|
1494
|
+
if (!input) {
|
|
1495
|
+
if (!existsSync5(resolve(rootDir || ".", output.file))) {
|
|
1496
|
+
warnings.push(`Could not find entrypoint for \`${output.file}\``);
|
|
1497
|
+
}
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
if (output.type === "cjs") {
|
|
1501
|
+
cjs = true;
|
|
1502
|
+
}
|
|
1503
|
+
const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1];
|
|
1504
|
+
if (/\.d\.(m|c)?ts$/.test(output.file)) {
|
|
1505
|
+
dts2 = true;
|
|
1506
|
+
}
|
|
1507
|
+
if (isDir) {
|
|
1508
|
+
entry.outDir = outputSlug;
|
|
1509
|
+
entry.format = output.type;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
return { entries, cjs, dts: dts2, warnings };
|
|
1513
|
+
}
|
|
1514
|
+
__name(inferEntries, "inferEntries");
|
|
1515
|
+
var getEntrypointPaths = /* @__PURE__ */ __name((path3) => {
|
|
1516
|
+
const segments = normalize(path3).split("/");
|
|
1517
|
+
return segments.map((_2, index) => segments.slice(index).join("/")).filter(Boolean);
|
|
1518
|
+
}, "getEntrypointPaths");
|
|
1519
|
+
async function ensuredir(path3) {
|
|
1520
|
+
await fsp.mkdir(dirname(path3), { recursive: true });
|
|
1521
|
+
}
|
|
1522
|
+
__name(ensuredir, "ensuredir");
|
|
1523
|
+
function warn(ctx, message) {
|
|
1524
|
+
if (ctx.warnings.has(message)) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
consola.debug("[unbuild] [warn]", message);
|
|
1528
|
+
ctx.warnings.add(message);
|
|
1529
|
+
}
|
|
1530
|
+
__name(warn, "warn");
|
|
1531
|
+
async function symlink(from, to, force = true) {
|
|
1532
|
+
await ensuredir(to);
|
|
1533
|
+
if (force) {
|
|
1534
|
+
await fsp.unlink(to).catch(() => {
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
await fsp.symlink(from, to, "junction");
|
|
1538
|
+
}
|
|
1539
|
+
__name(symlink, "symlink");
|
|
1540
|
+
function dumpObject(obj) {
|
|
1541
|
+
return "{ " + Object.keys(obj).map((key) => `${key}: ${JSON.stringify(obj[key])}`).join(", ") + " }";
|
|
1542
|
+
}
|
|
1543
|
+
__name(dumpObject, "dumpObject");
|
|
1544
|
+
function getpkg(id = "") {
|
|
1545
|
+
const s = id.split("/");
|
|
1546
|
+
return s[0][0] === "@" ? `${s[0]}/${s[1]}` : s[0];
|
|
1547
|
+
}
|
|
1548
|
+
__name(getpkg, "getpkg");
|
|
1549
|
+
async function rmdir(dir) {
|
|
1550
|
+
await fsp.unlink(dir).catch(() => {
|
|
1551
|
+
});
|
|
1552
|
+
await fsp.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
__name(rmdir, "rmdir");
|
|
1556
|
+
function listRecursively(path3) {
|
|
1557
|
+
const filenames = /* @__PURE__ */ new Set();
|
|
1558
|
+
const walk = /* @__PURE__ */ __name((path22) => {
|
|
1559
|
+
const files = readdirSync(path22);
|
|
1560
|
+
for (const file of files) {
|
|
1561
|
+
const fullPath = resolve(path22, file);
|
|
1562
|
+
if (statSync(fullPath).isDirectory()) {
|
|
1563
|
+
filenames.add(fullPath + "/");
|
|
1564
|
+
walk(fullPath);
|
|
1565
|
+
} else {
|
|
1566
|
+
filenames.add(fullPath);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}, "walk");
|
|
1570
|
+
walk(path3);
|
|
1571
|
+
return [...filenames];
|
|
1572
|
+
}
|
|
1573
|
+
__name(listRecursively, "listRecursively");
|
|
1574
|
+
async function resolvePreset(preset, rootDir) {
|
|
1575
|
+
if (preset === "auto") {
|
|
1576
|
+
preset = autoPreset;
|
|
1577
|
+
} else if (typeof preset === "string") {
|
|
1578
|
+
preset = await createJiti(rootDir, { interopDefault: true }).import(preset, {
|
|
1579
|
+
default: true
|
|
1580
|
+
}) || {};
|
|
1581
|
+
}
|
|
1582
|
+
if (typeof preset === "function") {
|
|
1583
|
+
preset = preset();
|
|
1584
|
+
}
|
|
1585
|
+
return preset;
|
|
1586
|
+
}
|
|
1587
|
+
__name(resolvePreset, "resolvePreset");
|
|
1588
|
+
function inferExportType(condition, previousConditions = [], filename = "") {
|
|
1589
|
+
if (filename) {
|
|
1590
|
+
if (filename.endsWith(".d.ts")) {
|
|
1591
|
+
return "esm";
|
|
1592
|
+
}
|
|
1593
|
+
if (filename.endsWith(".mjs")) {
|
|
1594
|
+
return "esm";
|
|
1595
|
+
}
|
|
1596
|
+
if (filename.endsWith(".cjs")) {
|
|
1597
|
+
return "cjs";
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
switch (condition) {
|
|
1601
|
+
case "import": {
|
|
1602
|
+
return "esm";
|
|
1603
|
+
}
|
|
1604
|
+
case "require": {
|
|
1605
|
+
return "cjs";
|
|
1606
|
+
}
|
|
1607
|
+
default: {
|
|
1608
|
+
if (previousConditions.length === 0) {
|
|
1609
|
+
return "esm";
|
|
1610
|
+
}
|
|
1611
|
+
const [newCondition, ...rest] = previousConditions;
|
|
1612
|
+
return inferExportType(newCondition, rest, filename);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
__name(inferExportType, "inferExportType");
|
|
1617
|
+
function extractExportFilenames(exports, conditions = []) {
|
|
1618
|
+
if (!exports) {
|
|
1619
|
+
return [];
|
|
1620
|
+
}
|
|
1621
|
+
if (typeof exports === "string") {
|
|
1622
|
+
return [{ file: exports, type: "esm" }];
|
|
1623
|
+
}
|
|
1624
|
+
return Object.entries(exports).filter(([subpath]) => !subpath.endsWith(".json")).flatMap(
|
|
1625
|
+
([condition, exports2]) => typeof exports2 === "string" ? {
|
|
1626
|
+
file: exports2,
|
|
1627
|
+
type: inferExportType(condition, conditions, exports2)
|
|
1628
|
+
} : extractExportFilenames(exports2, [...conditions, condition])
|
|
1629
|
+
);
|
|
1630
|
+
}
|
|
1631
|
+
__name(extractExportFilenames, "extractExportFilenames");
|
|
1632
|
+
function arrayIncludes(arr, searchElement) {
|
|
1633
|
+
return arr.some(
|
|
1634
|
+
(entry) => entry instanceof RegExp ? entry.test(searchElement) : entry === searchElement
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
__name(arrayIncludes, "arrayIncludes");
|
|
1638
|
+
function removeExtension(filename) {
|
|
1639
|
+
return filename.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/, "");
|
|
1640
|
+
}
|
|
1641
|
+
__name(removeExtension, "removeExtension");
|
|
1642
|
+
function inferPkgExternals(pkg) {
|
|
1643
|
+
const externals = [
|
|
1644
|
+
...Object.keys(pkg.dependencies || {}),
|
|
1645
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
1646
|
+
...Object.keys(pkg.devDependencies || {}).filter(
|
|
1647
|
+
(dep) => dep.startsWith("@types/")
|
|
1648
|
+
),
|
|
1649
|
+
...Object.keys(pkg.optionalDependencies || {})
|
|
1650
|
+
];
|
|
1651
|
+
if (pkg.name) {
|
|
1652
|
+
externals.push(pkg.name);
|
|
1653
|
+
if (pkg.exports) {
|
|
1654
|
+
for (const subpath of Object.keys(pkg.exports)) {
|
|
1655
|
+
if (subpath.startsWith("./")) {
|
|
1656
|
+
externals.push(pathToRegex(`${pkg.name}/${subpath.slice(2)}`));
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
if (pkg.imports) {
|
|
1662
|
+
for (const importName of Object.keys(pkg.imports)) {
|
|
1663
|
+
if (importName.startsWith("#")) {
|
|
1664
|
+
externals.push(pathToRegex(importName));
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
return [...new Set(externals)];
|
|
1669
|
+
}
|
|
1670
|
+
__name(inferPkgExternals, "inferPkgExternals");
|
|
1671
|
+
function pathToRegex(path3) {
|
|
1672
|
+
return path3.includes("*") ? new RegExp(
|
|
1673
|
+
`^${path3.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`
|
|
1674
|
+
) : path3;
|
|
1675
|
+
}
|
|
1676
|
+
__name(pathToRegex, "pathToRegex");
|
|
1677
|
+
function withTrailingSlash(path3) {
|
|
1678
|
+
return path3.endsWith("/") ? path3 : `${path3}/`;
|
|
1679
|
+
}
|
|
1680
|
+
__name(withTrailingSlash, "withTrailingSlash");
|
|
1681
|
+
function validateDependencies(ctx) {
|
|
1682
|
+
const usedDependencies = /* @__PURE__ */ new Set();
|
|
1683
|
+
const unusedDependencies = new Set(
|
|
1684
|
+
Object.keys(ctx.pkg.dependencies || {})
|
|
1685
|
+
);
|
|
1686
|
+
const implicitDependencies = /* @__PURE__ */ new Set();
|
|
1687
|
+
for (const id of ctx.usedImports) {
|
|
1688
|
+
unusedDependencies.delete(id);
|
|
1689
|
+
usedDependencies.add(id);
|
|
1690
|
+
}
|
|
1691
|
+
if (Array.isArray(ctx.options.dependencies)) {
|
|
1692
|
+
for (const id of ctx.options.dependencies) {
|
|
1693
|
+
unusedDependencies.delete(id);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
for (const id of usedDependencies) {
|
|
1697
|
+
if (!arrayIncludes(ctx.options.externals, id) && !id.startsWith("chunks/") && !ctx.options.dependencies.includes(getpkg(id)) && !ctx.options.peerDependencies.includes(getpkg(id))) {
|
|
1698
|
+
implicitDependencies.add(id);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (unusedDependencies.size > 0) {
|
|
1702
|
+
warn(
|
|
1703
|
+
ctx,
|
|
1704
|
+
"Potential unused dependencies found: " + [...unusedDependencies].map((id) => colors.cyan(id)).join(", ")
|
|
1705
|
+
);
|
|
1706
|
+
}
|
|
1707
|
+
if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) {
|
|
1708
|
+
warn(
|
|
1709
|
+
ctx,
|
|
1710
|
+
"Potential implicit dependencies found: " + [...implicitDependencies].map((id) => colors.cyan(id)).join(", ")
|
|
1711
|
+
);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
__name(validateDependencies, "validateDependencies");
|
|
1715
|
+
function validatePackage(pkg, rootDir, ctx) {
|
|
1716
|
+
if (!pkg) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const filenames = new Set(
|
|
1720
|
+
[
|
|
1721
|
+
...typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {}),
|
|
1722
|
+
pkg.main,
|
|
1723
|
+
pkg.module,
|
|
1724
|
+
pkg.types,
|
|
1725
|
+
pkg.typings,
|
|
1726
|
+
...extractExportFilenames(pkg.exports).map((i) => i.file)
|
|
1727
|
+
].map((i) => i && resolve(rootDir, i.replace(/\/[^/]*\*.*$/, "")))
|
|
1728
|
+
);
|
|
1729
|
+
const missingOutputs = [];
|
|
1730
|
+
for (const filename of filenames) {
|
|
1731
|
+
if (filename && !filename.includes("*") && !existsSync5(filename)) {
|
|
1732
|
+
missingOutputs.push(filename.replace(rootDir + "/", ""));
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
if (missingOutputs.length > 0) {
|
|
1736
|
+
warn(
|
|
1737
|
+
ctx,
|
|
1738
|
+
`Potential missing package.json files: ${missingOutputs.map((o) => colors.cyan(o)).join(", ")}`
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
__name(validatePackage, "validatePackage");
|
|
1743
|
+
var SHEBANG_RE = /^#![^\n]*/;
|
|
1744
|
+
function shebangPlugin() {
|
|
1745
|
+
return {
|
|
1746
|
+
name: "unbuild-shebang",
|
|
1747
|
+
async writeBundle(options, bundle) {
|
|
1748
|
+
for (const [fileName, output] of Object.entries(bundle)) {
|
|
1749
|
+
if (output.type !== "chunk") {
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
if (output.code?.match(SHEBANG_RE)) {
|
|
1753
|
+
const outFile = resolve(options.dir, fileName);
|
|
1754
|
+
await makeExecutable(outFile);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
__name(shebangPlugin, "shebangPlugin");
|
|
1761
|
+
function removeShebangPlugin() {
|
|
1762
|
+
return {
|
|
1763
|
+
name: "unbuild-remove-shebang",
|
|
1764
|
+
renderChunk(code) {
|
|
1765
|
+
return code.replace(SHEBANG_RE, "");
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
__name(removeShebangPlugin, "removeShebangPlugin");
|
|
1770
|
+
async function makeExecutable(filePath) {
|
|
1771
|
+
await promises.chmod(
|
|
1772
|
+
filePath,
|
|
1773
|
+
493
|
|
1774
|
+
/* rwx r-x r-x */
|
|
1775
|
+
).catch(() => {
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
__name(makeExecutable, "makeExecutable");
|
|
1779
|
+
function getShebang(code, append = "\n") {
|
|
1780
|
+
const m = code.match(SHEBANG_RE);
|
|
1781
|
+
return m ? m + append : "";
|
|
1782
|
+
}
|
|
1783
|
+
__name(getShebang, "getShebang");
|
|
1784
|
+
var DefaultLoaders = {
|
|
1785
|
+
".js": "js",
|
|
1786
|
+
".mjs": "js",
|
|
1787
|
+
".cjs": "js",
|
|
1788
|
+
".ts": "ts",
|
|
1789
|
+
".mts": "ts",
|
|
1790
|
+
".cts": "ts",
|
|
1791
|
+
".tsx": "tsx",
|
|
1792
|
+
".jsx": "jsx"
|
|
1793
|
+
};
|
|
1794
|
+
function esbuild(options) {
|
|
1795
|
+
const {
|
|
1796
|
+
include = new RegExp(Object.keys(DefaultLoaders).join("|")),
|
|
1797
|
+
exclude = /node_modules/,
|
|
1798
|
+
loaders: loaderOptions,
|
|
1799
|
+
...esbuildOptions
|
|
1800
|
+
} = options;
|
|
1801
|
+
const loaders = { ...DefaultLoaders };
|
|
1802
|
+
if (loaderOptions) {
|
|
1803
|
+
for (const [key, value] of Object.entries(loaderOptions)) {
|
|
1804
|
+
if (typeof value === "string") {
|
|
1805
|
+
loaders[key] = value;
|
|
1806
|
+
} else if (value === false) {
|
|
1807
|
+
delete loaders[key];
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const getLoader = /* @__PURE__ */ __name((id = "") => {
|
|
1812
|
+
return loaders[extname(id)];
|
|
1813
|
+
}, "getLoader");
|
|
1814
|
+
const filter = createFilter(include, exclude);
|
|
1815
|
+
return {
|
|
1816
|
+
name: "esbuild",
|
|
1817
|
+
async transform(code, id) {
|
|
1818
|
+
if (!filter(id)) {
|
|
1819
|
+
return null;
|
|
1820
|
+
}
|
|
1821
|
+
const loader = getLoader(id);
|
|
1822
|
+
if (!loader) {
|
|
1823
|
+
return null;
|
|
1824
|
+
}
|
|
1825
|
+
const result = await transform2(code, {
|
|
1826
|
+
...esbuildOptions,
|
|
1827
|
+
loader,
|
|
1828
|
+
sourcefile: id
|
|
1829
|
+
});
|
|
1830
|
+
printWarnings(id, result, this);
|
|
1831
|
+
return {
|
|
1832
|
+
code: result.code || "",
|
|
1833
|
+
map: result.map || null
|
|
1834
|
+
};
|
|
1835
|
+
},
|
|
1836
|
+
async renderChunk(code, { fileName }) {
|
|
1837
|
+
if (!options.minify) {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1840
|
+
if (/\.d\.(c|m)?tsx?$/.test(fileName)) {
|
|
1841
|
+
return null;
|
|
1842
|
+
}
|
|
1843
|
+
const loader = getLoader(fileName);
|
|
1844
|
+
if (!loader) {
|
|
1845
|
+
return null;
|
|
1846
|
+
}
|
|
1847
|
+
const result = await transform2(code, {
|
|
1848
|
+
...esbuildOptions,
|
|
1849
|
+
loader,
|
|
1850
|
+
sourcefile: fileName,
|
|
1851
|
+
minify: true
|
|
1852
|
+
});
|
|
1853
|
+
return {
|
|
1854
|
+
code: result.code || "",
|
|
1855
|
+
map: result.map || null
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
__name(esbuild, "esbuild");
|
|
1861
|
+
function printWarnings(id, result, plugin) {
|
|
1862
|
+
if (result.warnings) {
|
|
1863
|
+
for (const warning of result.warnings) {
|
|
1864
|
+
let message = "[esbuild]";
|
|
1865
|
+
if (warning.location) {
|
|
1866
|
+
message += ` (${relative2(process.cwd(), id)}:${warning.location.line}:${warning.location.column})`;
|
|
1867
|
+
}
|
|
1868
|
+
message += ` ${warning.text}`;
|
|
1869
|
+
plugin.warn(message);
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
__name(printWarnings, "printWarnings");
|
|
1874
|
+
var EXPORT_DEFAULT = "export default ";
|
|
1875
|
+
function JSONPlugin(options) {
|
|
1876
|
+
const plugin = rollupJSONPlugin(options);
|
|
1877
|
+
return {
|
|
1878
|
+
...plugin,
|
|
1879
|
+
name: "unbuild-json",
|
|
1880
|
+
transform(code, id) {
|
|
1881
|
+
const res = plugin.transform.call(this, code, id);
|
|
1882
|
+
if (res && typeof res !== "string" && "code" in res && res.code && res.code.startsWith(EXPORT_DEFAULT)) {
|
|
1883
|
+
res.code = res.code.replace(EXPORT_DEFAULT, "module.exports = ");
|
|
1884
|
+
}
|
|
1885
|
+
return res;
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
__name(JSONPlugin, "JSONPlugin");
|
|
1890
|
+
var defaults = {
|
|
1891
|
+
include: [/\.(md|txt|css|htm|html)$/],
|
|
1892
|
+
exclude: []
|
|
1893
|
+
};
|
|
1894
|
+
function rawPlugin(opts = {}) {
|
|
1895
|
+
opts = { ...opts, ...defaults };
|
|
1896
|
+
const filter = createFilter(opts.include, opts.exclude);
|
|
1897
|
+
return {
|
|
1898
|
+
name: "unbuild-raw",
|
|
1899
|
+
transform(code, id) {
|
|
1900
|
+
if (filter(id)) {
|
|
1901
|
+
return {
|
|
1902
|
+
code: `export default ${JSON.stringify(code)}`,
|
|
1903
|
+
map: null
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
__name(rawPlugin, "rawPlugin");
|
|
1910
|
+
function cjsPlugin(_opts) {
|
|
1911
|
+
return {
|
|
1912
|
+
name: "unbuild-cjs",
|
|
1913
|
+
renderChunk(code, _chunk, opts) {
|
|
1914
|
+
if (opts.format === "es") {
|
|
1915
|
+
return CJSToESM(code);
|
|
1916
|
+
}
|
|
1917
|
+
return null;
|
|
1918
|
+
}
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
__name(cjsPlugin, "cjsPlugin");
|
|
1922
|
+
function fixCJSExportTypePlugin() {
|
|
1923
|
+
return {
|
|
1924
|
+
name: "unbuild-fix-cjs-export-type",
|
|
1925
|
+
renderChunk(code, info, opts) {
|
|
1926
|
+
if (info.type !== "chunk" || !info.fileName.endsWith(".d.cts") || !info.isEntry || info.exports?.length !== 1 || info.exports[0] !== "default") {
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1929
|
+
return code.replace(
|
|
1930
|
+
/(?<=(?<=[;}]|^)\s*export\s*){\s*([\w$]+)\s*as\s+default\s*}/,
|
|
1931
|
+
`= $1`
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
__name(fixCJSExportTypePlugin, "fixCJSExportTypePlugin");
|
|
1937
|
+
var CJSyntaxRe = /__filename|__dirname|require\(|require\.resolve\(/;
|
|
1938
|
+
var CJSShim = `
|
|
1939
|
+
|
|
1940
|
+
// -- Unbuild CommonJS Shims --
|
|
1941
|
+
import __cjs_url__ from 'url';
|
|
1942
|
+
import __cjs_path__ from 'path';
|
|
1943
|
+
import __cjs_mod__ from 'module';
|
|
1944
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
1945
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
1946
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
1947
|
+
`;
|
|
1948
|
+
function CJSToESM(code) {
|
|
1949
|
+
if (code.includes(CJSShim) || !CJSyntaxRe.test(code)) {
|
|
1950
|
+
return null;
|
|
1951
|
+
}
|
|
1952
|
+
const lastESMImport = findStaticImports(code).pop();
|
|
1953
|
+
const indexToAppend = lastESMImport ? lastESMImport.end : 0;
|
|
1954
|
+
const s = new MagicString(code);
|
|
1955
|
+
s.appendRight(indexToAppend, CJSShim);
|
|
1956
|
+
return {
|
|
1957
|
+
code: s.toString(),
|
|
1958
|
+
map: s.generateMap()
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
__name(CJSToESM, "CJSToESM");
|
|
1962
|
+
var DEFAULT_EXTENSIONS = [
|
|
1963
|
+
".ts",
|
|
1964
|
+
".tsx",
|
|
1965
|
+
".mts",
|
|
1966
|
+
".cts",
|
|
1967
|
+
".mjs",
|
|
1968
|
+
".cjs",
|
|
1969
|
+
".js",
|
|
1970
|
+
".jsx",
|
|
1971
|
+
".json"
|
|
1972
|
+
];
|
|
1973
|
+
function resolveAliases(ctx) {
|
|
1974
|
+
const aliases = {
|
|
1975
|
+
[ctx.pkg.name]: ctx.options.rootDir,
|
|
1976
|
+
...ctx.options.alias
|
|
1977
|
+
};
|
|
1978
|
+
if (ctx.options.rollup.alias) {
|
|
1979
|
+
if (Array.isArray(ctx.options.rollup.alias.entries)) {
|
|
1980
|
+
Object.assign(
|
|
1981
|
+
aliases,
|
|
1982
|
+
Object.fromEntries(
|
|
1983
|
+
ctx.options.rollup.alias.entries.map((entry) => {
|
|
1984
|
+
return [entry.find, entry.replacement];
|
|
1985
|
+
})
|
|
1986
|
+
)
|
|
1987
|
+
);
|
|
1988
|
+
} else {
|
|
1989
|
+
Object.assign(
|
|
1990
|
+
aliases,
|
|
1991
|
+
ctx.options.rollup.alias.entries || ctx.options.rollup.alias
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return aliases;
|
|
1996
|
+
}
|
|
1997
|
+
__name(resolveAliases, "resolveAliases");
|
|
1998
|
+
function getChunkFilename(ctx, chunk, ext) {
|
|
1999
|
+
if (chunk.isDynamicEntry) {
|
|
2000
|
+
return `chunks/[name].${ext}`;
|
|
2001
|
+
}
|
|
2002
|
+
return `shared/${ctx.options.name}.[hash].${ext}`;
|
|
2003
|
+
}
|
|
2004
|
+
__name(getChunkFilename, "getChunkFilename");
|
|
2005
|
+
function getRollupOptions(ctx) {
|
|
2006
|
+
const _aliases = resolveAliases(ctx);
|
|
2007
|
+
return {
|
|
2008
|
+
input: Object.fromEntries(
|
|
2009
|
+
ctx.options.entries.filter((entry) => entry.builder === "rollup").map((entry) => [
|
|
2010
|
+
entry.name,
|
|
2011
|
+
resolve(ctx.options.rootDir, entry.input)
|
|
2012
|
+
])
|
|
2013
|
+
),
|
|
2014
|
+
output: [
|
|
2015
|
+
ctx.options.rollup.emitCJS && {
|
|
2016
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2017
|
+
entryFileNames: "[name].cjs",
|
|
2018
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "cjs"), "chunkFileNames"),
|
|
2019
|
+
format: "cjs",
|
|
2020
|
+
exports: "auto",
|
|
2021
|
+
interop: "compat",
|
|
2022
|
+
generatedCode: { constBindings: true },
|
|
2023
|
+
externalLiveBindings: false,
|
|
2024
|
+
freeze: false,
|
|
2025
|
+
sourcemap: ctx.options.sourcemap,
|
|
2026
|
+
...ctx.options.rollup.output
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2030
|
+
entryFileNames: "[name].mjs",
|
|
2031
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "mjs"), "chunkFileNames"),
|
|
2032
|
+
format: "esm",
|
|
2033
|
+
exports: "auto",
|
|
2034
|
+
generatedCode: { constBindings: true },
|
|
2035
|
+
externalLiveBindings: false,
|
|
2036
|
+
freeze: false,
|
|
2037
|
+
sourcemap: ctx.options.sourcemap,
|
|
2038
|
+
...ctx.options.rollup.output
|
|
2039
|
+
}
|
|
2040
|
+
].filter(Boolean),
|
|
2041
|
+
external(originalId) {
|
|
2042
|
+
const resolvedId = resolveAlias(originalId, _aliases);
|
|
2043
|
+
const pkgName = parseNodeModulePath(resolvedId)?.name || parseNodeModulePath(originalId)?.name || getpkg(originalId);
|
|
2044
|
+
if (arrayIncludes(ctx.options.externals, pkgName) || arrayIncludes(ctx.options.externals, originalId) || arrayIncludes(ctx.options.externals, resolvedId)) {
|
|
2045
|
+
return true;
|
|
2046
|
+
}
|
|
2047
|
+
for (const id of [originalId, resolvedId]) {
|
|
2048
|
+
if (id[0] === "." || isAbsolute(id) || /src[/\\]/.test(id) || id.startsWith(ctx.pkg.name)) {
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
if (ctx.options.rollup.inlineDependencies === true || Array.isArray(ctx.options.rollup.inlineDependencies) && (arrayIncludes(ctx.options.rollup.inlineDependencies, pkgName) || arrayIncludes(ctx.options.rollup.inlineDependencies, originalId) || arrayIncludes(ctx.options.rollup.inlineDependencies, resolvedId))) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
warn(ctx, `Implicitly bundling "${originalId}"`);
|
|
2056
|
+
return false;
|
|
2057
|
+
},
|
|
2058
|
+
onwarn(warning, rollupWarn) {
|
|
2059
|
+
if (!warning.code || !["CIRCULAR_DEPENDENCY"].includes(warning.code)) {
|
|
2060
|
+
rollupWarn(warning);
|
|
2061
|
+
}
|
|
2062
|
+
},
|
|
2063
|
+
plugins: [
|
|
2064
|
+
ctx.options.rollup.replace && replace({
|
|
2065
|
+
...ctx.options.rollup.replace,
|
|
2066
|
+
values: {
|
|
2067
|
+
...ctx.options.replace,
|
|
2068
|
+
...ctx.options.rollup.replace.values
|
|
2069
|
+
}
|
|
2070
|
+
}),
|
|
2071
|
+
ctx.options.rollup.alias && alias({
|
|
2072
|
+
...ctx.options.rollup.alias,
|
|
2073
|
+
entries: _aliases
|
|
2074
|
+
}),
|
|
2075
|
+
ctx.options.rollup.resolve && nodeResolve({
|
|
2076
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2077
|
+
exportConditions: ["production"],
|
|
2078
|
+
...ctx.options.rollup.resolve
|
|
2079
|
+
}),
|
|
2080
|
+
ctx.options.rollup.json && JSONPlugin({
|
|
2081
|
+
...ctx.options.rollup.json
|
|
2082
|
+
}),
|
|
2083
|
+
shebangPlugin(),
|
|
2084
|
+
ctx.options.rollup.esbuild && esbuild({
|
|
2085
|
+
sourcemap: ctx.options.sourcemap,
|
|
2086
|
+
...ctx.options.rollup.esbuild
|
|
2087
|
+
}),
|
|
2088
|
+
ctx.options.rollup.commonjs && commonjs({
|
|
2089
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
2090
|
+
...ctx.options.rollup.commonjs
|
|
2091
|
+
}),
|
|
2092
|
+
ctx.options.rollup.preserveDynamicImports && {
|
|
2093
|
+
renderDynamicImport() {
|
|
2094
|
+
return { left: "import(", right: ")" };
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
ctx.options.rollup.cjsBridge && cjsPlugin(),
|
|
2098
|
+
rawPlugin()
|
|
2099
|
+
].filter(Boolean)
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
__name(getRollupOptions, "getRollupOptions");
|
|
2103
|
+
async function rollupStub(ctx) {
|
|
2104
|
+
const babelPlugins = ctx.options.stubOptions.jiti.transformOptions?.babel?.plugins;
|
|
2105
|
+
const importedBabelPlugins = [];
|
|
2106
|
+
const serializedJitiOptions = JSON.stringify(
|
|
2107
|
+
{
|
|
2108
|
+
...ctx.options.stubOptions.jiti,
|
|
2109
|
+
alias: {
|
|
2110
|
+
...resolveAliases(ctx),
|
|
2111
|
+
...ctx.options.stubOptions.jiti.alias
|
|
2112
|
+
},
|
|
2113
|
+
transformOptions: {
|
|
2114
|
+
...ctx.options.stubOptions.jiti.transformOptions,
|
|
2115
|
+
babel: {
|
|
2116
|
+
...ctx.options.stubOptions.jiti.transformOptions?.babel,
|
|
2117
|
+
plugins: "__$BABEL_PLUGINS"
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
},
|
|
2121
|
+
null,
|
|
2122
|
+
2
|
|
2123
|
+
).replace(
|
|
2124
|
+
'"__$BABEL_PLUGINS"',
|
|
2125
|
+
Array.isArray(babelPlugins) ? "[" + babelPlugins.map((plugin, i) => {
|
|
2126
|
+
if (Array.isArray(plugin)) {
|
|
2127
|
+
const [name, ...args] = plugin;
|
|
2128
|
+
importedBabelPlugins.push(name);
|
|
2129
|
+
return `[` + [
|
|
2130
|
+
`plugin${i}`,
|
|
2131
|
+
...args.map((val) => JSON.stringify(val))
|
|
2132
|
+
].join(", ") + "]";
|
|
2133
|
+
} else {
|
|
2134
|
+
importedBabelPlugins.push(plugin);
|
|
2135
|
+
return `plugin${i}`;
|
|
2136
|
+
}
|
|
2137
|
+
}).join(",") + "]" : "[]"
|
|
2138
|
+
);
|
|
2139
|
+
for (const entry of ctx.options.entries.filter(
|
|
2140
|
+
(entry2) => entry2.builder === "rollup"
|
|
2141
|
+
)) {
|
|
2142
|
+
const output = resolve(
|
|
2143
|
+
ctx.options.rootDir,
|
|
2144
|
+
ctx.options.outDir,
|
|
2145
|
+
entry.name
|
|
2146
|
+
);
|
|
2147
|
+
const isESM = ctx.pkg.type === "module";
|
|
2148
|
+
const resolvedEntry = fileURLToPath(ctx.jiti.esmResolve(entry.input));
|
|
2149
|
+
const resolvedEntryWithoutExt = resolvedEntry.slice(
|
|
2150
|
+
0,
|
|
2151
|
+
Math.max(0, resolvedEntry.length - extname(resolvedEntry).length)
|
|
2152
|
+
);
|
|
2153
|
+
const resolvedEntryForTypeImport = isESM ? `${resolvedEntry.replace(/(\.m?)(ts)$/, "$1js")}` : resolvedEntryWithoutExt;
|
|
2154
|
+
const code = await promises.readFile(resolvedEntry, "utf8");
|
|
2155
|
+
const shebang = getShebang(code);
|
|
2156
|
+
await mkdir(dirname(output), { recursive: true });
|
|
2157
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2158
|
+
const jitiCJSPath = relative2(
|
|
2159
|
+
dirname(output),
|
|
2160
|
+
await resolvePath("jiti", {
|
|
2161
|
+
url: import.meta.url,
|
|
2162
|
+
conditions: ["node", "require"]
|
|
2163
|
+
})
|
|
2164
|
+
);
|
|
2165
|
+
await writeFile2(
|
|
2166
|
+
output + ".cjs",
|
|
2167
|
+
shebang + [
|
|
2168
|
+
`const { createJiti } = require(${JSON.stringify(jitiCJSPath)})`,
|
|
2169
|
+
...importedBabelPlugins.map(
|
|
2170
|
+
(plugin, i) => `const plugin${i} = require(${JSON.stringify(plugin)})`
|
|
2171
|
+
),
|
|
2172
|
+
"",
|
|
2173
|
+
`const jiti = createJiti(__filename, ${serializedJitiOptions})`,
|
|
2174
|
+
"",
|
|
2175
|
+
`/** @type {import(${JSON.stringify(
|
|
2176
|
+
resolvedEntryForTypeImport
|
|
2177
|
+
)})} */`,
|
|
2178
|
+
`module.exports = jiti(${JSON.stringify(resolvedEntry)})`
|
|
2179
|
+
].join("\n")
|
|
2180
|
+
);
|
|
2181
|
+
}
|
|
2182
|
+
const namedExports = await resolveModuleExportNames(
|
|
2183
|
+
resolvedEntry,
|
|
2184
|
+
{
|
|
2185
|
+
extensions: DEFAULT_EXTENSIONS
|
|
2186
|
+
}
|
|
2187
|
+
).catch((error) => {
|
|
2188
|
+
warn(ctx, `Cannot analyze ${resolvedEntry} for exports:` + error);
|
|
2189
|
+
return [];
|
|
2190
|
+
});
|
|
2191
|
+
const hasDefaultExport = namedExports.includes("default") || namedExports.length === 0;
|
|
2192
|
+
const jitiESMPath = relative2(
|
|
2193
|
+
dirname(output),
|
|
2194
|
+
await resolvePath("jiti", {
|
|
2195
|
+
url: import.meta.url,
|
|
2196
|
+
conditions: ["node", "import"]
|
|
2197
|
+
})
|
|
2198
|
+
);
|
|
2199
|
+
await writeFile2(
|
|
2200
|
+
output + ".mjs",
|
|
2201
|
+
shebang + [
|
|
2202
|
+
`import { createJiti } from ${JSON.stringify(jitiESMPath)};`,
|
|
2203
|
+
...importedBabelPlugins.map(
|
|
2204
|
+
(plugin, i) => `import plugin${i} from ${JSON.stringify(plugin)}`
|
|
2205
|
+
),
|
|
2206
|
+
"",
|
|
2207
|
+
`const jiti = createJiti(import.meta.url, ${serializedJitiOptions})`,
|
|
2208
|
+
"",
|
|
2209
|
+
`/** @type {import(${JSON.stringify(resolvedEntryForTypeImport)})} */`,
|
|
2210
|
+
`const _module = await jiti.import(${JSON.stringify(
|
|
2211
|
+
resolvedEntry
|
|
2212
|
+
)});`,
|
|
2213
|
+
hasDefaultExport ? "\nexport default _module?.default ?? _module;" : "",
|
|
2214
|
+
...namedExports.filter((name) => name !== "default").map((name) => `export const ${name} = _module.${name};`)
|
|
2215
|
+
].join("\n")
|
|
2216
|
+
);
|
|
2217
|
+
if (ctx.options.declaration) {
|
|
2218
|
+
const dtsContent = [
|
|
2219
|
+
`export * from ${JSON.stringify(resolvedEntryForTypeImport)};`,
|
|
2220
|
+
hasDefaultExport ? `export { default } from ${JSON.stringify(resolvedEntryForTypeImport)};` : ""
|
|
2221
|
+
].join("\n");
|
|
2222
|
+
await writeFile2(output + ".d.cts", dtsContent);
|
|
2223
|
+
await writeFile2(output + ".d.mts", dtsContent);
|
|
2224
|
+
if (ctx.options.declaration === "compatible" || ctx.options.declaration === true) {
|
|
2225
|
+
await writeFile2(output + ".d.ts", dtsContent);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
if (shebang) {
|
|
2229
|
+
await makeExecutable(output + ".cjs");
|
|
2230
|
+
await makeExecutable(output + ".mjs");
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
__name(rollupStub, "rollupStub");
|
|
2235
|
+
function rollupWatch(rollupOptions) {
|
|
2236
|
+
const watcher = watch(rollupOptions);
|
|
2237
|
+
let inputs;
|
|
2238
|
+
if (Array.isArray(rollupOptions.input)) {
|
|
2239
|
+
inputs = rollupOptions.input;
|
|
2240
|
+
} else if (typeof rollupOptions.input === "string") {
|
|
2241
|
+
inputs = [rollupOptions.input];
|
|
2242
|
+
} else {
|
|
2243
|
+
inputs = Object.keys(rollupOptions.input || {});
|
|
2244
|
+
}
|
|
2245
|
+
consola$1.info(
|
|
2246
|
+
`[unbuild] [rollup] Starting watchers for entries: ${inputs.map((input) => "./" + relative2(process.cwd(), input)).join(", ")}`
|
|
2247
|
+
);
|
|
2248
|
+
consola$1.warn(
|
|
2249
|
+
"[unbuild] [rollup] Watch mode is experimental and may be unstable"
|
|
2250
|
+
);
|
|
2251
|
+
watcher.on("change", (id, { event }) => {
|
|
2252
|
+
consola$1.info(`${colors.cyan(relative2(".", id))} was ${event}d`);
|
|
2253
|
+
});
|
|
2254
|
+
watcher.on("restart", () => {
|
|
2255
|
+
consola$1.info(colors.gray("[unbuild] [rollup] Rebuilding bundle"));
|
|
2256
|
+
});
|
|
2257
|
+
watcher.on("event", (event) => {
|
|
2258
|
+
if (event.code === "END") {
|
|
2259
|
+
consola$1.success(colors.green("[unbuild] [rollup] Rebuild finished\n"));
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
__name(rollupWatch, "rollupWatch");
|
|
2264
|
+
async function rollupBuild(ctx) {
|
|
2265
|
+
if (ctx.options.stub) {
|
|
2266
|
+
await rollupStub(ctx);
|
|
2267
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
const rollupOptions = getRollupOptions(ctx);
|
|
2271
|
+
await ctx.hooks.callHook("rollup:options", ctx, rollupOptions);
|
|
2272
|
+
if (Object.keys(rollupOptions.input).length === 0) {
|
|
2273
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
const buildResult = await rollup(rollupOptions);
|
|
2277
|
+
await ctx.hooks.callHook("rollup:build", ctx, buildResult);
|
|
2278
|
+
const allOutputOptions = rollupOptions.output;
|
|
2279
|
+
for (const outputOptions of allOutputOptions) {
|
|
2280
|
+
const { output } = await buildResult.write(outputOptions);
|
|
2281
|
+
const chunkFileNames = /* @__PURE__ */ new Set();
|
|
2282
|
+
const outputChunks = output.filter(
|
|
2283
|
+
(e) => e.type === "chunk"
|
|
2284
|
+
);
|
|
2285
|
+
for (const entry of outputChunks) {
|
|
2286
|
+
chunkFileNames.add(entry.fileName);
|
|
2287
|
+
for (const id of entry.imports) {
|
|
2288
|
+
ctx.usedImports.add(id);
|
|
2289
|
+
}
|
|
2290
|
+
if (entry.isEntry) {
|
|
2291
|
+
ctx.buildEntries.push({
|
|
2292
|
+
chunks: entry.imports.filter(
|
|
2293
|
+
(i) => outputChunks.find((c) => c.fileName === i)
|
|
2294
|
+
),
|
|
2295
|
+
modules: Object.entries(entry.modules).map(([id, mod]) => ({
|
|
2296
|
+
id,
|
|
2297
|
+
bytes: mod.renderedLength
|
|
2298
|
+
})),
|
|
2299
|
+
path: entry.fileName,
|
|
2300
|
+
bytes: Buffer.byteLength(entry.code, "utf8"),
|
|
2301
|
+
exports: entry.exports
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
for (const chunkFileName of chunkFileNames) {
|
|
2306
|
+
ctx.usedImports.delete(chunkFileName);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
if (ctx.options.watch) {
|
|
2310
|
+
rollupWatch(rollupOptions);
|
|
2311
|
+
if (ctx.options.declaration && ctx.options.watch) {
|
|
2312
|
+
consola$1.warn("`rollup` DTS builder does not support watch mode yet.");
|
|
2313
|
+
}
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
if (ctx.options.declaration) {
|
|
2317
|
+
rollupOptions.plugins = [
|
|
2318
|
+
...rollupOptions.plugins,
|
|
2319
|
+
dts(ctx.options.rollup.dts),
|
|
2320
|
+
removeShebangPlugin(),
|
|
2321
|
+
ctx.options.rollup.emitCJS && fixCJSExportTypePlugin()
|
|
2322
|
+
].filter(Boolean);
|
|
2323
|
+
await ctx.hooks.callHook("rollup:dts:options", ctx, rollupOptions);
|
|
2324
|
+
const typesBuild2 = await rollup(rollupOptions);
|
|
2325
|
+
await ctx.hooks.callHook("rollup:dts:build", ctx, typesBuild2);
|
|
2326
|
+
if (ctx.options.rollup.emitCJS) {
|
|
2327
|
+
await typesBuild2.write({
|
|
2328
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2329
|
+
entryFileNames: "[name].d.cts",
|
|
2330
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.cts"), "chunkFileNames")
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
await typesBuild2.write({
|
|
2334
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2335
|
+
entryFileNames: "[name].d.mts",
|
|
2336
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.mts"), "chunkFileNames")
|
|
2337
|
+
});
|
|
2338
|
+
if (ctx.options.declaration === true || ctx.options.declaration === "compatible") {
|
|
2339
|
+
await typesBuild2.write({
|
|
2340
|
+
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
|
|
2341
|
+
entryFileNames: "[name].d.ts",
|
|
2342
|
+
chunkFileNames: /* @__PURE__ */ __name((chunk) => getChunkFilename(ctx, chunk, "d.ts"), "chunkFileNames")
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
await ctx.hooks.callHook("rollup:done", ctx);
|
|
2347
|
+
}
|
|
2348
|
+
__name(rollupBuild, "rollupBuild");
|
|
2349
|
+
async function typesBuild(ctx) {
|
|
2350
|
+
const entries = ctx.options.entries.filter(
|
|
2351
|
+
(entry) => entry.builder === "untyped"
|
|
2352
|
+
);
|
|
2353
|
+
await ctx.hooks.callHook("untyped:entries", ctx, entries);
|
|
2354
|
+
for (const entry of entries) {
|
|
2355
|
+
const options = {
|
|
2356
|
+
jiti: {
|
|
2357
|
+
interopDefault: true,
|
|
2358
|
+
transformOptions: {
|
|
2359
|
+
babel: {
|
|
2360
|
+
plugins: [untypedPlugin]
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
await ctx.hooks.callHook("untyped:entry:options", ctx, entry, options);
|
|
2366
|
+
const untypedJiti = createJiti(ctx.options.rootDir, options.jiti);
|
|
2367
|
+
const distDir = entry.outDir;
|
|
2368
|
+
let rawSchema = await untypedJiti.import(resolve(ctx.options.rootDir, entry.input), {
|
|
2369
|
+
try: true
|
|
2370
|
+
}) || {};
|
|
2371
|
+
const rawSchemaKeys = Object.keys(rawSchema);
|
|
2372
|
+
if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") {
|
|
2373
|
+
rawSchema = rawSchema.default;
|
|
2374
|
+
}
|
|
2375
|
+
const defaults2 = entry.defaults || {};
|
|
2376
|
+
const schema = await resolveSchema(rawSchema, defaults2);
|
|
2377
|
+
await ctx.hooks.callHook("untyped:entry:schema", ctx, entry, schema);
|
|
2378
|
+
const outputs = {
|
|
2379
|
+
markdown: {
|
|
2380
|
+
fileName: resolve(distDir, `${entry.name}.md`),
|
|
2381
|
+
contents: generateMarkdown(schema)
|
|
2382
|
+
},
|
|
2383
|
+
schema: {
|
|
2384
|
+
fileName: `${entry.name}.schema.json`,
|
|
2385
|
+
contents: JSON.stringify(schema, null, 2)
|
|
2386
|
+
},
|
|
2387
|
+
defaults: {
|
|
2388
|
+
fileName: `${entry.name}.defaults.json`,
|
|
2389
|
+
contents: JSON.stringify(defaults2, null, 2)
|
|
2390
|
+
},
|
|
2391
|
+
declaration: entry.declaration ? {
|
|
2392
|
+
fileName: `${entry.name}.d.ts`,
|
|
2393
|
+
contents: generateTypes(schema, {
|
|
2394
|
+
interfaceName: pascalCase(entry.name + "-schema")
|
|
2395
|
+
})
|
|
2396
|
+
} : void 0
|
|
2397
|
+
};
|
|
2398
|
+
await ctx.hooks.callHook("untyped:entry:outputs", ctx, entry, outputs);
|
|
2399
|
+
for (const output of Object.values(outputs)) {
|
|
2400
|
+
if (!output) continue;
|
|
2401
|
+
await writeFile2(
|
|
2402
|
+
resolve(distDir, output.fileName),
|
|
2403
|
+
output.contents,
|
|
2404
|
+
"utf8"
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
await ctx.hooks.callHook("untyped:done", ctx);
|
|
2409
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2410
|
+
consola$1.warn("`untyped` builder does not support watch mode yet.");
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
__name(typesBuild, "typesBuild");
|
|
2414
|
+
async function mkdistBuild(ctx) {
|
|
2415
|
+
const entries = ctx.options.entries.filter(
|
|
2416
|
+
(e) => e.builder === "mkdist"
|
|
2417
|
+
);
|
|
2418
|
+
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
2419
|
+
for (const entry of entries) {
|
|
2420
|
+
const distDir = entry.outDir;
|
|
2421
|
+
if (ctx.options.stub) {
|
|
2422
|
+
await rmdir(distDir);
|
|
2423
|
+
await symlink(entry.input, distDir);
|
|
2424
|
+
} else {
|
|
2425
|
+
const mkdistOptions = {
|
|
2426
|
+
rootDir: ctx.options.rootDir,
|
|
2427
|
+
srcDir: entry.input,
|
|
2428
|
+
distDir,
|
|
2429
|
+
cleanDist: false,
|
|
2430
|
+
...entry
|
|
2431
|
+
};
|
|
2432
|
+
await ctx.hooks.callHook(
|
|
2433
|
+
"mkdist:entry:options",
|
|
2434
|
+
ctx,
|
|
2435
|
+
entry,
|
|
2436
|
+
mkdistOptions
|
|
2437
|
+
);
|
|
2438
|
+
const output = await mkdist(mkdistOptions);
|
|
2439
|
+
ctx.buildEntries.push({
|
|
2440
|
+
path: distDir,
|
|
2441
|
+
chunks: output.writtenFiles.map((p) => relative2(ctx.options.outDir, p))
|
|
2442
|
+
});
|
|
2443
|
+
await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
|
|
2444
|
+
if (output.errors) {
|
|
2445
|
+
for (const error of output.errors) {
|
|
2446
|
+
warn(
|
|
2447
|
+
ctx,
|
|
2448
|
+
`mkdist build failed for \`${relative2(ctx.options.rootDir, error.filename)}\`:
|
|
2449
|
+
${error.errors.map((e) => ` - ${e}`).join("\n")}`
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
await ctx.hooks.callHook("mkdist:done", ctx);
|
|
2456
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2457
|
+
consola$1.warn("`mkdist` builder does not support watch mode yet.");
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
__name(mkdistBuild, "mkdistBuild");
|
|
2461
|
+
var copy = promises.cp || promises.copyFile;
|
|
2462
|
+
async function copyBuild(ctx) {
|
|
2463
|
+
const entries = ctx.options.entries.filter(
|
|
2464
|
+
(e) => e.builder === "copy"
|
|
2465
|
+
);
|
|
2466
|
+
await ctx.hooks.callHook("copy:entries", ctx, entries);
|
|
2467
|
+
for (const entry of entries) {
|
|
2468
|
+
const distDir = entry.outDir;
|
|
2469
|
+
if (ctx.options.stub) {
|
|
2470
|
+
await rmdir(distDir);
|
|
2471
|
+
await symlink(entry.input, distDir);
|
|
2472
|
+
} else {
|
|
2473
|
+
const patterns = Array.isArray(entry.pattern) ? entry.pattern : [entry.pattern || "**"];
|
|
2474
|
+
const paths = await glob3(patterns, {
|
|
2475
|
+
cwd: resolve(ctx.options.rootDir, entry.input),
|
|
2476
|
+
absolute: false
|
|
2477
|
+
});
|
|
2478
|
+
const outputList = await Promise.allSettled(
|
|
2479
|
+
paths.map(async (path3) => {
|
|
2480
|
+
const src = resolve(ctx.options.rootDir, entry.input, path3);
|
|
2481
|
+
const dist = resolve(ctx.options.rootDir, distDir, path3);
|
|
2482
|
+
await copy(src, dist);
|
|
2483
|
+
return dist;
|
|
2484
|
+
})
|
|
2485
|
+
);
|
|
2486
|
+
for (const output of outputList) {
|
|
2487
|
+
if (output.status === "rejected") {
|
|
2488
|
+
warn(ctx, output.reason);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
ctx.buildEntries.push({
|
|
2492
|
+
path: distDir,
|
|
2493
|
+
chunks: outputList.filter(({ status }) => status === "fulfilled").map(
|
|
2494
|
+
(p) => relative2(
|
|
2495
|
+
ctx.options.outDir,
|
|
2496
|
+
p.value
|
|
2497
|
+
)
|
|
2498
|
+
)
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
await ctx.hooks.callHook("copy:done", ctx);
|
|
2503
|
+
if (entries.length > 0 && ctx.options.watch) {
|
|
2504
|
+
consola$1.warn("`untyped` builder does not support watch mode yet.");
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
__name(copyBuild, "copyBuild");
|
|
2508
|
+
async function build(rootDir, stub, inputConfig = {}) {
|
|
2509
|
+
rootDir = resolve(process.cwd(), rootDir || ".");
|
|
2510
|
+
const jiti = createJiti(rootDir);
|
|
2511
|
+
const _buildConfig = await jiti.import(inputConfig?.config || "./build.config", {
|
|
2512
|
+
try: !inputConfig.config,
|
|
2513
|
+
default: true
|
|
2514
|
+
}) || {};
|
|
2515
|
+
const buildConfigs = (Array.isArray(_buildConfig) ? _buildConfig : [_buildConfig]).filter(Boolean);
|
|
2516
|
+
const pkg = await jiti.import("./package.json", {
|
|
2517
|
+
try: true,
|
|
2518
|
+
default: true
|
|
2519
|
+
}) || {};
|
|
2520
|
+
const cleanedDirs = [];
|
|
2521
|
+
const _watchMode = inputConfig.watch === true;
|
|
2522
|
+
const _stubMode = !_watchMode && (stub || inputConfig.stub === true);
|
|
2523
|
+
for (const buildConfig of buildConfigs) {
|
|
2524
|
+
await _build(
|
|
2525
|
+
rootDir,
|
|
2526
|
+
inputConfig,
|
|
2527
|
+
buildConfig,
|
|
2528
|
+
pkg,
|
|
2529
|
+
cleanedDirs,
|
|
2530
|
+
_stubMode,
|
|
2531
|
+
_watchMode
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
__name(build, "build");
|
|
2536
|
+
async function _build(rootDir, inputConfig = {}, buildConfig, pkg, cleanedDirs, _stubMode, _watchMode) {
|
|
2537
|
+
const preset = await resolvePreset(
|
|
2538
|
+
buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || inputConfig.preset || "auto",
|
|
2539
|
+
rootDir
|
|
2540
|
+
);
|
|
2541
|
+
const options = defu3(
|
|
2542
|
+
buildConfig,
|
|
2543
|
+
pkg.unbuild || pkg.build,
|
|
2544
|
+
inputConfig,
|
|
2545
|
+
preset,
|
|
2546
|
+
{
|
|
2547
|
+
name: (pkg?.name || "").split("/").pop() || "default",
|
|
2548
|
+
rootDir,
|
|
2549
|
+
entries: [],
|
|
2550
|
+
clean: true,
|
|
2551
|
+
declaration: void 0,
|
|
2552
|
+
outDir: "dist",
|
|
2553
|
+
stub: _stubMode,
|
|
2554
|
+
stubOptions: {
|
|
2555
|
+
/**
|
|
2556
|
+
* See https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
2557
|
+
*/
|
|
2558
|
+
jiti: {
|
|
2559
|
+
interopDefault: true,
|
|
2560
|
+
alias: {}
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
watch: _watchMode,
|
|
2564
|
+
watchOptions: _watchMode ? {
|
|
2565
|
+
exclude: "node_modules/**",
|
|
2566
|
+
include: "src/**"
|
|
2567
|
+
} : void 0,
|
|
2568
|
+
externals: [
|
|
2569
|
+
...Module.builtinModules,
|
|
2570
|
+
...Module.builtinModules.map((m) => "node:" + m)
|
|
2571
|
+
],
|
|
2572
|
+
dependencies: [],
|
|
2573
|
+
devDependencies: [],
|
|
2574
|
+
peerDependencies: [],
|
|
2575
|
+
alias: {},
|
|
2576
|
+
replace: {},
|
|
2577
|
+
failOnWarn: true,
|
|
2578
|
+
sourcemap: false,
|
|
2579
|
+
rollup: {
|
|
2580
|
+
emitCJS: false,
|
|
2581
|
+
watch: false,
|
|
2582
|
+
cjsBridge: false,
|
|
2583
|
+
inlineDependencies: false,
|
|
2584
|
+
preserveDynamicImports: true,
|
|
2585
|
+
output: {
|
|
2586
|
+
// https://v8.dev/features/import-attributes
|
|
2587
|
+
importAttributesKey: "with"
|
|
2588
|
+
},
|
|
2589
|
+
// Plugins
|
|
2590
|
+
replace: {
|
|
2591
|
+
preventAssignment: true
|
|
2592
|
+
},
|
|
2593
|
+
alias: {},
|
|
2594
|
+
resolve: {
|
|
2595
|
+
preferBuiltins: true
|
|
2596
|
+
},
|
|
2597
|
+
json: {
|
|
2598
|
+
preferConst: true
|
|
2599
|
+
},
|
|
2600
|
+
commonjs: {
|
|
2601
|
+
ignoreTryCatch: true
|
|
2602
|
+
},
|
|
2603
|
+
esbuild: { target: "esnext" },
|
|
2604
|
+
dts: {
|
|
2605
|
+
// https://github.com/Swatinem/rollup-plugin-dts/issues/143
|
|
2606
|
+
compilerOptions: { preserveSymlinks: false },
|
|
2607
|
+
respectExternal: true
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
parallel: false
|
|
2611
|
+
}
|
|
2612
|
+
);
|
|
2613
|
+
options.outDir = resolve(options.rootDir, options.outDir);
|
|
2614
|
+
const jiti = createJiti(options.rootDir, { interopDefault: true });
|
|
2615
|
+
const ctx = {
|
|
2616
|
+
options,
|
|
2617
|
+
jiti,
|
|
2618
|
+
warnings: /* @__PURE__ */ new Set(),
|
|
2619
|
+
pkg,
|
|
2620
|
+
buildEntries: [],
|
|
2621
|
+
usedImports: /* @__PURE__ */ new Set(),
|
|
2622
|
+
hooks: createHooks()
|
|
2623
|
+
};
|
|
2624
|
+
if (preset.hooks) {
|
|
2625
|
+
ctx.hooks.addHooks(preset.hooks);
|
|
2626
|
+
}
|
|
2627
|
+
if (inputConfig.hooks) {
|
|
2628
|
+
ctx.hooks.addHooks(inputConfig.hooks);
|
|
2629
|
+
}
|
|
2630
|
+
if (buildConfig.hooks) {
|
|
2631
|
+
ctx.hooks.addHooks(buildConfig.hooks);
|
|
2632
|
+
}
|
|
2633
|
+
await ctx.hooks.callHook("build:prepare", ctx);
|
|
2634
|
+
options.entries = options.entries.map(
|
|
2635
|
+
(entry) => typeof entry === "string" ? { input: entry } : entry
|
|
2636
|
+
);
|
|
2637
|
+
for (const entry of options.entries) {
|
|
2638
|
+
if (typeof entry.name !== "string") {
|
|
2639
|
+
let relativeInput = isAbsolute(entry.input) ? relative2(rootDir, entry.input) : normalize(entry.input);
|
|
2640
|
+
if (relativeInput.startsWith("./")) {
|
|
2641
|
+
relativeInput = relativeInput.slice(2);
|
|
2642
|
+
}
|
|
2643
|
+
entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
|
|
2644
|
+
}
|
|
2645
|
+
if (!entry.input) {
|
|
2646
|
+
throw new Error("Missing entry input: " + dumpObject(entry));
|
|
2647
|
+
}
|
|
2648
|
+
if (!entry.builder) {
|
|
2649
|
+
entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
|
|
2650
|
+
}
|
|
2651
|
+
if (options.declaration !== void 0 && entry.declaration === void 0) {
|
|
2652
|
+
entry.declaration = options.declaration;
|
|
2653
|
+
}
|
|
2654
|
+
entry.input = resolve(options.rootDir, entry.input);
|
|
2655
|
+
entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
|
|
2656
|
+
}
|
|
2657
|
+
options.dependencies = Object.keys(pkg.dependencies || {});
|
|
2658
|
+
options.peerDependencies = Object.keys(pkg.peerDependencies || {});
|
|
2659
|
+
options.devDependencies = Object.keys(pkg.devDependencies || {});
|
|
2660
|
+
options.externals.push(...inferPkgExternals(pkg));
|
|
2661
|
+
options.externals = [...new Set(options.externals)];
|
|
2662
|
+
await ctx.hooks.callHook("build:before", ctx);
|
|
2663
|
+
consola.info(
|
|
2664
|
+
colors.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`)
|
|
2665
|
+
);
|
|
2666
|
+
if (process.env.DEBUG) {
|
|
2667
|
+
consola.info(`${colors.bold("Root dir:")} ${options.rootDir}
|
|
2668
|
+
${colors.bold("Entries:")}
|
|
2669
|
+
${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")}
|
|
2670
|
+
`);
|
|
2671
|
+
}
|
|
2672
|
+
if (options.clean) {
|
|
2673
|
+
for (const dir of new Set(
|
|
2674
|
+
options.entries.map((e) => e.outDir).filter(Boolean).sort()
|
|
2675
|
+
)) {
|
|
2676
|
+
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
2677
|
+
continue;
|
|
2678
|
+
}
|
|
2679
|
+
cleanedDirs.push(dir);
|
|
2680
|
+
consola.info(
|
|
2681
|
+
`Cleaning dist directory: \`./${relative2(process.cwd(), dir)}\``
|
|
2682
|
+
);
|
|
2683
|
+
await rmdir(dir);
|
|
2684
|
+
await promises.mkdir(dir, { recursive: true });
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
const buildTasks = [
|
|
2688
|
+
typesBuild,
|
|
2689
|
+
// untyped
|
|
2690
|
+
mkdistBuild,
|
|
2691
|
+
// mkdist
|
|
2692
|
+
rollupBuild,
|
|
2693
|
+
// rollup
|
|
2694
|
+
copyBuild
|
|
2695
|
+
// copy
|
|
2696
|
+
];
|
|
2697
|
+
if (options.parallel) {
|
|
2698
|
+
await Promise.all(buildTasks.map((task) => task(ctx)));
|
|
2699
|
+
} else {
|
|
2700
|
+
for (const task of buildTasks) {
|
|
2701
|
+
await task(ctx);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
if (options.stub || options.watch) {
|
|
2705
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
consola.success(colors.green("Build succeeded for " + options.name));
|
|
2709
|
+
const outFiles = await glob3(["**"], { cwd: options.outDir });
|
|
2710
|
+
for (const file of outFiles) {
|
|
2711
|
+
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
2712
|
+
if (!entry) {
|
|
2713
|
+
entry = {
|
|
2714
|
+
path: file,
|
|
2715
|
+
chunk: true
|
|
2716
|
+
};
|
|
2717
|
+
ctx.buildEntries.push(entry);
|
|
2718
|
+
}
|
|
2719
|
+
if (!entry.bytes) {
|
|
2720
|
+
const stat = await promises.stat(resolve(options.outDir, file));
|
|
2721
|
+
entry.bytes = stat.size;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
const rPath = /* @__PURE__ */ __name((p) => relative2(process.cwd(), resolve(options.outDir, p)), "rPath");
|
|
2725
|
+
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
2726
|
+
let totalBytes = entry.bytes || 0;
|
|
2727
|
+
for (const chunk of entry.chunks || []) {
|
|
2728
|
+
totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
|
|
2729
|
+
}
|
|
2730
|
+
let line = ` ${colors.bold(rPath(entry.path))} (` + [
|
|
2731
|
+
totalBytes && `total size: ${colors.cyan(prettyBytes(totalBytes))}`,
|
|
2732
|
+
entry.bytes && `chunk size: ${colors.cyan(prettyBytes(entry.bytes))}`,
|
|
2733
|
+
entry.exports?.length && `exports: ${colors.gray(entry.exports.join(", "))}`
|
|
2734
|
+
].filter(Boolean).join(", ") + ")";
|
|
2735
|
+
if (entry.chunks?.length) {
|
|
2736
|
+
line += "\n" + entry.chunks.map((p) => {
|
|
2737
|
+
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
2738
|
+
return colors.gray(
|
|
2739
|
+
" \u2514\u2500 " + rPath(p) + colors.bold(
|
|
2740
|
+
chunk.bytes ? ` (${prettyBytes(chunk?.bytes)})` : ""
|
|
2741
|
+
)
|
|
2742
|
+
);
|
|
2743
|
+
}).join("\n");
|
|
2744
|
+
}
|
|
2745
|
+
if (entry.modules?.length) {
|
|
2746
|
+
line += "\n" + entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
2747
|
+
return colors.gray(
|
|
2748
|
+
" \u{1F4E6} " + rPath(m.id) + colors.bold(m.bytes ? ` (${prettyBytes(m.bytes)})` : "")
|
|
2749
|
+
);
|
|
2750
|
+
}).join("\n");
|
|
2751
|
+
}
|
|
2752
|
+
consola.log(entry.chunk ? colors.gray(line) : line);
|
|
2753
|
+
}
|
|
2754
|
+
console.log(
|
|
2755
|
+
"\u03A3 Total dist size (byte size):",
|
|
2756
|
+
colors.cyan(
|
|
2757
|
+
prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))
|
|
2758
|
+
)
|
|
2759
|
+
);
|
|
2760
|
+
validateDependencies(ctx);
|
|
2761
|
+
validatePackage(pkg, rootDir, ctx);
|
|
2762
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
2763
|
+
consola.log("");
|
|
2764
|
+
if (ctx.warnings.size > 0) {
|
|
2765
|
+
consola.warn(
|
|
2766
|
+
"Build is done with some warnings:\n\n" + [...ctx.warnings].map((msg) => "- " + msg).join("\n")
|
|
2767
|
+
);
|
|
2768
|
+
if (ctx.options.failOnWarn) {
|
|
2769
|
+
consola.error(
|
|
2770
|
+
"Exiting with code (1). You can change this behavior by setting `failOnWarn: false` ."
|
|
2771
|
+
);
|
|
2772
|
+
process.exit(1);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
__name(_build, "_build");
|
|
2777
|
+
|
|
2778
|
+
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/index.mjs
|
|
2779
|
+
import "node:module";
|
|
2780
|
+
import "node:fs";
|
|
2781
|
+
import "pathe";
|
|
2782
|
+
import "consola/utils";
|
|
2783
|
+
import "consola";
|
|
2784
|
+
import "defu";
|
|
2785
|
+
import "hookable";
|
|
2786
|
+
import "pretty-bytes";
|
|
2787
|
+
import "tinyglobby";
|
|
2788
|
+
import "node:fs/promises";
|
|
2789
|
+
import "jiti";
|
|
2790
|
+
import "rollup";
|
|
2791
|
+
import "rollup-plugin-dts";
|
|
2792
|
+
import "@rollup/plugin-commonjs";
|
|
2793
|
+
import "@rollup/plugin-node-resolve";
|
|
2794
|
+
import "@rollup/plugin-alias";
|
|
2795
|
+
import "@rollup/plugin-replace";
|
|
2796
|
+
import "pathe/utils";
|
|
2797
|
+
import "mlly";
|
|
2798
|
+
import "esbuild";
|
|
2799
|
+
import "@rollup/pluginutils";
|
|
2800
|
+
import "@rollup/plugin-json";
|
|
2801
|
+
import "magic-string";
|
|
2802
|
+
import "untyped";
|
|
2803
|
+
import "untyped/babel-plugin";
|
|
2804
|
+
import "scule";
|
|
2805
|
+
import "mkdist";
|
|
1387
2806
|
|
|
1388
2807
|
// src/clean.ts
|
|
1389
2808
|
import { rm } from "node:fs/promises";
|
|
@@ -1445,29 +2864,29 @@ ${error ? error.message : "Unknown build error"}
|
|
|
1445
2864
|
}), "onErrorPlugin");
|
|
1446
2865
|
|
|
1447
2866
|
// src/plugins/tsc.ts
|
|
1448
|
-
import { readCachedProjectGraph } from "@nx/devkit";
|
|
2867
|
+
import { readCachedProjectGraph as readCachedProjectGraph3 } from "@nx/devkit";
|
|
1449
2868
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1450
2869
|
import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
|
|
1451
2870
|
|
|
1452
2871
|
// ../../node_modules/.pnpm/rollup-plugin-typescript2@0.36.0_rollup@4.29.1_typescript@5.7.3/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.es.js
|
|
1453
2872
|
import * as require$$0 from "path";
|
|
1454
|
-
import require$$0__default, { dirname, normalize as
|
|
2873
|
+
import require$$0__default, { dirname as dirname2, normalize as normalize3, resolve as resolve2, relative as relative3 } from "path";
|
|
1455
2874
|
import { normalizePath, createFilter as createFilter$1 } from "@rollup/pluginutils";
|
|
1456
2875
|
import require$$2 from "util";
|
|
1457
2876
|
import require$$0$1 from "os";
|
|
1458
2877
|
import require$$3, { satisfies } from "semver";
|
|
1459
|
-
import require$$0$2, { existsSync as
|
|
2878
|
+
import require$$0$2, { existsSync as existsSync6, readdirSync as readdirSync2, renameSync, readFileSync as readFileSync2 } from "fs";
|
|
1460
2879
|
import * as fs$4 from "fs-extra";
|
|
1461
2880
|
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync as removeSync2 } from "fs-extra";
|
|
1462
2881
|
import require$$0$3 from "crypto";
|
|
1463
2882
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1464
2883
|
function adopt(value) {
|
|
1465
|
-
return value instanceof P ? value : new P(function(
|
|
1466
|
-
|
|
2884
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
2885
|
+
resolve3(value);
|
|
1467
2886
|
});
|
|
1468
2887
|
}
|
|
1469
2888
|
__name(adopt, "adopt");
|
|
1470
|
-
return new (P || (P = Promise))(function(
|
|
2889
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1471
2890
|
function fulfilled(value) {
|
|
1472
2891
|
try {
|
|
1473
2892
|
step(generator.next(value));
|
|
@@ -1485,7 +2904,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
1485
2904
|
}
|
|
1486
2905
|
__name(rejected, "rejected");
|
|
1487
2906
|
function step(result) {
|
|
1488
|
-
result.done ?
|
|
2907
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1489
2908
|
}
|
|
1490
2909
|
__name(step, "step");
|
|
1491
2910
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -1496,7 +2915,7 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
|
|
|
1496
2915
|
var safe = {
|
|
1497
2916
|
exports: {}
|
|
1498
2917
|
};
|
|
1499
|
-
var
|
|
2918
|
+
var colors2 = {
|
|
1500
2919
|
exports: {}
|
|
1501
2920
|
};
|
|
1502
2921
|
var styles = {
|
|
@@ -2213,16 +3632,16 @@ function requireAmerica() {
|
|
|
2213
3632
|
if (hasRequiredAmerica) return america.exports;
|
|
2214
3633
|
hasRequiredAmerica = 1;
|
|
2215
3634
|
(function(module) {
|
|
2216
|
-
module["exports"] = function(
|
|
3635
|
+
module["exports"] = function(colors3) {
|
|
2217
3636
|
return function(letter, i, exploded) {
|
|
2218
3637
|
if (letter === " ") return letter;
|
|
2219
3638
|
switch (i % 3) {
|
|
2220
3639
|
case 0:
|
|
2221
|
-
return
|
|
3640
|
+
return colors3.red(letter);
|
|
2222
3641
|
case 1:
|
|
2223
|
-
return
|
|
3642
|
+
return colors3.white(letter);
|
|
2224
3643
|
case 2:
|
|
2225
|
-
return
|
|
3644
|
+
return colors3.blue(letter);
|
|
2226
3645
|
}
|
|
2227
3646
|
};
|
|
2228
3647
|
};
|
|
@@ -2238,9 +3657,9 @@ function requireZebra() {
|
|
|
2238
3657
|
if (hasRequiredZebra) return zebra.exports;
|
|
2239
3658
|
hasRequiredZebra = 1;
|
|
2240
3659
|
(function(module) {
|
|
2241
|
-
module["exports"] = function(
|
|
3660
|
+
module["exports"] = function(colors3) {
|
|
2242
3661
|
return function(letter, i, exploded) {
|
|
2243
|
-
return i % 2 === 0 ? letter :
|
|
3662
|
+
return i % 2 === 0 ? letter : colors3.inverse(letter);
|
|
2244
3663
|
};
|
|
2245
3664
|
};
|
|
2246
3665
|
})(zebra);
|
|
@@ -2255,7 +3674,7 @@ function requireRainbow() {
|
|
|
2255
3674
|
if (hasRequiredRainbow) return rainbow.exports;
|
|
2256
3675
|
hasRequiredRainbow = 1;
|
|
2257
3676
|
(function(module) {
|
|
2258
|
-
module["exports"] = function(
|
|
3677
|
+
module["exports"] = function(colors3) {
|
|
2259
3678
|
var rainbowColors = [
|
|
2260
3679
|
"red",
|
|
2261
3680
|
"yellow",
|
|
@@ -2267,7 +3686,7 @@ function requireRainbow() {
|
|
|
2267
3686
|
if (letter === " ") {
|
|
2268
3687
|
return letter;
|
|
2269
3688
|
} else {
|
|
2270
|
-
return
|
|
3689
|
+
return colors3[rainbowColors[i++ % rainbowColors.length]](letter);
|
|
2271
3690
|
}
|
|
2272
3691
|
};
|
|
2273
3692
|
};
|
|
@@ -2283,7 +3702,7 @@ function requireRandom() {
|
|
|
2283
3702
|
if (hasRequiredRandom) return random.exports;
|
|
2284
3703
|
hasRequiredRandom = 1;
|
|
2285
3704
|
(function(module) {
|
|
2286
|
-
module["exports"] = function(
|
|
3705
|
+
module["exports"] = function(colors3) {
|
|
2287
3706
|
var available = [
|
|
2288
3707
|
"underline",
|
|
2289
3708
|
"inverse",
|
|
@@ -2304,7 +3723,7 @@ function requireRandom() {
|
|
|
2304
3723
|
"brightMagenta"
|
|
2305
3724
|
];
|
|
2306
3725
|
return function(letter, i, exploded) {
|
|
2307
|
-
return letter === " " ? letter :
|
|
3726
|
+
return letter === " " ? letter : colors3[available[Math.round(Math.random() * (available.length - 2))]](letter);
|
|
2308
3727
|
};
|
|
2309
3728
|
};
|
|
2310
3729
|
})(random);
|
|
@@ -2312,33 +3731,33 @@ function requireRandom() {
|
|
|
2312
3731
|
}
|
|
2313
3732
|
__name(requireRandom, "requireRandom");
|
|
2314
3733
|
(function(module) {
|
|
2315
|
-
var
|
|
2316
|
-
module["exports"] =
|
|
2317
|
-
|
|
3734
|
+
var colors3 = {};
|
|
3735
|
+
module["exports"] = colors3;
|
|
3736
|
+
colors3.themes = {};
|
|
2318
3737
|
var util = require$$2;
|
|
2319
|
-
var ansiStyles =
|
|
3738
|
+
var ansiStyles = colors3.styles = styles.exports;
|
|
2320
3739
|
var defineProps = Object.defineProperties;
|
|
2321
3740
|
var newLineRegex = new RegExp(/[\r\n]+/g);
|
|
2322
|
-
|
|
2323
|
-
if (typeof
|
|
2324
|
-
|
|
3741
|
+
colors3.supportsColor = supportsColors.supportsColor;
|
|
3742
|
+
if (typeof colors3.enabled === "undefined") {
|
|
3743
|
+
colors3.enabled = colors3.supportsColor() !== false;
|
|
2325
3744
|
}
|
|
2326
|
-
|
|
2327
|
-
|
|
3745
|
+
colors3.enable = function() {
|
|
3746
|
+
colors3.enabled = true;
|
|
2328
3747
|
};
|
|
2329
|
-
|
|
2330
|
-
|
|
3748
|
+
colors3.disable = function() {
|
|
3749
|
+
colors3.enabled = false;
|
|
2331
3750
|
};
|
|
2332
|
-
|
|
3751
|
+
colors3.stripColors = colors3.strip = function(str) {
|
|
2333
3752
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
2334
3753
|
};
|
|
2335
|
-
|
|
2336
|
-
if (!
|
|
3754
|
+
colors3.stylize = /* @__PURE__ */ __name(function stylize(str, style) {
|
|
3755
|
+
if (!colors3.enabled) {
|
|
2337
3756
|
return str + "";
|
|
2338
3757
|
}
|
|
2339
3758
|
var styleMap = ansiStyles[style];
|
|
2340
|
-
if (!styleMap && style in
|
|
2341
|
-
return
|
|
3759
|
+
if (!styleMap && style in colors3) {
|
|
3760
|
+
return colors3[style](str);
|
|
2342
3761
|
}
|
|
2343
3762
|
return styleMap.open + str + styleMap.close;
|
|
2344
3763
|
}, "stylize");
|
|
@@ -2349,7 +3768,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2349
3768
|
}
|
|
2350
3769
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
2351
3770
|
}, "escapeStringRegexp");
|
|
2352
|
-
function
|
|
3771
|
+
function build3(_styles) {
|
|
2353
3772
|
var builder = /* @__PURE__ */ __name(function builder2() {
|
|
2354
3773
|
return applyStyle.apply(builder2, arguments);
|
|
2355
3774
|
}, "builder");
|
|
@@ -2357,7 +3776,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2357
3776
|
builder.__proto__ = proto;
|
|
2358
3777
|
return builder;
|
|
2359
3778
|
}
|
|
2360
|
-
__name(
|
|
3779
|
+
__name(build3, "build");
|
|
2361
3780
|
var styles$1 = function() {
|
|
2362
3781
|
var ret = {};
|
|
2363
3782
|
ansiStyles.grey = ansiStyles.gray;
|
|
@@ -2365,13 +3784,13 @@ __name(requireRandom, "requireRandom");
|
|
|
2365
3784
|
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
|
|
2366
3785
|
ret[key] = {
|
|
2367
3786
|
get: /* @__PURE__ */ __name(function() {
|
|
2368
|
-
return
|
|
3787
|
+
return build3(this._styles.concat(key));
|
|
2369
3788
|
}, "get")
|
|
2370
3789
|
};
|
|
2371
3790
|
});
|
|
2372
3791
|
return ret;
|
|
2373
3792
|
}();
|
|
2374
|
-
var proto = defineProps(/* @__PURE__ */ __name(function
|
|
3793
|
+
var proto = defineProps(/* @__PURE__ */ __name(function colors4() {
|
|
2375
3794
|
}, "colors"), styles$1);
|
|
2376
3795
|
function applyStyle() {
|
|
2377
3796
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -2382,7 +3801,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2382
3801
|
return util.inspect(arg);
|
|
2383
3802
|
}
|
|
2384
3803
|
}).join(" ");
|
|
2385
|
-
if (!
|
|
3804
|
+
if (!colors3.enabled || !str) {
|
|
2386
3805
|
return str;
|
|
2387
3806
|
}
|
|
2388
3807
|
var newLinesPresent = str.indexOf("\n") != -1;
|
|
@@ -2400,22 +3819,22 @@ __name(requireRandom, "requireRandom");
|
|
|
2400
3819
|
return str;
|
|
2401
3820
|
}
|
|
2402
3821
|
__name(applyStyle, "applyStyle");
|
|
2403
|
-
|
|
3822
|
+
colors3.setTheme = function(theme) {
|
|
2404
3823
|
if (typeof theme === "string") {
|
|
2405
3824
|
console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");
|
|
2406
3825
|
return;
|
|
2407
3826
|
}
|
|
2408
3827
|
for (var style in theme) {
|
|
2409
3828
|
(function(style2) {
|
|
2410
|
-
|
|
3829
|
+
colors3[style2] = function(str) {
|
|
2411
3830
|
if (typeof theme[style2] === "object") {
|
|
2412
3831
|
var out = str;
|
|
2413
3832
|
for (var i in theme[style2]) {
|
|
2414
|
-
out =
|
|
3833
|
+
out = colors3[theme[style2][i]](out);
|
|
2415
3834
|
}
|
|
2416
3835
|
return out;
|
|
2417
3836
|
}
|
|
2418
|
-
return
|
|
3837
|
+
return colors3[theme[style2]](str);
|
|
2419
3838
|
};
|
|
2420
3839
|
})(style);
|
|
2421
3840
|
}
|
|
@@ -2425,7 +3844,7 @@ __name(requireRandom, "requireRandom");
|
|
|
2425
3844
|
Object.keys(styles$1).forEach(function(name) {
|
|
2426
3845
|
ret[name] = {
|
|
2427
3846
|
get: /* @__PURE__ */ __name(function() {
|
|
2428
|
-
return
|
|
3847
|
+
return build3([
|
|
2429
3848
|
name
|
|
2430
3849
|
]);
|
|
2431
3850
|
}, "get")
|
|
@@ -2439,24 +3858,24 @@ __name(requireRandom, "requireRandom");
|
|
|
2439
3858
|
exploded = exploded.map(map2);
|
|
2440
3859
|
return exploded.join("");
|
|
2441
3860
|
}, "sequencer");
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
for (var map in
|
|
3861
|
+
colors3.trap = requireTrap();
|
|
3862
|
+
colors3.zalgo = requireZalgo();
|
|
3863
|
+
colors3.maps = {};
|
|
3864
|
+
colors3.maps.america = requireAmerica()(colors3);
|
|
3865
|
+
colors3.maps.zebra = requireZebra()(colors3);
|
|
3866
|
+
colors3.maps.rainbow = requireRainbow()(colors3);
|
|
3867
|
+
colors3.maps.random = requireRandom()(colors3);
|
|
3868
|
+
for (var map in colors3.maps) {
|
|
2450
3869
|
(function(map2) {
|
|
2451
|
-
|
|
2452
|
-
return sequencer(
|
|
3870
|
+
colors3[map2] = function(str) {
|
|
3871
|
+
return sequencer(colors3.maps[map2], str);
|
|
2453
3872
|
};
|
|
2454
3873
|
})(map);
|
|
2455
3874
|
}
|
|
2456
|
-
defineProps(
|
|
2457
|
-
})(
|
|
3875
|
+
defineProps(colors3, init());
|
|
3876
|
+
})(colors2);
|
|
2458
3877
|
(function(module) {
|
|
2459
|
-
var colors$1 =
|
|
3878
|
+
var colors$1 = colors2.exports;
|
|
2460
3879
|
module["exports"] = colors$1;
|
|
2461
3880
|
})(safe);
|
|
2462
3881
|
var path$4 = require$$0__default;
|
|
@@ -2496,8 +3915,8 @@ var pLimit$2 = {
|
|
|
2496
3915
|
var pTry$2 = {
|
|
2497
3916
|
exports: {}
|
|
2498
3917
|
};
|
|
2499
|
-
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((
|
|
2500
|
-
|
|
3918
|
+
var pTry$1 = /* @__PURE__ */ __name((fn, ...arguments_) => new Promise((resolve3) => {
|
|
3919
|
+
resolve3(fn(...arguments_));
|
|
2501
3920
|
}), "pTry$1");
|
|
2502
3921
|
pTry$2.exports = pTry$1;
|
|
2503
3922
|
pTry$2.exports.default = pTry$1;
|
|
@@ -2514,20 +3933,20 @@ var pLimit$1 = /* @__PURE__ */ __name((concurrency) => {
|
|
|
2514
3933
|
queue.shift()();
|
|
2515
3934
|
}
|
|
2516
3935
|
}, "next");
|
|
2517
|
-
const run = /* @__PURE__ */ __name((fn,
|
|
3936
|
+
const run = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2518
3937
|
activeCount++;
|
|
2519
3938
|
const result = pTry(fn, ...args);
|
|
2520
|
-
|
|
3939
|
+
resolve3(result);
|
|
2521
3940
|
result.then(next, next);
|
|
2522
3941
|
}, "run");
|
|
2523
|
-
const enqueue = /* @__PURE__ */ __name((fn,
|
|
3942
|
+
const enqueue = /* @__PURE__ */ __name((fn, resolve3, ...args) => {
|
|
2524
3943
|
if (activeCount < concurrency) {
|
|
2525
|
-
run(fn,
|
|
3944
|
+
run(fn, resolve3, ...args);
|
|
2526
3945
|
} else {
|
|
2527
|
-
queue.push(run.bind(null, fn,
|
|
3946
|
+
queue.push(run.bind(null, fn, resolve3, ...args));
|
|
2528
3947
|
}
|
|
2529
3948
|
}, "enqueue");
|
|
2530
|
-
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((
|
|
3949
|
+
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve3) => enqueue(fn, resolve3, ...args)), "generator");
|
|
2531
3950
|
Object.defineProperties(generator, {
|
|
2532
3951
|
activeCount: {
|
|
2533
3952
|
get: /* @__PURE__ */ __name(() => activeCount, "get")
|
|
@@ -2770,12 +4189,12 @@ var checkPath = /* @__PURE__ */ __name((pth) => {
|
|
|
2770
4189
|
}
|
|
2771
4190
|
}, "checkPath");
|
|
2772
4191
|
var processOptions = /* @__PURE__ */ __name((options) => {
|
|
2773
|
-
const
|
|
4192
|
+
const defaults2 = {
|
|
2774
4193
|
mode: 511 & ~process.umask(),
|
|
2775
4194
|
fs: fs$1
|
|
2776
4195
|
};
|
|
2777
4196
|
return {
|
|
2778
|
-
...
|
|
4197
|
+
...defaults2,
|
|
2779
4198
|
...options
|
|
2780
4199
|
};
|
|
2781
4200
|
}, "processOptions");
|
|
@@ -2790,11 +4209,11 @@ var permissionError = /* @__PURE__ */ __name((pth) => {
|
|
|
2790
4209
|
var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
2791
4210
|
checkPath(input);
|
|
2792
4211
|
options = processOptions(options);
|
|
2793
|
-
const
|
|
4212
|
+
const mkdir2 = promisify(options.fs.mkdir);
|
|
2794
4213
|
const stat = promisify(options.fs.stat);
|
|
2795
4214
|
if (useNativeRecursiveOption && options.fs.mkdir === fs$1.mkdir) {
|
|
2796
4215
|
const pth = path$1.resolve(input);
|
|
2797
|
-
await
|
|
4216
|
+
await mkdir2(pth, {
|
|
2798
4217
|
mode: options.mode,
|
|
2799
4218
|
recursive: true
|
|
2800
4219
|
});
|
|
@@ -2802,7 +4221,7 @@ var makeDir$1 = /* @__PURE__ */ __name(async (input, options) => {
|
|
|
2802
4221
|
}
|
|
2803
4222
|
const make = /* @__PURE__ */ __name(async (pth) => {
|
|
2804
4223
|
try {
|
|
2805
|
-
await
|
|
4224
|
+
await mkdir2(pth, options.mode);
|
|
2806
4225
|
return pth;
|
|
2807
4226
|
} catch (error) {
|
|
2808
4227
|
if (error.code === "EPERM") {
|
|
@@ -3497,11 +4916,11 @@ var lodash$1 = {
|
|
|
3497
4916
|
return result;
|
|
3498
4917
|
}
|
|
3499
4918
|
__name(arrayFilter, "arrayFilter");
|
|
3500
|
-
function
|
|
4919
|
+
function arrayIncludes2(array, value) {
|
|
3501
4920
|
var length = array == null ? 0 : array.length;
|
|
3502
4921
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
3503
4922
|
}
|
|
3504
|
-
__name(
|
|
4923
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
3505
4924
|
function arrayIncludesWith(array, value, comparator) {
|
|
3506
4925
|
var index = -1, length = array == null ? 0 : array.length;
|
|
3507
4926
|
while (++index < length) {
|
|
@@ -3750,9 +5169,9 @@ var lodash$1 = {
|
|
|
3750
5169
|
return result;
|
|
3751
5170
|
}
|
|
3752
5171
|
__name(mapToArray, "mapToArray");
|
|
3753
|
-
function overArg(func,
|
|
5172
|
+
function overArg(func, transform3) {
|
|
3754
5173
|
return function(arg) {
|
|
3755
|
-
return func(
|
|
5174
|
+
return func(transform3(arg));
|
|
3756
5175
|
};
|
|
3757
5176
|
}
|
|
3758
5177
|
__name(overArg, "overArg");
|
|
@@ -4426,7 +5845,7 @@ var lodash$1 = {
|
|
|
4426
5845
|
}
|
|
4427
5846
|
__name(baseDelay, "baseDelay");
|
|
4428
5847
|
function baseDifference(array, values2, iteratee2, comparator) {
|
|
4429
|
-
var index = -1, includes2 =
|
|
5848
|
+
var index = -1, includes2 = arrayIncludes2, isCommon = true, length = array.length, result2 = [], valuesLength = values2.length;
|
|
4430
5849
|
if (!length) {
|
|
4431
5850
|
return result2;
|
|
4432
5851
|
}
|
|
@@ -4581,7 +6000,7 @@ var lodash$1 = {
|
|
|
4581
6000
|
}
|
|
4582
6001
|
__name(baseInRange, "baseInRange");
|
|
4583
6002
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
4584
|
-
var includes2 = comparator ? arrayIncludesWith :
|
|
6003
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes2, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array1(othLength), maxLength = Infinity, result2 = [];
|
|
4585
6004
|
while (othIndex--) {
|
|
4586
6005
|
var array = arrays[othIndex];
|
|
4587
6006
|
if (othIndex && iteratee2) {
|
|
@@ -5162,7 +6581,7 @@ var lodash$1 = {
|
|
|
5162
6581
|
}
|
|
5163
6582
|
__name(baseToString, "baseToString");
|
|
5164
6583
|
function baseUniq(array, iteratee2, comparator) {
|
|
5165
|
-
var index = -1, includes2 =
|
|
6584
|
+
var index = -1, includes2 = arrayIncludes2, length = array.length, isCommon = true, result2 = [], seen = result2;
|
|
5166
6585
|
if (comparator) {
|
|
5167
6586
|
isCommon = false;
|
|
5168
6587
|
includes2 = arrayIncludesWith;
|
|
@@ -6360,7 +7779,7 @@ var lodash$1 = {
|
|
|
6360
7779
|
return nativeObjectToString.call(value);
|
|
6361
7780
|
}
|
|
6362
7781
|
__name(objectToString, "objectToString");
|
|
6363
|
-
function overRest(func, start,
|
|
7782
|
+
function overRest(func, start, transform4) {
|
|
6364
7783
|
start = nativeMax(start === undefined$1 ? func.length - 1 : start, 0);
|
|
6365
7784
|
return function() {
|
|
6366
7785
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array1(length);
|
|
@@ -6372,7 +7791,7 @@ var lodash$1 = {
|
|
|
6372
7791
|
while (++index < start) {
|
|
6373
7792
|
otherArgs[index] = args[index];
|
|
6374
7793
|
}
|
|
6375
|
-
otherArgs[start] =
|
|
7794
|
+
otherArgs[start] = transform4(array);
|
|
6376
7795
|
return apply(func, this, otherArgs);
|
|
6377
7796
|
};
|
|
6378
7797
|
}
|
|
@@ -6473,7 +7892,7 @@ var lodash$1 = {
|
|
|
6473
7892
|
function updateWrapDetails(details, bitmask) {
|
|
6474
7893
|
arrayEach(wrapFlags, function(pair) {
|
|
6475
7894
|
var value = "_." + pair[0];
|
|
6476
|
-
if (bitmask & pair[1] && !
|
|
7895
|
+
if (bitmask & pair[1] && !arrayIncludes2(details, value)) {
|
|
6477
7896
|
details.push(value);
|
|
6478
7897
|
}
|
|
6479
7898
|
});
|
|
@@ -6684,10 +8103,10 @@ var lodash$1 = {
|
|
|
6684
8103
|
}
|
|
6685
8104
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined$1, comparator) : [];
|
|
6686
8105
|
});
|
|
6687
|
-
function
|
|
8106
|
+
function join5(array, separator) {
|
|
6688
8107
|
return array == null ? "" : nativeJoin.call(array, separator);
|
|
6689
8108
|
}
|
|
6690
|
-
__name(
|
|
8109
|
+
__name(join5, "join");
|
|
6691
8110
|
function last(array) {
|
|
6692
8111
|
var length = array == null ? 0 : array.length;
|
|
6693
8112
|
return length ? array[length - 1] : undefined$1;
|
|
@@ -7792,7 +9211,7 @@ var lodash$1 = {
|
|
|
7792
9211
|
return properties == null ? result2 : baseAssign(result2, properties);
|
|
7793
9212
|
}
|
|
7794
9213
|
__name(create, "create");
|
|
7795
|
-
var
|
|
9214
|
+
var defaults2 = baseRest(function(object, sources) {
|
|
7796
9215
|
object = Object1(object);
|
|
7797
9216
|
var index = -1;
|
|
7798
9217
|
var length = sources.length;
|
|
@@ -7987,7 +9406,7 @@ var lodash$1 = {
|
|
|
7987
9406
|
__name(setWith, "setWith");
|
|
7988
9407
|
var toPairs = createToPairs(keys);
|
|
7989
9408
|
var toPairsIn = createToPairs(keysIn);
|
|
7990
|
-
function
|
|
9409
|
+
function transform3(object, iteratee2, accumulator) {
|
|
7991
9410
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
7992
9411
|
iteratee2 = getIteratee(iteratee2, 4);
|
|
7993
9412
|
if (accumulator == null) {
|
|
@@ -8005,7 +9424,7 @@ var lodash$1 = {
|
|
|
8005
9424
|
});
|
|
8006
9425
|
return accumulator;
|
|
8007
9426
|
}
|
|
8008
|
-
__name(
|
|
9427
|
+
__name(transform3, "transform");
|
|
8009
9428
|
function unset(object, path3) {
|
|
8010
9429
|
return object == null ? true : baseUnset(object, path3);
|
|
8011
9430
|
}
|
|
@@ -8175,11 +9594,11 @@ var lodash$1 = {
|
|
|
8175
9594
|
return baseRepeat(toString(string), n);
|
|
8176
9595
|
}
|
|
8177
9596
|
__name(repeat, "repeat");
|
|
8178
|
-
function
|
|
9597
|
+
function replace2() {
|
|
8179
9598
|
var args = arguments, string = toString(args[0]);
|
|
8180
9599
|
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
8181
9600
|
}
|
|
8182
|
-
__name(
|
|
9601
|
+
__name(replace2, "replace");
|
|
8183
9602
|
var snakeCase = createCompounder(function(result2, word, index) {
|
|
8184
9603
|
return result2 + (index ? "_" : "") + word.toLowerCase();
|
|
8185
9604
|
});
|
|
@@ -8632,7 +10051,7 @@ var lodash$1 = {
|
|
|
8632
10051
|
lodash2.curry = curry;
|
|
8633
10052
|
lodash2.curryRight = curryRight;
|
|
8634
10053
|
lodash2.debounce = debounce;
|
|
8635
|
-
lodash2.defaults =
|
|
10054
|
+
lodash2.defaults = defaults2;
|
|
8636
10055
|
lodash2.defaultsDeep = defaultsDeep;
|
|
8637
10056
|
lodash2.defer = defer;
|
|
8638
10057
|
lodash2.delay = delay;
|
|
@@ -8732,7 +10151,7 @@ var lodash$1 = {
|
|
|
8732
10151
|
lodash2.toPairsIn = toPairsIn;
|
|
8733
10152
|
lodash2.toPath = toPath;
|
|
8734
10153
|
lodash2.toPlainObject = toPlainObject;
|
|
8735
|
-
lodash2.transform =
|
|
10154
|
+
lodash2.transform = transform3;
|
|
8736
10155
|
lodash2.unary = unary;
|
|
8737
10156
|
lodash2.union = union;
|
|
8738
10157
|
lodash2.unionBy = unionBy;
|
|
@@ -8842,7 +10261,7 @@ var lodash$1 = {
|
|
|
8842
10261
|
lodash2.isUndefined = isUndefined;
|
|
8843
10262
|
lodash2.isWeakMap = isWeakMap;
|
|
8844
10263
|
lodash2.isWeakSet = isWeakSet;
|
|
8845
|
-
lodash2.join =
|
|
10264
|
+
lodash2.join = join5;
|
|
8846
10265
|
lodash2.kebabCase = kebabCase;
|
|
8847
10266
|
lodash2.last = last;
|
|
8848
10267
|
lodash2.lastIndexOf = lastIndexOf;
|
|
@@ -8874,7 +10293,7 @@ var lodash$1 = {
|
|
|
8874
10293
|
lodash2.reduce = reduce;
|
|
8875
10294
|
lodash2.reduceRight = reduceRight;
|
|
8876
10295
|
lodash2.repeat = repeat;
|
|
8877
|
-
lodash2.replace =
|
|
10296
|
+
lodash2.replace = replace2;
|
|
8878
10297
|
lodash2.result = result;
|
|
8879
10298
|
lodash2.round = round;
|
|
8880
10299
|
lodash2.runInContext = runInContext2;
|
|
@@ -10266,9 +11685,9 @@ var hasRequired_overArg;
|
|
|
10266
11685
|
function require_overArg() {
|
|
10267
11686
|
if (hasRequired_overArg) return _overArg;
|
|
10268
11687
|
hasRequired_overArg = 1;
|
|
10269
|
-
function overArg(func,
|
|
11688
|
+
function overArg(func, transform3) {
|
|
10270
11689
|
return function(arg) {
|
|
10271
|
-
return func(
|
|
11690
|
+
return func(transform3(arg));
|
|
10272
11691
|
};
|
|
10273
11692
|
}
|
|
10274
11693
|
__name(overArg, "overArg");
|
|
@@ -12389,7 +13808,7 @@ function requireTransform() {
|
|
|
12389
13808
|
if (hasRequiredTransform) return transform_1;
|
|
12390
13809
|
hasRequiredTransform = 1;
|
|
12391
13810
|
var arrayEach = require_arrayEach(), baseCreate = require_baseCreate(), baseForOwn = require_baseForOwn(), baseIteratee = require_baseIteratee(), getPrototype = require_getPrototype(), isArray = requireIsArray(), isBuffer2 = requireIsBuffer(), isFunction = requireIsFunction(), isObject = requireIsObject(), isTypedArray = requireIsTypedArray();
|
|
12392
|
-
function
|
|
13811
|
+
function transform3(object, iteratee, accumulator) {
|
|
12393
13812
|
var isArr = isArray(object), isArrLike = isArr || isBuffer2(object) || isTypedArray(object);
|
|
12394
13813
|
iteratee = baseIteratee(iteratee, 4);
|
|
12395
13814
|
if (accumulator == null) {
|
|
@@ -12407,8 +13826,8 @@ function requireTransform() {
|
|
|
12407
13826
|
});
|
|
12408
13827
|
return accumulator;
|
|
12409
13828
|
}
|
|
12410
|
-
__name(
|
|
12411
|
-
transform_1 =
|
|
13829
|
+
__name(transform3, "transform");
|
|
13830
|
+
transform_1 = transform3;
|
|
12412
13831
|
return transform_1;
|
|
12413
13832
|
}
|
|
12414
13833
|
__name(requireTransform, "requireTransform");
|
|
@@ -12486,7 +13905,7 @@ function require_overRest() {
|
|
|
12486
13905
|
hasRequired_overRest = 1;
|
|
12487
13906
|
var apply = require_apply();
|
|
12488
13907
|
var nativeMax = Math.max;
|
|
12489
|
-
function overRest(func, start,
|
|
13908
|
+
function overRest(func, start, transform3) {
|
|
12490
13909
|
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
12491
13910
|
return function() {
|
|
12492
13911
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
|
|
@@ -12498,7 +13917,7 @@ function require_overRest() {
|
|
|
12498
13917
|
while (++index < start) {
|
|
12499
13918
|
otherArgs[index] = args[index];
|
|
12500
13919
|
}
|
|
12501
|
-
otherArgs[start] =
|
|
13920
|
+
otherArgs[start] = transform3(array);
|
|
12502
13921
|
return apply(func, this, otherArgs);
|
|
12503
13922
|
};
|
|
12504
13923
|
}
|
|
@@ -12648,12 +14067,12 @@ function require_arrayIncludes() {
|
|
|
12648
14067
|
if (hasRequired_arrayIncludes) return _arrayIncludes;
|
|
12649
14068
|
hasRequired_arrayIncludes = 1;
|
|
12650
14069
|
var baseIndexOf = require_baseIndexOf();
|
|
12651
|
-
function
|
|
14070
|
+
function arrayIncludes2(array, value) {
|
|
12652
14071
|
var length = array == null ? 0 : array.length;
|
|
12653
14072
|
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
12654
14073
|
}
|
|
12655
|
-
__name(
|
|
12656
|
-
_arrayIncludes =
|
|
14074
|
+
__name(arrayIncludes2, "arrayIncludes");
|
|
14075
|
+
_arrayIncludes = arrayIncludes2;
|
|
12657
14076
|
return _arrayIncludes;
|
|
12658
14077
|
}
|
|
12659
14078
|
__name(require_arrayIncludes, "require_arrayIncludes");
|
|
@@ -12710,10 +14129,10 @@ var hasRequired_baseUniq;
|
|
|
12710
14129
|
function require_baseUniq() {
|
|
12711
14130
|
if (hasRequired_baseUniq) return _baseUniq;
|
|
12712
14131
|
hasRequired_baseUniq = 1;
|
|
12713
|
-
var SetCache = require_SetCache(),
|
|
14132
|
+
var SetCache = require_SetCache(), arrayIncludes2 = require_arrayIncludes(), arrayIncludesWith = require_arrayIncludesWith(), cacheHas = require_cacheHas(), createSet = require_createSet(), setToArray = require_setToArray();
|
|
12714
14133
|
var LARGE_ARRAY_SIZE = 200;
|
|
12715
14134
|
function baseUniq(array, iteratee, comparator) {
|
|
12716
|
-
var index = -1, includes =
|
|
14135
|
+
var index = -1, includes = arrayIncludes2, length = array.length, isCommon = true, result = [], seen = result;
|
|
12717
14136
|
if (comparator) {
|
|
12718
14137
|
isCommon = false;
|
|
12719
14138
|
includes = arrayIncludesWith;
|
|
@@ -13048,27 +14467,27 @@ Graph$2.prototype.isLeaf = function(v) {
|
|
|
13048
14467
|
return neighbors.length === 0;
|
|
13049
14468
|
};
|
|
13050
14469
|
Graph$2.prototype.filterNodes = function(filter) {
|
|
13051
|
-
var
|
|
14470
|
+
var copy2 = new this.constructor({
|
|
13052
14471
|
directed: this._isDirected,
|
|
13053
14472
|
multigraph: this._isMultigraph,
|
|
13054
14473
|
compound: this._isCompound
|
|
13055
14474
|
});
|
|
13056
|
-
|
|
14475
|
+
copy2.setGraph(this.graph());
|
|
13057
14476
|
var self1 = this;
|
|
13058
14477
|
_$b.each(this._nodes, function(value, v) {
|
|
13059
14478
|
if (filter(v)) {
|
|
13060
|
-
|
|
14479
|
+
copy2.setNode(v, value);
|
|
13061
14480
|
}
|
|
13062
14481
|
});
|
|
13063
14482
|
_$b.each(this._edgeObjs, function(e) {
|
|
13064
|
-
if (
|
|
13065
|
-
|
|
14483
|
+
if (copy2.hasNode(e.v) && copy2.hasNode(e.w)) {
|
|
14484
|
+
copy2.setEdge(e, self1.edge(e));
|
|
13066
14485
|
}
|
|
13067
14486
|
});
|
|
13068
14487
|
var parents = {};
|
|
13069
14488
|
function findParent(v) {
|
|
13070
14489
|
var parent = self1.parent(v);
|
|
13071
|
-
if (parent === void 0 ||
|
|
14490
|
+
if (parent === void 0 || copy2.hasNode(parent)) {
|
|
13072
14491
|
parents[v] = parent;
|
|
13073
14492
|
return parent;
|
|
13074
14493
|
} else if (parent in parents) {
|
|
@@ -13079,11 +14498,11 @@ Graph$2.prototype.filterNodes = function(filter) {
|
|
|
13079
14498
|
}
|
|
13080
14499
|
__name(findParent, "findParent");
|
|
13081
14500
|
if (this._isCompound) {
|
|
13082
|
-
_$b.each(
|
|
13083
|
-
|
|
14501
|
+
_$b.each(copy2.nodes(), function(v) {
|
|
14502
|
+
copy2.setParent(v, findParent(v));
|
|
13084
14503
|
});
|
|
13085
14504
|
}
|
|
13086
|
-
return
|
|
14505
|
+
return copy2;
|
|
13087
14506
|
};
|
|
13088
14507
|
Graph$2.prototype.setDefaultEdgeLabel = function(newDefault) {
|
|
13089
14508
|
if (!_$b.isFunction(newDefault)) {
|
|
@@ -14202,8 +15621,8 @@ var RollingCache = class RollingCache2 {
|
|
|
14202
15621
|
/** @returns true if name exists in either old cache or new cache */
|
|
14203
15622
|
exists(name) {
|
|
14204
15623
|
if (this.rolled) return false;
|
|
14205
|
-
if (
|
|
14206
|
-
return
|
|
15624
|
+
if (existsSync6(`${this.newCacheRoot}/${name}`)) return true;
|
|
15625
|
+
return existsSync6(`${this.oldCacheRoot}/${name}`);
|
|
14207
15626
|
}
|
|
14208
15627
|
path(name) {
|
|
14209
15628
|
return `${this.oldCacheRoot}/${name}`;
|
|
@@ -14211,12 +15630,12 @@ var RollingCache = class RollingCache2 {
|
|
|
14211
15630
|
/** @returns true if old cache contains all names and nothing more */
|
|
14212
15631
|
match(names) {
|
|
14213
15632
|
if (this.rolled) return false;
|
|
14214
|
-
if (!
|
|
14215
|
-
return lodash$1.exports.isEqual(
|
|
15633
|
+
if (!existsSync6(this.oldCacheRoot)) return names.length === 0;
|
|
15634
|
+
return lodash$1.exports.isEqual(readdirSync2(this.oldCacheRoot).sort(), names.sort());
|
|
14216
15635
|
}
|
|
14217
15636
|
/** @returns data for name, must exist in either old cache or new cache */
|
|
14218
15637
|
read(name) {
|
|
14219
|
-
if (
|
|
15638
|
+
if (existsSync6(`${this.newCacheRoot}/${name}`)) return readJsonSync(`${this.newCacheRoot}/${name}`, {
|
|
14220
15639
|
encoding: "utf8",
|
|
14221
15640
|
throws: false
|
|
14222
15641
|
});
|
|
@@ -14239,7 +15658,7 @@ var RollingCache = class RollingCache2 {
|
|
|
14239
15658
|
if (this.rolled) return;
|
|
14240
15659
|
this.rolled = true;
|
|
14241
15660
|
removeSync2(this.oldCacheRoot);
|
|
14242
|
-
if (
|
|
15661
|
+
if (existsSync6(this.newCacheRoot)) {
|
|
14243
15662
|
renameSync(this.newCacheRoot, this.oldCacheRoot);
|
|
14244
15663
|
}
|
|
14245
15664
|
}
|
|
@@ -14408,9 +15827,9 @@ var TsCache = class TsCache2 {
|
|
|
14408
15827
|
this.syntacticDiagnosticsCache.roll();
|
|
14409
15828
|
this.typesCache.roll();
|
|
14410
15829
|
}
|
|
14411
|
-
getCompiled(id, snapshot,
|
|
15830
|
+
getCompiled(id, snapshot, transform3) {
|
|
14412
15831
|
this.context.info(`${safe.exports.blue("transpiling")} '${id}'`);
|
|
14413
|
-
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration),
|
|
15832
|
+
return this.getCached(this.codeCache, id, snapshot, Boolean(!this.options.isolatedModules || this.options.declaration), transform3);
|
|
14414
15833
|
}
|
|
14415
15834
|
getSyntacticDiagnostics(id, snapshot, check) {
|
|
14416
15835
|
return this.getDiagnostics("syntax", this.syntacticDiagnosticsCache, id, snapshot, check);
|
|
@@ -14514,7 +15933,7 @@ function expandIncludeWithDirs(include, dirs) {
|
|
|
14514
15933
|
return newDirs;
|
|
14515
15934
|
}
|
|
14516
15935
|
__name(expandIncludeWithDirs, "expandIncludeWithDirs");
|
|
14517
|
-
function
|
|
15936
|
+
function createFilter2(context, pluginOptions, parsedConfig) {
|
|
14518
15937
|
let included = pluginOptions.include;
|
|
14519
15938
|
let excluded = pluginOptions.exclude;
|
|
14520
15939
|
if (parsedConfig.options.rootDirs) {
|
|
@@ -14533,7 +15952,7 @@ ${JSON.stringify(excluded, void 0, 4)}`);
|
|
|
14533
15952
|
resolve: parsedConfig.options.rootDir
|
|
14534
15953
|
});
|
|
14535
15954
|
}
|
|
14536
|
-
__name(
|
|
15955
|
+
__name(createFilter2, "createFilter");
|
|
14537
15956
|
function parseTsConfig(context, pluginOptions) {
|
|
14538
15957
|
var _a, _b;
|
|
14539
15958
|
const fileName = tsModule.findConfigFile(pluginOptions.cwd, tsModule.sys.fileExists, pluginOptions.tsconfig);
|
|
@@ -14553,7 +15972,7 @@ function parseTsConfig(context, pluginOptions) {
|
|
|
14553
15972
|
context.error(`failed to parse '${fileName}'`);
|
|
14554
15973
|
}
|
|
14555
15974
|
loadedConfig = result.config;
|
|
14556
|
-
baseDir =
|
|
15975
|
+
baseDir = dirname2(fileName);
|
|
14557
15976
|
configFileName = fileName;
|
|
14558
15977
|
}
|
|
14559
15978
|
const mergedConfig = {};
|
|
@@ -14704,7 +16123,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14704
16123
|
if (pluginOptions.objectHashIgnoreUnknownHack) context.warn(() => `${safe.exports.yellow("You are using 'objectHashIgnoreUnknownHack' option")}. If you enabled it because of async functions, try disabling it now.`);
|
|
14705
16124
|
if (pluginOptions.rollupCommonJSResolveHack) context.warn(() => `${safe.exports.yellow("You are using 'rollupCommonJSResolveHack' option")}. This is no longer needed, try disabling it now.`);
|
|
14706
16125
|
if (watchMode) context.info(`running in watch mode`);
|
|
14707
|
-
filter =
|
|
16126
|
+
filter = createFilter2(context, pluginOptions, parsedConfig);
|
|
14708
16127
|
servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd);
|
|
14709
16128
|
service = tsModule.createLanguageService(servicesHost, documentRegistry);
|
|
14710
16129
|
servicesHost.setLanguageService(service);
|
|
@@ -14735,7 +16154,7 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14735
16154
|
cache.setDependency(resolved, importer);
|
|
14736
16155
|
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
|
|
14737
16156
|
context.debug(() => ` to '${resolved}'`);
|
|
14738
|
-
return
|
|
16157
|
+
return normalize3(resolved);
|
|
14739
16158
|
},
|
|
14740
16159
|
load(id) {
|
|
14741
16160
|
if (id === TSLIB_VIRTUAL) return tslibSource;
|
|
@@ -14844,15 +16263,15 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14844
16263
|
let entryText = entry.text;
|
|
14845
16264
|
const cachePlaceholder = `${pluginOptions.cacheRoot}/placeholder`;
|
|
14846
16265
|
if (extension === ".d.ts.map" && ((_output === null || _output === void 0 ? void 0 : _output.file) || (_output === null || _output === void 0 ? void 0 : _output.dir))) {
|
|
14847
|
-
const declarationDir = _output.file ?
|
|
16266
|
+
const declarationDir = _output.file ? dirname2(_output.file) : _output.dir;
|
|
14848
16267
|
const parsedText = JSON.parse(entryText);
|
|
14849
16268
|
parsedText.sources = parsedText.sources.map((source) => {
|
|
14850
|
-
const absolutePath =
|
|
14851
|
-
return normalizePath(
|
|
16269
|
+
const absolutePath = resolve2(cachePlaceholder, source);
|
|
16270
|
+
return normalizePath(relative3(declarationDir, absolutePath));
|
|
14852
16271
|
});
|
|
14853
16272
|
entryText = JSON.stringify(parsedText);
|
|
14854
16273
|
}
|
|
14855
|
-
const relativePath = normalizePath(
|
|
16274
|
+
const relativePath = normalizePath(relative3(cachePlaceholder, fileName));
|
|
14856
16275
|
context.debug(() => `${safe.exports.blue("emitting declarations")} for '${key}' to '${relativePath}'`);
|
|
14857
16276
|
this.emitFile({
|
|
14858
16277
|
type: "asset",
|
|
@@ -14873,11 +16292,11 @@ ${JSON.stringify(rollupOptions, void 0, 4)}`);
|
|
|
14873
16292
|
// src/utilities/helpers.ts
|
|
14874
16293
|
import { joinPathFragments as joinPathFragments2 } from "@nx/devkit";
|
|
14875
16294
|
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
14876
|
-
import { dirname as
|
|
16295
|
+
import { dirname as dirname3, extname as extname2 } from "node:path";
|
|
14877
16296
|
import { pathToFileURL } from "node:url";
|
|
14878
16297
|
import ts from "typescript";
|
|
14879
16298
|
async function loadConfig2(configPath) {
|
|
14880
|
-
if (!/\.(js|mjs)$/.test(
|
|
16299
|
+
if (!/\.(js|mjs)$/.test(extname2(configPath))) {
|
|
14881
16300
|
throw new Error("Unsupported config file format");
|
|
14882
16301
|
}
|
|
14883
16302
|
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
@@ -14885,7 +16304,7 @@ async function loadConfig2(configPath) {
|
|
|
14885
16304
|
__name(loadConfig2, "loadConfig");
|
|
14886
16305
|
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
14887
16306
|
const tsConfigFile = ts.readConfigFile(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
14888
|
-
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys,
|
|
16307
|
+
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname3(joinPathFragments2(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
14889
16308
|
const compilerOptions = {
|
|
14890
16309
|
rootDir: projectRoot,
|
|
14891
16310
|
declaration: true,
|
|
@@ -14898,7 +16317,7 @@ __name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
|
14898
16317
|
|
|
14899
16318
|
// src/plugins/tsc.ts
|
|
14900
16319
|
var tscPlugin = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
|
|
14901
|
-
const projectGraph =
|
|
16320
|
+
const projectGraph = readCachedProjectGraph3();
|
|
14902
16321
|
const result = calculateProjectBuildableDependencies2(void 0, projectGraph, resolvedOptions.config.workspaceRoot, resolvedOptions.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
14903
16322
|
let dependencies = result.dependencies;
|
|
14904
16323
|
const tsLibDependency = getHelperDependency(HelperDependency.tsc, resolvedOptions.tsconfig, dependencies, projectGraph, true);
|
|
@@ -14916,7 +16335,7 @@ var tscPlugin = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
|
|
|
14916
16335
|
}, "tscPlugin");
|
|
14917
16336
|
|
|
14918
16337
|
// src/plugins/type-definitions.ts
|
|
14919
|
-
import { relative as
|
|
16338
|
+
import { relative as relative4 } from "node:path";
|
|
14920
16339
|
function typeDefinitions(projectRoot) {
|
|
14921
16340
|
return {
|
|
14922
16341
|
name: "storm:dts-bundle",
|
|
@@ -14926,7 +16345,7 @@ function typeDefinitions(projectRoot) {
|
|
|
14926
16345
|
continue;
|
|
14927
16346
|
}
|
|
14928
16347
|
const hasDefaultExport = file.exports.includes("default");
|
|
14929
|
-
const entrySourceFileName =
|
|
16348
|
+
const entrySourceFileName = relative4(projectRoot, file.facadeModuleId);
|
|
14930
16349
|
const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
|
|
14931
16350
|
const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
|
|
14932
16351
|
const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
|
|
@@ -14971,35 +16390,35 @@ async function resolveOptions(options) {
|
|
|
14971
16390
|
if (options.configPath) {
|
|
14972
16391
|
const configFile = await loadConfig2(options.configPath);
|
|
14973
16392
|
if (configFile) {
|
|
14974
|
-
options =
|
|
16393
|
+
options = defu4(options, configFile);
|
|
14975
16394
|
}
|
|
14976
16395
|
}
|
|
14977
|
-
const projectGraph =
|
|
16396
|
+
const projectGraph = readCachedProjectGraph4();
|
|
14978
16397
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
14979
|
-
if (!
|
|
16398
|
+
if (!existsSync7(projectJsonPath)) {
|
|
14980
16399
|
throw new Error("Cannot find project.json configuration");
|
|
14981
16400
|
}
|
|
14982
|
-
const projectJsonContent = await
|
|
16401
|
+
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
14983
16402
|
const projectJson = JSON.parse(projectJsonContent);
|
|
14984
16403
|
const projectName = projectJson.name;
|
|
14985
16404
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
14986
|
-
if (!
|
|
16405
|
+
if (!existsSync7(packageJsonPath)) {
|
|
14987
16406
|
throw new Error("Cannot find package.json configuration");
|
|
14988
16407
|
}
|
|
14989
|
-
const packageJsonContent = await
|
|
16408
|
+
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
14990
16409
|
const packageJson = JSON.parse(packageJsonContent);
|
|
14991
16410
|
let tsconfig = options.tsconfig;
|
|
14992
16411
|
if (!tsconfig) {
|
|
14993
16412
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
14994
16413
|
}
|
|
14995
|
-
if (!
|
|
16414
|
+
if (!existsSync7(tsconfig)) {
|
|
14996
16415
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
14997
16416
|
}
|
|
14998
16417
|
let sourceRoot = projectJson.sourceRoot;
|
|
14999
16418
|
if (!sourceRoot) {
|
|
15000
16419
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
15001
16420
|
}
|
|
15002
|
-
if (!
|
|
16421
|
+
if (!existsSync7(sourceRoot)) {
|
|
15003
16422
|
throw new Error("Cannot find sourceRoot directory");
|
|
15004
16423
|
}
|
|
15005
16424
|
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -15021,14 +16440,14 @@ async function resolveOptions(options) {
|
|
|
15021
16440
|
{
|
|
15022
16441
|
builder: "mkdist",
|
|
15023
16442
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
15024
|
-
outDir: joinPaths(
|
|
16443
|
+
outDir: joinPaths(relative5(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
15025
16444
|
declaration: options.emitTypes !== false,
|
|
15026
16445
|
format: "esm"
|
|
15027
16446
|
},
|
|
15028
16447
|
{
|
|
15029
16448
|
builder: "mkdist",
|
|
15030
16449
|
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
15031
|
-
outDir: joinPaths(
|
|
16450
|
+
outDir: joinPaths(relative5(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
15032
16451
|
declaration: options.emitTypes !== false,
|
|
15033
16452
|
format: "cjs",
|
|
15034
16453
|
ext: "cjs"
|
|
@@ -15101,16 +16520,16 @@ async function resolveOptions(options) {
|
|
|
15101
16520
|
resolvedOptions.peerDependencies = Object.keys(packageJson.peerDependencies);
|
|
15102
16521
|
}
|
|
15103
16522
|
if (options.rollup) {
|
|
15104
|
-
let
|
|
16523
|
+
let rollup2 = {};
|
|
15105
16524
|
if (typeof options.rollup === "string") {
|
|
15106
16525
|
const rollupFile = await loadConfig2(options.rollup);
|
|
15107
16526
|
if (rollupFile) {
|
|
15108
|
-
|
|
16527
|
+
rollup2 = rollupFile;
|
|
15109
16528
|
}
|
|
15110
16529
|
} else {
|
|
15111
|
-
|
|
16530
|
+
rollup2 = options.rollup;
|
|
15112
16531
|
}
|
|
15113
|
-
resolvedOptions.rollup =
|
|
16532
|
+
resolvedOptions.rollup = defu4(resolvedOptions.rollup ?? {}, rollup2);
|
|
15114
16533
|
}
|
|
15115
16534
|
resolvedOptions.hooks = {
|
|
15116
16535
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
@@ -15122,14 +16541,14 @@ async function resolveOptions(options) {
|
|
|
15122
16541
|
}
|
|
15123
16542
|
__name(resolveOptions, "resolveOptions");
|
|
15124
16543
|
async function generatePackageJson(options) {
|
|
15125
|
-
if (options.generatePackageJson !== false &&
|
|
16544
|
+
if (options.generatePackageJson !== false && existsSync7(joinPaths(options.projectRoot, "package.json"))) {
|
|
15126
16545
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
15127
16546
|
const stopwatch = getStopwatch("Write package.json file");
|
|
15128
16547
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
15129
|
-
if (!
|
|
16548
|
+
if (!existsSync7(packageJsonPath)) {
|
|
15130
16549
|
throw new Error("Cannot find package.json configuration");
|
|
15131
16550
|
}
|
|
15132
|
-
let packageJsonContent = await
|
|
16551
|
+
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
15133
16552
|
if (!packageJsonContent) {
|
|
15134
16553
|
throw new Error("Cannot find package.json configuration file");
|
|
15135
16554
|
}
|
|
@@ -15146,7 +16565,7 @@ async function executeUnbuild(options) {
|
|
|
15146
16565
|
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
15147
16566
|
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
15148
16567
|
try {
|
|
15149
|
-
await
|
|
16568
|
+
await build(options.projectRoot, false, {
|
|
15150
16569
|
...options,
|
|
15151
16570
|
rootDir: options.projectRoot
|
|
15152
16571
|
});
|
|
@@ -15171,7 +16590,7 @@ async function cleanOutputPath(options) {
|
|
|
15171
16590
|
return options;
|
|
15172
16591
|
}
|
|
15173
16592
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
15174
|
-
async function
|
|
16593
|
+
async function build2(options) {
|
|
15175
16594
|
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`);
|
|
15176
16595
|
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
15177
16596
|
try {
|
|
@@ -15188,7 +16607,7 @@ async function build(options) {
|
|
|
15188
16607
|
stopwatch();
|
|
15189
16608
|
}
|
|
15190
16609
|
}
|
|
15191
|
-
__name(
|
|
16610
|
+
__name(build2, "build");
|
|
15192
16611
|
|
|
15193
16612
|
// bin/unbuild.ts
|
|
15194
16613
|
async function createProgram(config) {
|
|
@@ -15266,7 +16685,7 @@ async function createProgram(config) {
|
|
|
15266
16685
|
__name(createProgram, "createProgram");
|
|
15267
16686
|
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
15268
16687
|
try {
|
|
15269
|
-
await
|
|
16688
|
+
await build2({
|
|
15270
16689
|
...options,
|
|
15271
16690
|
sourcemap: !!options.debug,
|
|
15272
16691
|
replace: {},
|