@storm-software/unbuild 0.20.1 → 0.21.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 +31 -42
- package/bin/unbuild.mjs +41 -52
- package/dist/build.js +2 -2
- package/dist/build.mjs +1 -1
- package/dist/{chunk-2345XTVS.js → chunk-3KCZOJ2Q.js} +18 -31
- package/dist/{chunk-WGFWMGCJ.mjs → chunk-AYFS4N2Z.mjs} +33 -46
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
package/bin/unbuild.js
CHANGED
|
@@ -1135,13 +1135,14 @@ var import_devkit2 = require("@nx/devkit");
|
|
|
1135
1135
|
var import_path = require("path");
|
|
1136
1136
|
|
|
1137
1137
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1138
|
-
var import_node2 = require("@humanfs/node");
|
|
1139
1138
|
var import_devkit3 = require("@nx/devkit");
|
|
1140
1139
|
var import_js = require("@nx/js");
|
|
1141
1140
|
var import_glob = require("glob");
|
|
1141
|
+
var import_promises2 = require("fs/promises");
|
|
1142
1142
|
|
|
1143
1143
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
1144
|
-
var
|
|
1144
|
+
var import_node_fs4 = require("fs");
|
|
1145
|
+
var import_promises = require("fs/promises");
|
|
1145
1146
|
var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
1146
1147
|
let rootDir = workspaceRoot;
|
|
1147
1148
|
if (!rootDir) {
|
|
@@ -1149,10 +1150,11 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
1149
1150
|
rootDir = config.workspaceRoot;
|
|
1150
1151
|
}
|
|
1151
1152
|
const nxJsonPath = joinPaths(rootDir, "nx.json");
|
|
1152
|
-
if (!
|
|
1153
|
+
if (!(0, import_node_fs4.existsSync)(nxJsonPath)) {
|
|
1153
1154
|
throw new Error("Cannot find project.json configuration");
|
|
1154
1155
|
}
|
|
1155
|
-
|
|
1156
|
+
const configContent = await (0, import_promises.readFile)(nxJsonPath, "utf8");
|
|
1157
|
+
return JSON.parse(configContent);
|
|
1156
1158
|
}, "readNxConfig");
|
|
1157
1159
|
|
|
1158
1160
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
@@ -1187,14 +1189,12 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1187
1189
|
});
|
|
1188
1190
|
}
|
|
1189
1191
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
1190
|
-
const projectGraph =
|
|
1191
|
-
exitOnError: true
|
|
1192
|
-
});
|
|
1192
|
+
const projectGraph = (0, import_devkit3.readCachedProjectGraph)();
|
|
1193
1193
|
const projectsConfigurations = (0, import_devkit3.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
1194
1194
|
if (!projectsConfigurations?.projects?.[projectName]) {
|
|
1195
1195
|
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
1196
|
}
|
|
1197
|
-
const buildTarget = projectsConfigurations.projects[projectName]
|
|
1197
|
+
const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
|
|
1198
1198
|
if (!buildTarget) {
|
|
1199
1199
|
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
1200
|
}
|
|
@@ -1224,42 +1224,30 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1224
1224
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
1225
1225
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
1226
1226
|
]);
|
|
1227
|
-
await Promise.allSettled(files.map(async (file) =>
|
|
1227
|
+
await Promise.allSettled(files.map(async (file) => (0, import_promises2.writeFile)(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
1228
1228
|
|
|
1229
|
-
${await
|
|
1229
|
+
${await (0, import_promises2.readFile)(file, "utf8")}
|
|
1230
1230
|
|
|
1231
1231
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
1232
1232
|
}
|
|
1233
1233
|
}, "copyAssets");
|
|
1234
1234
|
|
|
1235
1235
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
1236
|
-
var import_node3 = require("@humanfs/node");
|
|
1237
1236
|
var import_buildable_libs_utils = require("@nx/js/src/utils/buildable-libs-utils");
|
|
1238
1237
|
var import_glob2 = require("glob");
|
|
1238
|
+
var import_node_fs5 = require("fs");
|
|
1239
|
+
var import_promises3 = require("fs/promises");
|
|
1239
1240
|
var import_project_graph = require("nx/src/project-graph/project-graph");
|
|
1240
1241
|
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);
|
|
1242
|
+
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
1243
|
const localPackages = [];
|
|
1257
1244
|
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
1258
1245
|
const projectNode = project.node;
|
|
1259
1246
|
if (projectNode.data.root) {
|
|
1260
1247
|
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
1261
|
-
if (
|
|
1262
|
-
const
|
|
1248
|
+
if ((0, import_node_fs5.existsSync)(projectPackageJsonPath)) {
|
|
1249
|
+
const projectPackageJsonContent = await (0, import_promises3.readFile)(projectPackageJsonPath, "utf8");
|
|
1250
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
1263
1251
|
if (projectPackageJson.private !== false) {
|
|
1264
1252
|
localPackages.push(projectPackageJson);
|
|
1265
1253
|
}
|
|
@@ -1295,7 +1283,8 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1295
1283
|
}, "addPackageDependencies");
|
|
1296
1284
|
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
1297
1285
|
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
1298
|
-
const
|
|
1286
|
+
const workspacePackageJsonContent = await (0, import_promises3.readFile)(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
1287
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
1299
1288
|
packageJson.type ??= "module";
|
|
1300
1289
|
packageJson.sideEffects ??= false;
|
|
1301
1290
|
if (includeSrc === true) {
|
|
@@ -1394,18 +1383,18 @@ var import_create_task_graph = require("nx/src/tasks-runner/create-task-graph");
|
|
|
1394
1383
|
|
|
1395
1384
|
// src/build.ts
|
|
1396
1385
|
var import_defu3 = __toESM(require("defu"));
|
|
1397
|
-
var
|
|
1398
|
-
var
|
|
1386
|
+
var import_node_fs6 = require("fs");
|
|
1387
|
+
var import_promises5 = require("fs/promises");
|
|
1399
1388
|
var import_node_path6 = require("path");
|
|
1400
1389
|
var import_find_workspace_root5 = require("nx/src/utils/find-workspace-root");
|
|
1401
1390
|
var import_unbuild = require("unbuild");
|
|
1402
1391
|
|
|
1403
1392
|
// src/clean.ts
|
|
1404
|
-
var
|
|
1393
|
+
var import_promises4 = require("fs/promises");
|
|
1405
1394
|
async function clean(name = "Unbuild", directory, config) {
|
|
1406
1395
|
writeDebug(` \u{1F9F9} Cleaning ${name} output path: ${directory}`, config);
|
|
1407
1396
|
const stopwatch = getStopwatch(`${name} output clean`);
|
|
1408
|
-
await (0,
|
|
1397
|
+
await (0, import_promises4.rm)(directory, {
|
|
1409
1398
|
recursive: true,
|
|
1410
1399
|
force: true
|
|
1411
1400
|
});
|
|
@@ -14991,30 +14980,30 @@ async function resolveOptions(options) {
|
|
|
14991
14980
|
}
|
|
14992
14981
|
const projectGraph = (0, import_devkit6.readCachedProjectGraph)();
|
|
14993
14982
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
14994
|
-
if (!(0,
|
|
14983
|
+
if (!(0, import_node_fs6.existsSync)(projectJsonPath)) {
|
|
14995
14984
|
throw new Error("Cannot find project.json configuration");
|
|
14996
14985
|
}
|
|
14997
|
-
const projectJsonContent = await (0,
|
|
14986
|
+
const projectJsonContent = await (0, import_promises5.readFile)(projectJsonPath, "utf8");
|
|
14998
14987
|
const projectJson = JSON.parse(projectJsonContent);
|
|
14999
14988
|
const projectName = projectJson.name;
|
|
15000
14989
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
15001
|
-
if (!(0,
|
|
14990
|
+
if (!(0, import_node_fs6.existsSync)(packageJsonPath)) {
|
|
15002
14991
|
throw new Error("Cannot find package.json configuration");
|
|
15003
14992
|
}
|
|
15004
|
-
const packageJsonContent = await (0,
|
|
14993
|
+
const packageJsonContent = await (0, import_promises5.readFile)(packageJsonPath, "utf8");
|
|
15005
14994
|
const packageJson = JSON.parse(packageJsonContent);
|
|
15006
14995
|
let tsconfig = options.tsconfig;
|
|
15007
14996
|
if (!tsconfig) {
|
|
15008
14997
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
15009
14998
|
}
|
|
15010
|
-
if (!(0,
|
|
14999
|
+
if (!(0, import_node_fs6.existsSync)(tsconfig)) {
|
|
15011
15000
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
15012
15001
|
}
|
|
15013
15002
|
let sourceRoot = projectJson.sourceRoot;
|
|
15014
15003
|
if (!sourceRoot) {
|
|
15015
15004
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
15016
15005
|
}
|
|
15017
|
-
if (!(0,
|
|
15006
|
+
if (!(0, import_node_fs6.existsSync)(sourceRoot)) {
|
|
15018
15007
|
throw new Error("Cannot find sourceRoot directory");
|
|
15019
15008
|
}
|
|
15020
15009
|
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);
|
|
@@ -15137,14 +15126,14 @@ async function resolveOptions(options) {
|
|
|
15137
15126
|
}
|
|
15138
15127
|
__name(resolveOptions, "resolveOptions");
|
|
15139
15128
|
async function generatePackageJson(options) {
|
|
15140
|
-
if (options.generatePackageJson !== false && (0,
|
|
15129
|
+
if (options.generatePackageJson !== false && (0, import_node_fs6.existsSync)(joinPaths(options.projectRoot, "package.json"))) {
|
|
15141
15130
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
15142
15131
|
const stopwatch = getStopwatch("Write package.json file");
|
|
15143
15132
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
15144
|
-
if (!(0,
|
|
15133
|
+
if (!(0, import_node_fs6.existsSync)(packageJsonPath)) {
|
|
15145
15134
|
throw new Error("Cannot find package.json configuration");
|
|
15146
15135
|
}
|
|
15147
|
-
let packageJsonContent = await (0,
|
|
15136
|
+
let packageJsonContent = await (0, import_promises5.readFile)(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
15148
15137
|
if (!packageJsonContent) {
|
|
15149
15138
|
throw new Error("Cannot find package.json configuration file");
|
|
15150
15139
|
}
|
package/bin/unbuild.mjs
CHANGED
|
@@ -1102,7 +1102,7 @@ ${formatLogMessage(config)}`, config);
|
|
|
1102
1102
|
import { Command, Option } from "commander";
|
|
1103
1103
|
|
|
1104
1104
|
// src/build.ts
|
|
1105
|
-
import { readCachedProjectGraph as
|
|
1105
|
+
import { readCachedProjectGraph as readCachedProjectGraph4, writeJsonFile } from "@nx/devkit";
|
|
1106
1106
|
import { getHelperDependency as getHelperDependency2, HelperDependency as HelperDependency2 } from "@nx/js";
|
|
1107
1107
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies3 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1108
1108
|
|
|
@@ -1120,13 +1120,14 @@ import { stripIndents } from "@nx/devkit";
|
|
|
1120
1120
|
import { relative } from "path";
|
|
1121
1121
|
|
|
1122
1122
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1123
|
-
import {
|
|
1124
|
-
import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
1123
|
+
import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
1125
1124
|
import { copyAssets as copyAssetsBase } from "@nx/js";
|
|
1126
1125
|
import { glob } from "glob";
|
|
1126
|
+
import { readFile as readFile2, writeFile } from "node:fs/promises";
|
|
1127
1127
|
|
|
1128
1128
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
1129
|
-
import {
|
|
1129
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
1130
|
+
import { readFile } from "node:fs/promises";
|
|
1130
1131
|
var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
1131
1132
|
let rootDir = workspaceRoot;
|
|
1132
1133
|
if (!rootDir) {
|
|
@@ -1134,10 +1135,11 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
1134
1135
|
rootDir = config.workspaceRoot;
|
|
1135
1136
|
}
|
|
1136
1137
|
const nxJsonPath = joinPaths(rootDir, "nx.json");
|
|
1137
|
-
if (!
|
|
1138
|
+
if (!existsSync3(nxJsonPath)) {
|
|
1138
1139
|
throw new Error("Cannot find project.json configuration");
|
|
1139
1140
|
}
|
|
1140
|
-
|
|
1141
|
+
const configContent = await readFile(nxJsonPath, "utf8");
|
|
1142
|
+
return JSON.parse(configContent);
|
|
1141
1143
|
}, "readNxConfig");
|
|
1142
1144
|
|
|
1143
1145
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
@@ -1172,14 +1174,12 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1172
1174
|
});
|
|
1173
1175
|
}
|
|
1174
1176
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
1175
|
-
const projectGraph =
|
|
1176
|
-
exitOnError: true
|
|
1177
|
-
});
|
|
1177
|
+
const projectGraph = readCachedProjectGraph();
|
|
1178
1178
|
const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
1179
1179
|
if (!projectsConfigurations?.projects?.[projectName]) {
|
|
1180
1180
|
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1181
1181
|
}
|
|
1182
|
-
const buildTarget = projectsConfigurations.projects[projectName]
|
|
1182
|
+
const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
|
|
1183
1183
|
if (!buildTarget) {
|
|
1184
1184
|
throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
|
|
1185
1185
|
}
|
|
@@ -1209,42 +1209,30 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1209
1209
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
1210
1210
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
1211
1211
|
]);
|
|
1212
|
-
await Promise.allSettled(files.map(async (file) =>
|
|
1212
|
+
await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
1213
1213
|
|
|
1214
|
-
${await
|
|
1214
|
+
${await readFile2(file, "utf8")}
|
|
1215
1215
|
|
|
1216
1216
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
1217
1217
|
}
|
|
1218
1218
|
}, "copyAssets");
|
|
1219
1219
|
|
|
1220
1220
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
1221
|
-
import { hfs as hfs3 } from "@humanfs/node";
|
|
1222
1221
|
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1223
1222
|
import { Glob } from "glob";
|
|
1224
|
-
import {
|
|
1223
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
1224
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
1225
|
+
import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
|
|
1225
1226
|
var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
1226
|
-
const
|
|
1227
|
-
exitOnError: true
|
|
1228
|
-
});
|
|
1229
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
1230
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1231
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1232
|
-
}
|
|
1233
|
-
const projectJsonPath = joinPaths(workspaceRoot, projectRoot, "project.json");
|
|
1234
|
-
if (!await hfs3.isFile(projectJsonPath)) {
|
|
1235
|
-
throw new Error("Cannot find project.json configuration");
|
|
1236
|
-
}
|
|
1237
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1238
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
1239
|
-
}
|
|
1240
|
-
const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1227
|
+
const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1241
1228
|
const localPackages = [];
|
|
1242
1229
|
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
1243
1230
|
const projectNode = project.node;
|
|
1244
1231
|
if (projectNode.data.root) {
|
|
1245
1232
|
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
1246
|
-
if (
|
|
1247
|
-
const
|
|
1233
|
+
if (existsSync4(projectPackageJsonPath)) {
|
|
1234
|
+
const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
|
|
1235
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
1248
1236
|
if (projectPackageJson.private !== false) {
|
|
1249
1237
|
localPackages.push(projectPackageJson);
|
|
1250
1238
|
}
|
|
@@ -1280,7 +1268,8 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1280
1268
|
}, "addPackageDependencies");
|
|
1281
1269
|
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
1282
1270
|
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
1283
|
-
const
|
|
1271
|
+
const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
1272
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
1284
1273
|
packageJson.type ??= "module";
|
|
1285
1274
|
packageJson.sideEffects ??= false;
|
|
1286
1275
|
if (includeSrc === true) {
|
|
@@ -1379,8 +1368,8 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
|
|
|
1379
1368
|
|
|
1380
1369
|
// src/build.ts
|
|
1381
1370
|
import defu3 from "defu";
|
|
1382
|
-
import { existsSync as
|
|
1383
|
-
import { readFile } from "node:fs/promises";
|
|
1371
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
1372
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1384
1373
|
import { relative as relative4 } from "node:path";
|
|
1385
1374
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
1386
1375
|
import { build as unbuild } from "unbuild";
|
|
@@ -1445,7 +1434,7 @@ ${error ? error.message : "Unknown build error"}
|
|
|
1445
1434
|
}), "onErrorPlugin");
|
|
1446
1435
|
|
|
1447
1436
|
// src/plugins/tsc.ts
|
|
1448
|
-
import { readCachedProjectGraph } from "@nx/devkit";
|
|
1437
|
+
import { readCachedProjectGraph as readCachedProjectGraph3 } from "@nx/devkit";
|
|
1449
1438
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1450
1439
|
import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
|
|
1451
1440
|
|
|
@@ -1456,7 +1445,7 @@ import { normalizePath, createFilter as createFilter$1 } from "@rollup/pluginuti
|
|
|
1456
1445
|
import require$$2 from "util";
|
|
1457
1446
|
import require$$0$1 from "os";
|
|
1458
1447
|
import require$$3, { satisfies } from "semver";
|
|
1459
|
-
import require$$0$2, { existsSync as
|
|
1448
|
+
import require$$0$2, { existsSync as existsSync5, readdirSync, renameSync, readFileSync as readFileSync2 } from "fs";
|
|
1460
1449
|
import * as fs$4 from "fs-extra";
|
|
1461
1450
|
import { emptyDirSync, readJsonSync, writeJsonSync, ensureFileSync, removeSync as removeSync2 } from "fs-extra";
|
|
1462
1451
|
import require$$0$3 from "crypto";
|
|
@@ -14202,8 +14191,8 @@ var RollingCache = class RollingCache2 {
|
|
|
14202
14191
|
/** @returns true if name exists in either old cache or new cache */
|
|
14203
14192
|
exists(name) {
|
|
14204
14193
|
if (this.rolled) return false;
|
|
14205
|
-
if (
|
|
14206
|
-
return
|
|
14194
|
+
if (existsSync5(`${this.newCacheRoot}/${name}`)) return true;
|
|
14195
|
+
return existsSync5(`${this.oldCacheRoot}/${name}`);
|
|
14207
14196
|
}
|
|
14208
14197
|
path(name) {
|
|
14209
14198
|
return `${this.oldCacheRoot}/${name}`;
|
|
@@ -14211,12 +14200,12 @@ var RollingCache = class RollingCache2 {
|
|
|
14211
14200
|
/** @returns true if old cache contains all names and nothing more */
|
|
14212
14201
|
match(names) {
|
|
14213
14202
|
if (this.rolled) return false;
|
|
14214
|
-
if (!
|
|
14203
|
+
if (!existsSync5(this.oldCacheRoot)) return names.length === 0;
|
|
14215
14204
|
return lodash$1.exports.isEqual(readdirSync(this.oldCacheRoot).sort(), names.sort());
|
|
14216
14205
|
}
|
|
14217
14206
|
/** @returns data for name, must exist in either old cache or new cache */
|
|
14218
14207
|
read(name) {
|
|
14219
|
-
if (
|
|
14208
|
+
if (existsSync5(`${this.newCacheRoot}/${name}`)) return readJsonSync(`${this.newCacheRoot}/${name}`, {
|
|
14220
14209
|
encoding: "utf8",
|
|
14221
14210
|
throws: false
|
|
14222
14211
|
});
|
|
@@ -14239,7 +14228,7 @@ var RollingCache = class RollingCache2 {
|
|
|
14239
14228
|
if (this.rolled) return;
|
|
14240
14229
|
this.rolled = true;
|
|
14241
14230
|
removeSync2(this.oldCacheRoot);
|
|
14242
|
-
if (
|
|
14231
|
+
if (existsSync5(this.newCacheRoot)) {
|
|
14243
14232
|
renameSync(this.newCacheRoot, this.oldCacheRoot);
|
|
14244
14233
|
}
|
|
14245
14234
|
}
|
|
@@ -14898,7 +14887,7 @@ __name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
|
14898
14887
|
|
|
14899
14888
|
// src/plugins/tsc.ts
|
|
14900
14889
|
var tscPlugin = /* @__PURE__ */ __name(async (options, resolvedOptions) => {
|
|
14901
|
-
const projectGraph =
|
|
14890
|
+
const projectGraph = readCachedProjectGraph3();
|
|
14902
14891
|
const result = calculateProjectBuildableDependencies2(void 0, projectGraph, resolvedOptions.config.workspaceRoot, resolvedOptions.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
14903
14892
|
let dependencies = result.dependencies;
|
|
14904
14893
|
const tsLibDependency = getHelperDependency(HelperDependency.tsc, resolvedOptions.tsconfig, dependencies, projectGraph, true);
|
|
@@ -14974,32 +14963,32 @@ async function resolveOptions(options) {
|
|
|
14974
14963
|
options = defu3(options, configFile);
|
|
14975
14964
|
}
|
|
14976
14965
|
}
|
|
14977
|
-
const projectGraph =
|
|
14966
|
+
const projectGraph = readCachedProjectGraph4();
|
|
14978
14967
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
14979
|
-
if (!
|
|
14968
|
+
if (!existsSync6(projectJsonPath)) {
|
|
14980
14969
|
throw new Error("Cannot find project.json configuration");
|
|
14981
14970
|
}
|
|
14982
|
-
const projectJsonContent = await
|
|
14971
|
+
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
14983
14972
|
const projectJson = JSON.parse(projectJsonContent);
|
|
14984
14973
|
const projectName = projectJson.name;
|
|
14985
14974
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
14986
|
-
if (!
|
|
14975
|
+
if (!existsSync6(packageJsonPath)) {
|
|
14987
14976
|
throw new Error("Cannot find package.json configuration");
|
|
14988
14977
|
}
|
|
14989
|
-
const packageJsonContent = await
|
|
14978
|
+
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
14990
14979
|
const packageJson = JSON.parse(packageJsonContent);
|
|
14991
14980
|
let tsconfig = options.tsconfig;
|
|
14992
14981
|
if (!tsconfig) {
|
|
14993
14982
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
14994
14983
|
}
|
|
14995
|
-
if (!
|
|
14984
|
+
if (!existsSync6(tsconfig)) {
|
|
14996
14985
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
14997
14986
|
}
|
|
14998
14987
|
let sourceRoot = projectJson.sourceRoot;
|
|
14999
14988
|
if (!sourceRoot) {
|
|
15000
14989
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
15001
14990
|
}
|
|
15002
|
-
if (!
|
|
14991
|
+
if (!existsSync6(sourceRoot)) {
|
|
15003
14992
|
throw new Error("Cannot find sourceRoot directory");
|
|
15004
14993
|
}
|
|
15005
14994
|
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -15122,14 +15111,14 @@ async function resolveOptions(options) {
|
|
|
15122
15111
|
}
|
|
15123
15112
|
__name(resolveOptions, "resolveOptions");
|
|
15124
15113
|
async function generatePackageJson(options) {
|
|
15125
|
-
if (options.generatePackageJson !== false &&
|
|
15114
|
+
if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
|
|
15126
15115
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
15127
15116
|
const stopwatch = getStopwatch("Write package.json file");
|
|
15128
15117
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
15129
|
-
if (!
|
|
15118
|
+
if (!existsSync6(packageJsonPath)) {
|
|
15130
15119
|
throw new Error("Cannot find package.json configuration");
|
|
15131
15120
|
}
|
|
15132
|
-
let packageJsonContent = await
|
|
15121
|
+
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
15133
15122
|
if (!packageJsonContent) {
|
|
15134
15123
|
throw new Error("Cannot find package.json configuration file");
|
|
15135
15124
|
}
|
package/dist/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk3KCZOJ2Qjs = require('./chunk-3KCZOJ2Q.js');
|
|
4
4
|
require('./chunk-3OJD7CO4.js');
|
|
5
5
|
require('./chunk-AYRYNROK.js');
|
|
6
6
|
require('./chunk-DFIGNXGY.js');
|
|
@@ -11,4 +11,4 @@ require('./chunk-OQPSH7GE.js');
|
|
|
11
11
|
require('./chunk-3GQAWCBQ.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.build =
|
|
14
|
+
exports.build = _chunk3KCZOJ2Qjs.build;
|
package/dist/build.mjs
CHANGED
|
@@ -53,13 +53,10 @@ var _resolve2 = require('resolve'); var _resolve3 = _interopRequireDefault(_reso
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
56
|
-
var _node = require('@humanfs/node');
|
|
57
56
|
|
|
58
57
|
|
|
59
58
|
var _glob = require('glob');
|
|
60
|
-
|
|
61
|
-
// ../build-tools/src/utilities/read-nx-config.ts
|
|
62
|
-
|
|
59
|
+
var _promises = require('fs/promises');
|
|
63
60
|
|
|
64
61
|
// ../config-tools/src/config-file/get-config-file.ts
|
|
65
62
|
var _c12 = require('c12');
|
|
@@ -539,6 +536,8 @@ ${_chunkOQPSH7GEjs.formatLogMessage.call(void 0, config)}`, config);
|
|
|
539
536
|
}, "loadStormConfig");
|
|
540
537
|
|
|
541
538
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
539
|
+
|
|
540
|
+
|
|
542
541
|
var readNxConfig = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (workspaceRoot) => {
|
|
543
542
|
let rootDir = workspaceRoot;
|
|
544
543
|
if (!rootDir) {
|
|
@@ -546,10 +545,11 @@ var readNxConfig = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (w
|
|
|
546
545
|
rootDir = config.workspaceRoot;
|
|
547
546
|
}
|
|
548
547
|
const nxJsonPath = _chunkOQPSH7GEjs.joinPaths.call(void 0, rootDir, "nx.json");
|
|
549
|
-
if (!
|
|
548
|
+
if (!_fs.existsSync.call(void 0, nxJsonPath)) {
|
|
550
549
|
throw new Error("Cannot find project.json configuration");
|
|
551
550
|
}
|
|
552
|
-
|
|
551
|
+
const configContent = await _promises.readFile.call(void 0, nxJsonPath, "utf8");
|
|
552
|
+
return JSON.parse(configContent);
|
|
553
553
|
}, "readNxConfig");
|
|
554
554
|
|
|
555
555
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
@@ -584,14 +584,12 @@ var copyAssets = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (con
|
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
587
|
-
const projectGraph =
|
|
588
|
-
exitOnError: true
|
|
589
|
-
});
|
|
587
|
+
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
590
588
|
const projectsConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
|
|
591
589
|
if (!_optionalChain([projectsConfigurations, 'optionalAccess', _37 => _37.projects, 'optionalAccess', _38 => _38[projectName]])) {
|
|
592
590
|
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.");
|
|
593
591
|
}
|
|
594
|
-
const buildTarget = _optionalChain([projectsConfigurations, 'access', _39 => _39.projects, 'access', _40 => _40[projectName], '
|
|
592
|
+
const buildTarget = _optionalChain([projectsConfigurations, 'access', _39 => _39.projects, 'access', _40 => _40[projectName], 'access', _41 => _41.targets, 'optionalAccess', _42 => _42.build]);
|
|
595
593
|
if (!buildTarget) {
|
|
596
594
|
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 ${_chunkOQPSH7GEjs.joinPaths.call(void 0, projectRoot, "project.json")}`);
|
|
597
595
|
}
|
|
@@ -621,9 +619,9 @@ var copyAssets = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (con
|
|
|
621
619
|
_chunkOQPSH7GEjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
622
620
|
_chunkOQPSH7GEjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
623
621
|
]);
|
|
624
|
-
await Promise.allSettled(files.map(async (file) =>
|
|
622
|
+
await Promise.allSettled(files.map(async (file) => _promises.writeFile.call(void 0, file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
625
623
|
|
|
626
|
-
${await
|
|
624
|
+
${await _promises.readFile.call(void 0, file, "utf8")}
|
|
627
625
|
|
|
628
626
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
629
627
|
}
|
|
@@ -633,30 +631,18 @@ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `//
|
|
|
633
631
|
|
|
634
632
|
|
|
635
633
|
|
|
634
|
+
|
|
636
635
|
var _projectgraph = require('nx/src/project-graph/project-graph');
|
|
637
636
|
var addPackageDependencies = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
638
|
-
const
|
|
639
|
-
exitOnError: true
|
|
640
|
-
});
|
|
641
|
-
const projectConfigurations = _projectgraph.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
|
|
642
|
-
if (!_optionalChain([projectConfigurations, 'optionalAccess', _43 => _43.projects, 'optionalAccess', _44 => _44[projectName]])) {
|
|
643
|
-
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.");
|
|
644
|
-
}
|
|
645
|
-
const projectJsonPath = _chunkOQPSH7GEjs.joinPaths.call(void 0, workspaceRoot, projectRoot, "project.json");
|
|
646
|
-
if (!await _node.hfs.isFile(projectJsonPath)) {
|
|
647
|
-
throw new Error("Cannot find project.json configuration");
|
|
648
|
-
}
|
|
649
|
-
if (!_optionalChain([projectConfigurations, 'optionalAccess', _45 => _45.projects, 'optionalAccess', _46 => _46[projectName]])) {
|
|
650
|
-
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.");
|
|
651
|
-
}
|
|
652
|
-
const projectDependencies = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
637
|
+
const projectDependencies = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, _projectgraph.readCachedProjectGraph.call(void 0, ), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
653
638
|
const localPackages = [];
|
|
654
639
|
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
655
640
|
const projectNode = project.node;
|
|
656
641
|
if (projectNode.data.root) {
|
|
657
642
|
const projectPackageJsonPath = _chunkOQPSH7GEjs.joinPaths.call(void 0, workspaceRoot, projectNode.data.root, "package.json");
|
|
658
|
-
if (
|
|
659
|
-
const
|
|
643
|
+
if (_fs.existsSync.call(void 0, projectPackageJsonPath)) {
|
|
644
|
+
const projectPackageJsonContent = await _promises.readFile.call(void 0, projectPackageJsonPath, "utf8");
|
|
645
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
660
646
|
if (projectPackageJson.private !== false) {
|
|
661
647
|
localPackages.push(projectPackageJson);
|
|
662
648
|
}
|
|
@@ -692,7 +678,8 @@ var addPackageDependencies = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0
|
|
|
692
678
|
}, "addPackageDependencies");
|
|
693
679
|
var addWorkspacePackageJsonFields = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
694
680
|
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : _chunkOQPSH7GEjs.findWorkspaceRoot.call(void 0, );
|
|
695
|
-
const
|
|
681
|
+
const workspacePackageJsonContent = await _promises.readFile.call(void 0, _chunkOQPSH7GEjs.joinPaths.call(void 0, workspaceRoot, "package.json"), "utf8");
|
|
682
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
696
683
|
packageJson.type ??= "module";
|
|
697
684
|
packageJson.sideEffects ??= false;
|
|
698
685
|
if (includeSrc === true) {
|
|
@@ -792,7 +779,7 @@ var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
|
|
|
792
779
|
// src/build.ts
|
|
793
780
|
|
|
794
781
|
|
|
795
|
-
|
|
782
|
+
|
|
796
783
|
|
|
797
784
|
var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
|
|
798
785
|
var _unbuild = require('unbuild');
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./chunk-LPEX4YW6.mjs";
|
|
36
36
|
|
|
37
37
|
// src/build.ts
|
|
38
|
-
import { readCachedProjectGraph, writeJsonFile } from "@nx/devkit";
|
|
38
|
+
import { readCachedProjectGraph as readCachedProjectGraph3, writeJsonFile } from "@nx/devkit";
|
|
39
39
|
import { getHelperDependency, HelperDependency } from "@nx/js";
|
|
40
40
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
41
41
|
|
|
@@ -53,13 +53,10 @@ import { stripIndents } from "@nx/devkit";
|
|
|
53
53
|
import { relative } from "path";
|
|
54
54
|
|
|
55
55
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
56
|
-
import {
|
|
57
|
-
import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
56
|
+
import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
58
57
|
import { copyAssets as copyAssetsBase } from "@nx/js";
|
|
59
58
|
import { glob } from "glob";
|
|
60
|
-
|
|
61
|
-
// ../build-tools/src/utilities/read-nx-config.ts
|
|
62
|
-
import { hfs } from "@humanfs/node";
|
|
59
|
+
import { readFile as readFile2, writeFile } from "node:fs/promises";
|
|
63
60
|
|
|
64
61
|
// ../config-tools/src/config-file/get-config-file.ts
|
|
65
62
|
import { loadConfig as loadConfig2 } from "c12";
|
|
@@ -539,6 +536,8 @@ ${formatLogMessage(config)}`, config);
|
|
|
539
536
|
}, "loadStormConfig");
|
|
540
537
|
|
|
541
538
|
// ../build-tools/src/utilities/read-nx-config.ts
|
|
539
|
+
import { existsSync } from "node:fs";
|
|
540
|
+
import { readFile } from "node:fs/promises";
|
|
542
541
|
var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
543
542
|
let rootDir = workspaceRoot;
|
|
544
543
|
if (!rootDir) {
|
|
@@ -546,10 +545,11 @@ var readNxConfig = /* @__PURE__ */ __name(async (workspaceRoot) => {
|
|
|
546
545
|
rootDir = config.workspaceRoot;
|
|
547
546
|
}
|
|
548
547
|
const nxJsonPath = joinPaths(rootDir, "nx.json");
|
|
549
|
-
if (!
|
|
548
|
+
if (!existsSync(nxJsonPath)) {
|
|
550
549
|
throw new Error("Cannot find project.json configuration");
|
|
551
550
|
}
|
|
552
|
-
|
|
551
|
+
const configContent = await readFile(nxJsonPath, "utf8");
|
|
552
|
+
return JSON.parse(configContent);
|
|
553
553
|
}, "readNxConfig");
|
|
554
554
|
|
|
555
555
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
@@ -584,14 +584,12 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
const nxJson = readNxConfig(config.workspaceRoot);
|
|
587
|
-
const projectGraph =
|
|
588
|
-
exitOnError: true
|
|
589
|
-
});
|
|
587
|
+
const projectGraph = readCachedProjectGraph();
|
|
590
588
|
const projectsConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
591
589
|
if (!projectsConfigurations?.projects?.[projectName]) {
|
|
592
590
|
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.");
|
|
593
591
|
}
|
|
594
|
-
const buildTarget = projectsConfigurations.projects[projectName]
|
|
592
|
+
const buildTarget = projectsConfigurations.projects[projectName].targets?.build;
|
|
595
593
|
if (!buildTarget) {
|
|
596
594
|
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")}`);
|
|
597
595
|
}
|
|
@@ -621,42 +619,30 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
621
619
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
622
620
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
623
621
|
]);
|
|
624
|
-
await Promise.allSettled(files.map(async (file) =>
|
|
622
|
+
await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
625
623
|
|
|
626
|
-
${await
|
|
624
|
+
${await readFile2(file, "utf8")}
|
|
627
625
|
|
|
628
626
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
|
|
629
627
|
}
|
|
630
628
|
}, "copyAssets");
|
|
631
629
|
|
|
632
630
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
633
|
-
import { hfs as hfs3 } from "@humanfs/node";
|
|
634
631
|
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
635
632
|
import { Glob } from "glob";
|
|
636
|
-
import {
|
|
633
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
634
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
635
|
+
import { readCachedProjectGraph as readCachedProjectGraph2 } from "nx/src/project-graph/project-graph";
|
|
637
636
|
var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
638
|
-
const
|
|
639
|
-
exitOnError: true
|
|
640
|
-
});
|
|
641
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
642
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
643
|
-
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.");
|
|
644
|
-
}
|
|
645
|
-
const projectJsonPath = joinPaths(workspaceRoot, projectRoot, "project.json");
|
|
646
|
-
if (!await hfs3.isFile(projectJsonPath)) {
|
|
647
|
-
throw new Error("Cannot find project.json configuration");
|
|
648
|
-
}
|
|
649
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
650
|
-
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.");
|
|
651
|
-
}
|
|
652
|
-
const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
637
|
+
const projectDependencies = calculateProjectBuildableDependencies(void 0, readCachedProjectGraph2(), workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
653
638
|
const localPackages = [];
|
|
654
639
|
for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== projectRoot && dep.node.data.root !== workspaceRoot)) {
|
|
655
640
|
const projectNode = project.node;
|
|
656
641
|
if (projectNode.data.root) {
|
|
657
642
|
const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
|
|
658
|
-
if (
|
|
659
|
-
const
|
|
643
|
+
if (existsSync2(projectPackageJsonPath)) {
|
|
644
|
+
const projectPackageJsonContent = await readFile3(projectPackageJsonPath, "utf8");
|
|
645
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
660
646
|
if (projectPackageJson.private !== false) {
|
|
661
647
|
localPackages.push(projectPackageJson);
|
|
662
648
|
}
|
|
@@ -692,7 +678,8 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
692
678
|
}, "addPackageDependencies");
|
|
693
679
|
var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
694
680
|
const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
|
|
695
|
-
const
|
|
681
|
+
const workspacePackageJsonContent = await readFile3(joinPaths(workspaceRoot, "package.json"), "utf8");
|
|
682
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
696
683
|
packageJson.type ??= "module";
|
|
697
684
|
packageJson.sideEffects ??= false;
|
|
698
685
|
if (includeSrc === true) {
|
|
@@ -791,8 +778,8 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
|
|
|
791
778
|
|
|
792
779
|
// src/build.ts
|
|
793
780
|
import defu3 from "defu";
|
|
794
|
-
import { existsSync } from "node:fs";
|
|
795
|
-
import { readFile } from "node:fs/promises";
|
|
781
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
782
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
796
783
|
import { relative as relative2 } from "node:path";
|
|
797
784
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
798
785
|
import { build as unbuild } from "unbuild";
|
|
@@ -815,32 +802,32 @@ async function resolveOptions(options) {
|
|
|
815
802
|
options = defu3(options, configFile);
|
|
816
803
|
}
|
|
817
804
|
}
|
|
818
|
-
const projectGraph =
|
|
805
|
+
const projectGraph = readCachedProjectGraph3();
|
|
819
806
|
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
820
|
-
if (!
|
|
807
|
+
if (!existsSync3(projectJsonPath)) {
|
|
821
808
|
throw new Error("Cannot find project.json configuration");
|
|
822
809
|
}
|
|
823
|
-
const projectJsonContent = await
|
|
810
|
+
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
824
811
|
const projectJson = JSON.parse(projectJsonContent);
|
|
825
812
|
const projectName = projectJson.name;
|
|
826
813
|
const packageJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "package.json");
|
|
827
|
-
if (!
|
|
814
|
+
if (!existsSync3(packageJsonPath)) {
|
|
828
815
|
throw new Error("Cannot find package.json configuration");
|
|
829
816
|
}
|
|
830
|
-
const packageJsonContent = await
|
|
817
|
+
const packageJsonContent = await readFile4(packageJsonPath, "utf8");
|
|
831
818
|
const packageJson = JSON.parse(packageJsonContent);
|
|
832
819
|
let tsconfig = options.tsconfig;
|
|
833
820
|
if (!tsconfig) {
|
|
834
821
|
tsconfig = joinPaths(workspaceRoot.dir, projectRoot, "tsconfig.json");
|
|
835
822
|
}
|
|
836
|
-
if (!
|
|
823
|
+
if (!existsSync3(tsconfig)) {
|
|
837
824
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
838
825
|
}
|
|
839
826
|
let sourceRoot = projectJson.sourceRoot;
|
|
840
827
|
if (!sourceRoot) {
|
|
841
828
|
sourceRoot = joinPaths(projectRoot, "src");
|
|
842
829
|
}
|
|
843
|
-
if (!
|
|
830
|
+
if (!existsSync3(sourceRoot)) {
|
|
844
831
|
throw new Error("Cannot find sourceRoot directory");
|
|
845
832
|
}
|
|
846
833
|
const result = calculateProjectBuildableDependencies2(void 0, projectGraph, workspaceRoot.dir, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
@@ -963,14 +950,14 @@ async function resolveOptions(options) {
|
|
|
963
950
|
}
|
|
964
951
|
__name(resolveOptions, "resolveOptions");
|
|
965
952
|
async function generatePackageJson(options) {
|
|
966
|
-
if (options.generatePackageJson !== false &&
|
|
953
|
+
if (options.generatePackageJson !== false && existsSync3(joinPaths(options.projectRoot, "package.json"))) {
|
|
967
954
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
968
955
|
const stopwatch = getStopwatch("Write package.json file");
|
|
969
956
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
970
|
-
if (!
|
|
957
|
+
if (!existsSync3(packageJsonPath)) {
|
|
971
958
|
throw new Error("Cannot find package.json configuration");
|
|
972
959
|
}
|
|
973
|
-
let packageJsonContent = await
|
|
960
|
+
let packageJsonContent = await readFile4(joinPaths(options.config.workspaceRoot, options.projectRoot, "package.json"), "utf8");
|
|
974
961
|
if (!packageJsonContent) {
|
|
975
962
|
throw new Error("Cannot find package.json configuration file");
|
|
976
963
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk3KCZOJ2Qjs = require('./chunk-3KCZOJ2Q.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk3OJD7CO4js = require('./chunk-3OJD7CO4.js');
|
|
@@ -23,4 +23,4 @@ require('./chunk-3GQAWCBQ.js');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
exports.build =
|
|
26
|
+
exports.build = _chunk3KCZOJ2Qjs.build; exports.clean = _chunk3OJD7CO4js.clean; exports.createTsCompilerOptions = _chunkDFIGNXGYjs.createTsCompilerOptions; exports.getDefaultBuildPlugins = _chunkAYRYNROKjs.getDefaultBuildPlugins; exports.loadConfig = _chunkDFIGNXGYjs.loadConfig;
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@storm-software/unbuild","version":"0.
|
|
1
|
+
{"name":"@storm-software/unbuild","version":"0.21.0","description":"A package containing `unbuild` utilities for building Storm Software libraries and applications","repository":{"type":"github","url":"https://github.com/storm-software/storm-ops.git","directory":"packages/unbuild"},"homepage":"https://stormsoftware.com","bugs":"https://github.com/storm-software/storm-ops/issues","author":{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"},"maintainers":[{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"},{"name":"Pat Sullivan","email":"admin@stormsoftware.com","url":"https://patsullivan.org"}],"contributors":[{"name":"Storm Software","email":"contact@stormsoftware.com","url":"https://stormsoftware.com"}],"funding":{"type":"github","url":"https://github.com/sponsors/storm-software"},"license":"Apache-2.0","private":false,"packageManager":"pnpm@9.15.2","engines":{"node":">=22.4.0","pnpm":">=9.15.2"},"bin":{"storm-unbuild":"./bin/unbuild.js","storm-unbuild-cjs":"./bin/unbuild.js","storm-unbuild-esm":"./bin/unbuild.mjs"},"main":"./dist/index.js","module":"./dist/index.mjs","exports":{"./package.json":"./package.json","./types":{"import":{"types":"./dist/types.d.mts","default":"./dist/types.mjs"},"require":{"types":"./dist/types.d.ts","default":"./dist/types.js"},"default":{"types":"./dist/types.d.ts","default":"./dist/types.js"}},"./index":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./config":{"import":{"types":"./dist/config.d.mts","default":"./dist/config.mjs"},"require":{"types":"./dist/config.d.ts","default":"./dist/config.js"},"default":{"types":"./dist/config.d.ts","default":"./dist/config.js"}},"./clean":{"import":{"types":"./dist/clean.d.mts","default":"./dist/clean.mjs"},"require":{"types":"./dist/clean.d.ts","default":"./dist/clean.js"},"default":{"types":"./dist/clean.d.ts","default":"./dist/clean.js"}},"./build":{"import":{"types":"./dist/build/index.d.mts","default":"./dist/build/index.mjs"},"require":{"types":"./dist/build/index.d.ts","default":"./dist/build/index.js"},"default":{"types":"./dist/build/index.d.ts","default":"./dist/build/index.js"}},"./plugins/*":{"import":{"types":"./dist/plugins/*.d.mts","default":"./dist/plugins/*.mjs"},"require":{"types":"./dist/plugins/*.d.ts","default":"./dist/plugins/*.js"},"default":{"types":"./dist/plugins/*.d.ts","default":"./dist/plugins/*.js"}}},"types":"./dist/index.d.ts","files":["dist/**/*"],"keywords":["acidic","cyclone-ui","monorepo","storm","storm-ops","storm-stack","sullivanpj","unbuild"],"peerDependencies":{"@nx/devkit":"^20.3.1","@nx/js":"^20.3.1","@storm-software/build-tools":"workspace:*","@storm-software/config-tools":"workspace:*","@swc/core":"1.7.26","nx":"^20.3.1","rollup":"^4.29.1","typescript":"^5.7.2","unbuild":"^3.2.0"},"peerDependenciesMeta":{"@nx/devkit":{"optional":false},"@nx/js":{"optional":false},"@storm-software/build-tools":{"optional":false},"@storm-software/config-tools":{"optional":false},"@swc/core":{"optional":true},"nx":{"optional":false},"rollup":{"optional":false},"typescript":{"optional":false},"unbuild":{"optional":false}},"dependencies":{"@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^28.0.2","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^16.0.0","@rollup/plugin-replace":"^6.0.2","@rollup/pluginutils":"^5.1.4","commander":"^12.1.0","defu":"6.1.4","rollup":"^4.29.1","rollup-plugin-typescript2":"0.36.0"},"devDependencies":{"@nx/devkit":"^20.3.1","@nx/js":"^20.3.1","@storm-software/build-tools":"workspace:*","@storm-software/config":"workspace:*","@storm-software/config-tools":"workspace:*","@swc/core":"1.7.26","@types/node":"^22.10.2","nx":"^20.3.1","tsup":"8.3.5","typescript":"^5.7.2","unbuild":"^3.2.0"},"publishConfig":{"access":"public"},"sideEffects":false}
|