@storm-software/unbuild 0.25.3 → 0.26.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/bin/unbuild.cjs +42 -78
- package/bin/unbuild.js +41 -77
- package/dist/build.cjs +8 -8
- package/dist/build.d.cts +0 -2
- package/dist/build.d.ts +0 -2
- package/dist/build.js +7 -7
- package/dist/{chunk-JKBKJSU6.js → chunk-4RR7YISH.js} +7 -4
- package/dist/{chunk-RWW6C7JH.js → chunk-BRHZNXQM.js} +6 -1
- package/dist/{chunk-T2Q5LQOI.js → chunk-DRQUQQ5D.js} +43 -78
- package/dist/{chunk-36OA7HRF.cjs → chunk-GHVDJY3S.cjs} +6 -1
- package/dist/{chunk-ADWBQYE6.cjs → chunk-HO6B5DC7.cjs} +6 -6
- package/dist/{chunk-RHYLM6VP.js → chunk-JIVM7FQJ.js} +1 -1
- package/dist/{chunk-LUXNRUAP.cjs → chunk-KAXKUEZ7.cjs} +2 -2
- package/dist/{chunk-T6BV33KD.js → chunk-TFMXUACY.js} +3 -3
- package/dist/{chunk-KUMAH6IZ.cjs → chunk-TRA2WJ3W.cjs} +3 -3
- package/dist/{chunk-4AWYDOEH.cjs → chunk-UV35N5R4.cjs} +2 -2
- package/dist/{chunk-BE5U4XRE.js → chunk-VEX5RCZW.js} +1 -1
- package/dist/{chunk-HYDGJLPG.cjs → chunk-XGMJ3OUH.cjs} +107 -142
- package/dist/{chunk-D5YXD4XE.cjs → chunk-XKHSZIHP.cjs} +7 -4
- package/dist/{chunk-2RMUO4GG.js → chunk-YCGXRIUD.js} +1 -1
- package/dist/clean.cjs +3 -3
- package/dist/clean.js +2 -2
- package/dist/config.cjs +6 -6
- package/dist/config.d.cts +0 -2
- package/dist/config.d.ts +0 -2
- package/dist/config.js +5 -5
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +7 -7
- package/dist/types.d.cts +0 -4
- package/dist/types.d.ts +0 -4
- package/package.json +4 -4
package/bin/unbuild.cjs
CHANGED
|
@@ -1140,35 +1140,6 @@ var import_path = require("path");
|
|
|
1140
1140
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1141
1141
|
var import_devkit3 = require("@nx/devkit");
|
|
1142
1142
|
var import_js = require("@nx/js");
|
|
1143
|
-
|
|
1144
|
-
// ../config-tools/src/logger/create-logger.ts
|
|
1145
|
-
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
1146
|
-
async function createLogger(config) {
|
|
1147
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
1148
|
-
if (!workspaceRoot) {
|
|
1149
|
-
throw new Error("Cannot find workspace root");
|
|
1150
|
-
}
|
|
1151
|
-
const writeFatal2 = getLogFn(LogLevel.FATAL, config, import_chalk3.default);
|
|
1152
|
-
const writeError2 = getLogFn(LogLevel.ERROR, config, import_chalk3.default);
|
|
1153
|
-
const writeWarning2 = getLogFn(LogLevel.WARN, config, import_chalk3.default);
|
|
1154
|
-
const writeInfo2 = getLogFn(LogLevel.INFO, config, import_chalk3.default);
|
|
1155
|
-
const writeSuccess2 = getLogFn(LogLevel.SUCCESS, config, import_chalk3.default);
|
|
1156
|
-
const writeDebug2 = getLogFn(LogLevel.DEBUG, config, import_chalk3.default);
|
|
1157
|
-
const writeTrace2 = getLogFn(LogLevel.DEBUG, config, import_chalk3.default);
|
|
1158
|
-
return {
|
|
1159
|
-
fatal: writeFatal2,
|
|
1160
|
-
error: writeError2,
|
|
1161
|
-
warning: writeWarning2,
|
|
1162
|
-
info: writeInfo2,
|
|
1163
|
-
success: writeSuccess2,
|
|
1164
|
-
debug: writeDebug2,
|
|
1165
|
-
trace: writeTrace2,
|
|
1166
|
-
getStopwatch
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
__name(createLogger, "createLogger");
|
|
1170
|
-
|
|
1171
|
-
// ../build-tools/src/utilities/copy-assets.ts
|
|
1172
1143
|
var import_glob = require("glob");
|
|
1173
1144
|
var import_promises2 = require("fs/promises");
|
|
1174
1145
|
|
|
@@ -1415,11 +1386,10 @@ var import_create_task_graph = require("nx/src/tasks-runner/create-task-graph");
|
|
|
1415
1386
|
|
|
1416
1387
|
// src/build.ts
|
|
1417
1388
|
var import_defu5 = __toESM(require("defu"), 1);
|
|
1418
|
-
var import_jiti3 = require("jiti");
|
|
1419
1389
|
var import_node_fs8 = require("fs");
|
|
1420
1390
|
var import_promises7 = require("fs/promises");
|
|
1421
1391
|
var import_node_path6 = require("path");
|
|
1422
|
-
var
|
|
1392
|
+
var import_find_workspace_root5 = require("nx/src/utils/find-workspace-root");
|
|
1423
1393
|
|
|
1424
1394
|
// ../../node_modules/.pnpm/unbuild@3.3.1_sass@1.83.4_typescript@5.7.3/node_modules/unbuild/dist/shared/unbuild.B2_7OVir.mjs
|
|
1425
1395
|
var import_node_module2 = __toESM(require("module"), 1);
|
|
@@ -2899,18 +2869,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
|
|
|
2899
2869
|
name: "storm:on-error",
|
|
2900
2870
|
buildEnd(error) {
|
|
2901
2871
|
if (error) {
|
|
2902
|
-
|
|
2872
|
+
writeError(`The following errors occurred during the build:
|
|
2903
2873
|
${error ? error.message : "Unknown build error"}
|
|
2904
2874
|
|
|
2905
|
-
|
|
2875
|
+
`, resolvedOptions.config);
|
|
2906
2876
|
throw new Error("Storm unbuild process failed with errors.");
|
|
2907
2877
|
}
|
|
2908
2878
|
},
|
|
2909
2879
|
renderError(error) {
|
|
2910
|
-
|
|
2880
|
+
writeError(`The following errors occurred during the build:
|
|
2911
2881
|
${error ? error.message : "Unknown build error"}
|
|
2912
2882
|
|
|
2913
|
-
|
|
2883
|
+
`, resolvedOptions.config);
|
|
2914
2884
|
throw new Error("Storm unbuild process failed with errors.");
|
|
2915
2885
|
}
|
|
2916
2886
|
}), "onErrorPlugin");
|
|
@@ -3006,35 +2976,25 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name(async (options, resolvedOpti
|
|
|
3006
2976
|
].map((plugin) => Promise.resolve(plugin))), "getDefaultBuildPlugins");
|
|
3007
2977
|
|
|
3008
2978
|
// src/build.ts
|
|
3009
|
-
async function resolveOptions(options) {
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
throw new Error("Cannot find project root");
|
|
3013
|
-
}
|
|
3014
|
-
const outputPath = options.outputPath || joinPaths("dist", projectRoot);
|
|
3015
|
-
const workspaceRoot = (0, import_find_workspace_root6.findWorkspaceRoot)(projectRoot);
|
|
3016
|
-
if (!workspaceRoot) {
|
|
3017
|
-
throw new Error("Cannot find workspace root");
|
|
3018
|
-
}
|
|
3019
|
-
const config = await loadStormConfig(workspaceRoot.dir);
|
|
3020
|
-
const logger = await createLogger(config);
|
|
3021
|
-
logger.debug(" \u2699\uFE0F Resolving build options");
|
|
3022
|
-
const stopwatch = logger.getStopwatch("Build options resolution");
|
|
2979
|
+
async function resolveOptions(options, config) {
|
|
2980
|
+
writeDebug(" \u2699\uFE0F Resolving build options", config);
|
|
2981
|
+
const stopwatch = getStopwatch("Build options resolution");
|
|
3023
2982
|
if (options.configPath) {
|
|
3024
2983
|
const configFile = await loadConfig2(options.configPath);
|
|
3025
2984
|
if (configFile) {
|
|
3026
2985
|
options = (0, import_defu5.default)(options, configFile);
|
|
3027
2986
|
}
|
|
3028
2987
|
}
|
|
2988
|
+
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
3029
2989
|
const projectGraph = (0, import_devkit6.readCachedProjectGraph)();
|
|
3030
|
-
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
2990
|
+
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
3031
2991
|
if (!(0, import_node_fs8.existsSync)(projectJsonPath)) {
|
|
3032
2992
|
throw new Error("Cannot find project.json configuration");
|
|
3033
2993
|
}
|
|
3034
2994
|
const projectJsonContent = await (0, import_promises7.readFile)(projectJsonPath, "utf8");
|
|
3035
2995
|
const projectJson = JSON.parse(projectJsonContent);
|
|
3036
2996
|
const projectName = projectJson.name;
|
|
3037
|
-
const packageJsonPath = joinPaths(workspaceRoot
|
|
2997
|
+
const packageJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "package.json");
|
|
3038
2998
|
if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
|
|
3039
2999
|
throw new Error("Cannot find package.json configuration");
|
|
3040
3000
|
}
|
|
@@ -3042,51 +3002,45 @@ async function resolveOptions(options) {
|
|
|
3042
3002
|
const packageJson = JSON.parse(packageJsonContent);
|
|
3043
3003
|
let tsconfig = options.tsconfig;
|
|
3044
3004
|
if (!tsconfig) {
|
|
3045
|
-
tsconfig = joinPaths(workspaceRoot
|
|
3005
|
+
tsconfig = joinPaths(config.workspaceRoot, options.projectRoot, "tsconfig.json");
|
|
3046
3006
|
}
|
|
3047
3007
|
if (!(0, import_node_fs8.existsSync)(tsconfig)) {
|
|
3048
3008
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
3049
3009
|
}
|
|
3050
3010
|
let sourceRoot = projectJson.sourceRoot;
|
|
3051
3011
|
if (!sourceRoot) {
|
|
3052
|
-
sourceRoot = joinPaths(projectRoot, "src");
|
|
3012
|
+
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
3053
3013
|
}
|
|
3054
3014
|
if (!(0, import_node_fs8.existsSync)(sourceRoot)) {
|
|
3055
3015
|
throw new Error("Cannot find sourceRoot directory");
|
|
3056
3016
|
}
|
|
3057
|
-
const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, workspaceRoot
|
|
3017
|
+
const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
3058
3018
|
let dependencies = result.dependencies;
|
|
3059
3019
|
const tsLibDependency = (0, import_js2.getHelperDependency)(import_js2.HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
|
|
3060
3020
|
if (tsLibDependency) {
|
|
3061
3021
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
3062
3022
|
dependencies.push(tsLibDependency);
|
|
3063
3023
|
}
|
|
3064
|
-
const jiti = (0, import_jiti3.createJiti)(config.workspaceRoot, {
|
|
3065
|
-
fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
|
|
3066
|
-
interopDefault: true
|
|
3067
|
-
});
|
|
3068
3024
|
const resolvedOptions = {
|
|
3069
3025
|
name: projectName,
|
|
3070
3026
|
config,
|
|
3071
|
-
projectRoot,
|
|
3027
|
+
projectRoot: options.projectRoot,
|
|
3072
3028
|
sourceRoot,
|
|
3073
3029
|
projectName,
|
|
3074
3030
|
tsconfig,
|
|
3075
|
-
jiti,
|
|
3076
|
-
logger,
|
|
3077
3031
|
clean: false,
|
|
3078
3032
|
entries: [
|
|
3079
3033
|
{
|
|
3080
3034
|
builder: "mkdist",
|
|
3081
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
3082
|
-
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3035
|
+
input: `.${sourceRoot.replace(options.projectRoot, "")}`,
|
|
3036
|
+
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3083
3037
|
declaration: options.emitTypes !== false,
|
|
3084
3038
|
format: "esm"
|
|
3085
3039
|
},
|
|
3086
3040
|
{
|
|
3087
3041
|
builder: "mkdist",
|
|
3088
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
3089
|
-
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3042
|
+
input: `.${sourceRoot.replace(options.projectRoot, "")}`,
|
|
3043
|
+
outDir: joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3090
3044
|
declaration: options.emitTypes !== false,
|
|
3091
3045
|
format: "cjs",
|
|
3092
3046
|
ext: "cjs"
|
|
@@ -3181,8 +3135,8 @@ async function resolveOptions(options) {
|
|
|
3181
3135
|
__name(resolveOptions, "resolveOptions");
|
|
3182
3136
|
async function generatePackageJson(options) {
|
|
3183
3137
|
if (options.generatePackageJson !== false && (0, import_node_fs8.existsSync)(joinPaths(options.projectRoot, "package.json"))) {
|
|
3184
|
-
|
|
3185
|
-
const stopwatch =
|
|
3138
|
+
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
3139
|
+
const stopwatch = getStopwatch("Write package.json file");
|
|
3186
3140
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
3187
3141
|
if (!(0, import_node_fs8.existsSync)(packageJsonPath)) {
|
|
3188
3142
|
throw new Error("Cannot find package.json configuration");
|
|
@@ -3201,8 +3155,8 @@ async function generatePackageJson(options) {
|
|
|
3201
3155
|
}
|
|
3202
3156
|
__name(generatePackageJson, "generatePackageJson");
|
|
3203
3157
|
async function executeUnbuild(options) {
|
|
3204
|
-
|
|
3205
|
-
const stopwatch =
|
|
3158
|
+
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
3159
|
+
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
3206
3160
|
try {
|
|
3207
3161
|
await build(options.projectRoot, false, {
|
|
3208
3162
|
...options,
|
|
@@ -3215,8 +3169,8 @@ async function executeUnbuild(options) {
|
|
|
3215
3169
|
}
|
|
3216
3170
|
__name(executeUnbuild, "executeUnbuild");
|
|
3217
3171
|
async function copyBuildAssets(options) {
|
|
3218
|
-
|
|
3219
|
-
const stopwatch =
|
|
3172
|
+
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
|
|
3173
|
+
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
3220
3174
|
await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
|
|
3221
3175
|
stopwatch();
|
|
3222
3176
|
return options;
|
|
@@ -3224,8 +3178,8 @@ async function copyBuildAssets(options) {
|
|
|
3224
3178
|
__name(copyBuildAssets, "copyBuildAssets");
|
|
3225
3179
|
async function cleanOutputPath(options) {
|
|
3226
3180
|
if (options.clean !== false && options.outDir) {
|
|
3227
|
-
|
|
3228
|
-
const stopwatch =
|
|
3181
|
+
writeDebug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`, options.config);
|
|
3182
|
+
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
3229
3183
|
await cleanDirectories(options.name, options.outDir, options.config);
|
|
3230
3184
|
stopwatch();
|
|
3231
3185
|
}
|
|
@@ -3233,17 +3187,27 @@ async function cleanOutputPath(options) {
|
|
|
3233
3187
|
}
|
|
3234
3188
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
3235
3189
|
async function build2(options) {
|
|
3236
|
-
const
|
|
3237
|
-
|
|
3238
|
-
|
|
3190
|
+
const projectRoot = options.projectRoot;
|
|
3191
|
+
if (!projectRoot) {
|
|
3192
|
+
throw new Error("Cannot find project root");
|
|
3193
|
+
}
|
|
3194
|
+
const workspaceRoot = (0, import_find_workspace_root5.findWorkspaceRoot)(projectRoot);
|
|
3195
|
+
if (!workspaceRoot) {
|
|
3196
|
+
throw new Error("Cannot find workspace root");
|
|
3197
|
+
}
|
|
3198
|
+
const config = await loadStormConfig(workspaceRoot.dir);
|
|
3199
|
+
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
|
|
3200
|
+
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
3239
3201
|
try {
|
|
3202
|
+
options.projectRoot = projectRoot;
|
|
3203
|
+
const resolvedOptions = await resolveOptions(options, config);
|
|
3240
3204
|
await cleanOutputPath(resolvedOptions);
|
|
3241
3205
|
await generatePackageJson(resolvedOptions);
|
|
3242
3206
|
await executeUnbuild(resolvedOptions);
|
|
3243
3207
|
await copyBuildAssets(resolvedOptions);
|
|
3244
|
-
|
|
3208
|
+
writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, config);
|
|
3245
3209
|
} catch (error) {
|
|
3246
|
-
|
|
3210
|
+
writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.", config);
|
|
3247
3211
|
throw error;
|
|
3248
3212
|
} finally {
|
|
3249
3213
|
stopwatch();
|
package/bin/unbuild.js
CHANGED
|
@@ -1115,35 +1115,6 @@ import { relative } from "path";
|
|
|
1115
1115
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
1116
1116
|
import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit";
|
|
1117
1117
|
import { copyAssets as copyAssetsBase } from "@nx/js";
|
|
1118
|
-
|
|
1119
|
-
// ../config-tools/src/logger/create-logger.ts
|
|
1120
|
-
import chalk2 from "chalk";
|
|
1121
|
-
async function createLogger(config) {
|
|
1122
|
-
const workspaceRoot = findWorkspaceRoot();
|
|
1123
|
-
if (!workspaceRoot) {
|
|
1124
|
-
throw new Error("Cannot find workspace root");
|
|
1125
|
-
}
|
|
1126
|
-
const writeFatal2 = getLogFn(LogLevel.FATAL, config, chalk2);
|
|
1127
|
-
const writeError2 = getLogFn(LogLevel.ERROR, config, chalk2);
|
|
1128
|
-
const writeWarning2 = getLogFn(LogLevel.WARN, config, chalk2);
|
|
1129
|
-
const writeInfo2 = getLogFn(LogLevel.INFO, config, chalk2);
|
|
1130
|
-
const writeSuccess2 = getLogFn(LogLevel.SUCCESS, config, chalk2);
|
|
1131
|
-
const writeDebug2 = getLogFn(LogLevel.DEBUG, config, chalk2);
|
|
1132
|
-
const writeTrace2 = getLogFn(LogLevel.DEBUG, config, chalk2);
|
|
1133
|
-
return {
|
|
1134
|
-
fatal: writeFatal2,
|
|
1135
|
-
error: writeError2,
|
|
1136
|
-
warning: writeWarning2,
|
|
1137
|
-
info: writeInfo2,
|
|
1138
|
-
success: writeSuccess2,
|
|
1139
|
-
debug: writeDebug2,
|
|
1140
|
-
trace: writeTrace2,
|
|
1141
|
-
getStopwatch
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
__name(createLogger, "createLogger");
|
|
1145
|
-
|
|
1146
|
-
// ../build-tools/src/utilities/copy-assets.ts
|
|
1147
1118
|
import { glob } from "glob";
|
|
1148
1119
|
import { readFile as readFile2, writeFile } from "node:fs/promises";
|
|
1149
1120
|
|
|
@@ -1390,7 +1361,6 @@ import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-r
|
|
|
1390
1361
|
|
|
1391
1362
|
// src/build.ts
|
|
1392
1363
|
import defu4 from "defu";
|
|
1393
|
-
import { createJiti as createJiti2 } from "jiti";
|
|
1394
1364
|
import { existsSync as existsSync6 } from "node:fs";
|
|
1395
1365
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
1396
1366
|
import { relative as relative4 } from "node:path";
|
|
@@ -2874,18 +2844,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
|
|
|
2874
2844
|
name: "storm:on-error",
|
|
2875
2845
|
buildEnd(error) {
|
|
2876
2846
|
if (error) {
|
|
2877
|
-
|
|
2847
|
+
writeError(`The following errors occurred during the build:
|
|
2878
2848
|
${error ? error.message : "Unknown build error"}
|
|
2879
2849
|
|
|
2880
|
-
|
|
2850
|
+
`, resolvedOptions.config);
|
|
2881
2851
|
throw new Error("Storm unbuild process failed with errors.");
|
|
2882
2852
|
}
|
|
2883
2853
|
},
|
|
2884
2854
|
renderError(error) {
|
|
2885
|
-
|
|
2855
|
+
writeError(`The following errors occurred during the build:
|
|
2886
2856
|
${error ? error.message : "Unknown build error"}
|
|
2887
2857
|
|
|
2888
|
-
|
|
2858
|
+
`, resolvedOptions.config);
|
|
2889
2859
|
throw new Error("Storm unbuild process failed with errors.");
|
|
2890
2860
|
}
|
|
2891
2861
|
}), "onErrorPlugin");
|
|
@@ -2981,35 +2951,25 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name(async (options, resolvedOpti
|
|
|
2981
2951
|
].map((plugin) => Promise.resolve(plugin))), "getDefaultBuildPlugins");
|
|
2982
2952
|
|
|
2983
2953
|
// src/build.ts
|
|
2984
|
-
async function resolveOptions(options) {
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
throw new Error("Cannot find project root");
|
|
2988
|
-
}
|
|
2989
|
-
const outputPath = options.outputPath || joinPaths("dist", projectRoot);
|
|
2990
|
-
const workspaceRoot = findWorkspaceRoot2(projectRoot);
|
|
2991
|
-
if (!workspaceRoot) {
|
|
2992
|
-
throw new Error("Cannot find workspace root");
|
|
2993
|
-
}
|
|
2994
|
-
const config = await loadStormConfig(workspaceRoot.dir);
|
|
2995
|
-
const logger = await createLogger(config);
|
|
2996
|
-
logger.debug(" \u2699\uFE0F Resolving build options");
|
|
2997
|
-
const stopwatch = logger.getStopwatch("Build options resolution");
|
|
2954
|
+
async function resolveOptions(options, config) {
|
|
2955
|
+
writeDebug(" \u2699\uFE0F Resolving build options", config);
|
|
2956
|
+
const stopwatch = getStopwatch("Build options resolution");
|
|
2998
2957
|
if (options.configPath) {
|
|
2999
2958
|
const configFile = await loadConfig2(options.configPath);
|
|
3000
2959
|
if (configFile) {
|
|
3001
2960
|
options = defu4(options, configFile);
|
|
3002
2961
|
}
|
|
3003
2962
|
}
|
|
2963
|
+
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
3004
2964
|
const projectGraph = readCachedProjectGraph4();
|
|
3005
|
-
const projectJsonPath = joinPaths(config.workspaceRoot, projectRoot, "project.json");
|
|
2965
|
+
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
3006
2966
|
if (!existsSync6(projectJsonPath)) {
|
|
3007
2967
|
throw new Error("Cannot find project.json configuration");
|
|
3008
2968
|
}
|
|
3009
2969
|
const projectJsonContent = await readFile4(projectJsonPath, "utf8");
|
|
3010
2970
|
const projectJson = JSON.parse(projectJsonContent);
|
|
3011
2971
|
const projectName = projectJson.name;
|
|
3012
|
-
const packageJsonPath = joinPaths(workspaceRoot
|
|
2972
|
+
const packageJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "package.json");
|
|
3013
2973
|
if (!existsSync6(packageJsonPath)) {
|
|
3014
2974
|
throw new Error("Cannot find package.json configuration");
|
|
3015
2975
|
}
|
|
@@ -3017,51 +2977,45 @@ async function resolveOptions(options) {
|
|
|
3017
2977
|
const packageJson = JSON.parse(packageJsonContent);
|
|
3018
2978
|
let tsconfig = options.tsconfig;
|
|
3019
2979
|
if (!tsconfig) {
|
|
3020
|
-
tsconfig = joinPaths(workspaceRoot
|
|
2980
|
+
tsconfig = joinPaths(config.workspaceRoot, options.projectRoot, "tsconfig.json");
|
|
3021
2981
|
}
|
|
3022
2982
|
if (!existsSync6(tsconfig)) {
|
|
3023
2983
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
3024
2984
|
}
|
|
3025
2985
|
let sourceRoot = projectJson.sourceRoot;
|
|
3026
2986
|
if (!sourceRoot) {
|
|
3027
|
-
sourceRoot = joinPaths(projectRoot, "src");
|
|
2987
|
+
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
3028
2988
|
}
|
|
3029
2989
|
if (!existsSync6(sourceRoot)) {
|
|
3030
2990
|
throw new Error("Cannot find sourceRoot directory");
|
|
3031
2991
|
}
|
|
3032
|
-
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, workspaceRoot
|
|
2992
|
+
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
3033
2993
|
let dependencies = result.dependencies;
|
|
3034
2994
|
const tsLibDependency = getHelperDependency2(HelperDependency2.tsc, tsconfig, dependencies, projectGraph, true);
|
|
3035
2995
|
if (tsLibDependency) {
|
|
3036
2996
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
3037
2997
|
dependencies.push(tsLibDependency);
|
|
3038
2998
|
}
|
|
3039
|
-
const jiti = createJiti2(config.workspaceRoot, {
|
|
3040
|
-
fsCache: config.skipCache ? false : joinPaths(config.directories.cache || "node_modules/.cache/storm", "jiti"),
|
|
3041
|
-
interopDefault: true
|
|
3042
|
-
});
|
|
3043
2999
|
const resolvedOptions = {
|
|
3044
3000
|
name: projectName,
|
|
3045
3001
|
config,
|
|
3046
|
-
projectRoot,
|
|
3002
|
+
projectRoot: options.projectRoot,
|
|
3047
3003
|
sourceRoot,
|
|
3048
3004
|
projectName,
|
|
3049
3005
|
tsconfig,
|
|
3050
|
-
jiti,
|
|
3051
|
-
logger,
|
|
3052
3006
|
clean: false,
|
|
3053
3007
|
entries: [
|
|
3054
3008
|
{
|
|
3055
3009
|
builder: "mkdist",
|
|
3056
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
3057
|
-
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3010
|
+
input: `.${sourceRoot.replace(options.projectRoot, "")}`,
|
|
3011
|
+
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3058
3012
|
declaration: options.emitTypes !== false,
|
|
3059
3013
|
format: "esm"
|
|
3060
3014
|
},
|
|
3061
3015
|
{
|
|
3062
3016
|
builder: "mkdist",
|
|
3063
|
-
input: `.${sourceRoot.replace(projectRoot, "")}`,
|
|
3064
|
-
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3017
|
+
input: `.${sourceRoot.replace(options.projectRoot, "")}`,
|
|
3018
|
+
outDir: joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot).replaceAll("\\", "/"), outputPath, "dist").replaceAll("\\", "/"),
|
|
3065
3019
|
declaration: options.emitTypes !== false,
|
|
3066
3020
|
format: "cjs",
|
|
3067
3021
|
ext: "cjs"
|
|
@@ -3156,8 +3110,8 @@ async function resolveOptions(options) {
|
|
|
3156
3110
|
__name(resolveOptions, "resolveOptions");
|
|
3157
3111
|
async function generatePackageJson(options) {
|
|
3158
3112
|
if (options.generatePackageJson !== false && existsSync6(joinPaths(options.projectRoot, "package.json"))) {
|
|
3159
|
-
|
|
3160
|
-
const stopwatch =
|
|
3113
|
+
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
3114
|
+
const stopwatch = getStopwatch("Write package.json file");
|
|
3161
3115
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
3162
3116
|
if (!existsSync6(packageJsonPath)) {
|
|
3163
3117
|
throw new Error("Cannot find package.json configuration");
|
|
@@ -3176,8 +3130,8 @@ async function generatePackageJson(options) {
|
|
|
3176
3130
|
}
|
|
3177
3131
|
__name(generatePackageJson, "generatePackageJson");
|
|
3178
3132
|
async function executeUnbuild(options) {
|
|
3179
|
-
|
|
3180
|
-
const stopwatch =
|
|
3133
|
+
writeDebug(` \u{1F680} Running ${options.name} (${options.projectRoot}) build`, options.config);
|
|
3134
|
+
const stopwatch = getStopwatch(`${options.name} (${options.projectRoot}) build`);
|
|
3181
3135
|
try {
|
|
3182
3136
|
await build(options.projectRoot, false, {
|
|
3183
3137
|
...options,
|
|
@@ -3190,8 +3144,8 @@ async function executeUnbuild(options) {
|
|
|
3190
3144
|
}
|
|
3191
3145
|
__name(executeUnbuild, "executeUnbuild");
|
|
3192
3146
|
async function copyBuildAssets(options) {
|
|
3193
|
-
|
|
3194
|
-
const stopwatch =
|
|
3147
|
+
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`, options.config);
|
|
3148
|
+
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
3195
3149
|
await copyAssets(options.config, options.assets ?? [], options.outDir, options.projectRoot, options.projectName, options.sourceRoot, options.generatePackageJson, options.includeSrc);
|
|
3196
3150
|
stopwatch();
|
|
3197
3151
|
return options;
|
|
@@ -3199,8 +3153,8 @@ async function copyBuildAssets(options) {
|
|
|
3199
3153
|
__name(copyBuildAssets, "copyBuildAssets");
|
|
3200
3154
|
async function cleanOutputPath(options) {
|
|
3201
3155
|
if (options.clean !== false && options.outDir) {
|
|
3202
|
-
|
|
3203
|
-
const stopwatch =
|
|
3156
|
+
writeDebug(` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`, options.config);
|
|
3157
|
+
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
3204
3158
|
await cleanDirectories(options.name, options.outDir, options.config);
|
|
3205
3159
|
stopwatch();
|
|
3206
3160
|
}
|
|
@@ -3208,17 +3162,27 @@ async function cleanOutputPath(options) {
|
|
|
3208
3162
|
}
|
|
3209
3163
|
__name(cleanOutputPath, "cleanOutputPath");
|
|
3210
3164
|
async function build2(options) {
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3213
|
-
|
|
3165
|
+
const projectRoot = options.projectRoot;
|
|
3166
|
+
if (!projectRoot) {
|
|
3167
|
+
throw new Error("Cannot find project root");
|
|
3168
|
+
}
|
|
3169
|
+
const workspaceRoot = findWorkspaceRoot2(projectRoot);
|
|
3170
|
+
if (!workspaceRoot) {
|
|
3171
|
+
throw new Error("Cannot find workspace root");
|
|
3172
|
+
}
|
|
3173
|
+
const config = await loadStormConfig(workspaceRoot.dir);
|
|
3174
|
+
writeDebug(` \u26A1 Executing Storm Unbuild pipeline`, config);
|
|
3175
|
+
const stopwatch = getStopwatch("Unbuild pipeline");
|
|
3214
3176
|
try {
|
|
3177
|
+
options.projectRoot = projectRoot;
|
|
3178
|
+
const resolvedOptions = await resolveOptions(options, config);
|
|
3215
3179
|
await cleanOutputPath(resolvedOptions);
|
|
3216
3180
|
await generatePackageJson(resolvedOptions);
|
|
3217
3181
|
await executeUnbuild(resolvedOptions);
|
|
3218
3182
|
await copyBuildAssets(resolvedOptions);
|
|
3219
|
-
|
|
3183
|
+
writeSuccess(` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`, config);
|
|
3220
3184
|
} catch (error) {
|
|
3221
|
-
|
|
3185
|
+
writeFatal(" \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.", config);
|
|
3222
3186
|
throw error;
|
|
3223
3187
|
} finally {
|
|
3224
3188
|
stopwatch();
|
package/dist/build.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
3
|
+
var _chunkXGMJ3OUHcjs = require('./chunk-XGMJ3OUH.cjs');
|
|
4
|
+
require('./chunk-TRA2WJ3W.cjs');
|
|
5
|
+
require('./chunk-HO6B5DC7.cjs');
|
|
6
|
+
require('./chunk-KAXKUEZ7.cjs');
|
|
7
7
|
require('./chunk-SHHAZOHN.cjs');
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
10
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-UV35N5R4.cjs');
|
|
9
|
+
require('./chunk-XKHSZIHP.cjs');
|
|
10
|
+
require('./chunk-GHVDJY3S.cjs');
|
|
11
11
|
require('./chunk-YDYGZTJK.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.build =
|
|
14
|
+
exports.build = _chunkXGMJ3OUHcjs.build;
|
package/dist/build.d.cts
CHANGED
package/dist/build.d.ts
CHANGED
package/dist/build.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-DRQUQQ5D.js";
|
|
4
|
+
import "./chunk-JIVM7FQJ.js";
|
|
5
|
+
import "./chunk-TFMXUACY.js";
|
|
6
|
+
import "./chunk-VEX5RCZW.js";
|
|
7
7
|
import "./chunk-ESRR2FD2.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-YCGXRIUD.js";
|
|
9
|
+
import "./chunk-4RR7YISH.js";
|
|
10
|
+
import "./chunk-BRHZNXQM.js";
|
|
11
11
|
import "./chunk-3GQAWCBQ.js";
|
|
12
12
|
export {
|
|
13
13
|
build
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeError
|
|
3
|
+
} from "./chunk-BRHZNXQM.js";
|
|
1
4
|
import {
|
|
2
5
|
__name
|
|
3
6
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -7,18 +10,18 @@ var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
|
|
|
7
10
|
name: "storm:on-error",
|
|
8
11
|
buildEnd(error) {
|
|
9
12
|
if (error) {
|
|
10
|
-
|
|
13
|
+
writeError(`The following errors occurred during the build:
|
|
11
14
|
${error ? error.message : "Unknown build error"}
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
`, resolvedOptions.config);
|
|
14
17
|
throw new Error("Storm unbuild process failed with errors.");
|
|
15
18
|
}
|
|
16
19
|
},
|
|
17
20
|
renderError(error) {
|
|
18
|
-
|
|
21
|
+
writeError(`The following errors occurred during the build:
|
|
19
22
|
${error ? error.message : "Unknown build error"}
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
`, resolvedOptions.config);
|
|
22
25
|
throw new Error("Storm unbuild process failed with errors.");
|
|
23
26
|
}
|
|
24
27
|
}), "onErrorPlugin");
|
|
@@ -533,8 +533,11 @@ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CO
|
|
|
533
533
|
`);
|
|
534
534
|
};
|
|
535
535
|
}, "getLogFn");
|
|
536
|
+
var writeFatal = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.FATAL, config)(message), "writeFatal");
|
|
537
|
+
var writeError = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ERROR, config)(message), "writeError");
|
|
536
538
|
var writeWarning = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.WARN, config)(message), "writeWarning");
|
|
537
539
|
var writeInfo = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.INFO, config)(message), "writeInfo");
|
|
540
|
+
var writeSuccess = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.SUCCESS, config)(message), "writeSuccess");
|
|
538
541
|
var writeDebug = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.DEBUG, config)(message), "writeDebug");
|
|
539
542
|
var writeTrace = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.TRACE, config)(message), "writeTrace");
|
|
540
543
|
var writeSystem = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ALL, config)(message), "writeSystem");
|
|
@@ -587,9 +590,11 @@ export {
|
|
|
587
590
|
getLogLevel,
|
|
588
591
|
getLogLevelLabel,
|
|
589
592
|
isVerbose,
|
|
590
|
-
|
|
593
|
+
writeFatal,
|
|
594
|
+
writeError,
|
|
591
595
|
writeWarning,
|
|
592
596
|
writeInfo,
|
|
597
|
+
writeSuccess,
|
|
593
598
|
writeDebug,
|
|
594
599
|
writeTrace,
|
|
595
600
|
writeSystem,
|