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