@absolutejs/absolute 0.19.0-beta.755 → 0.19.0-beta.756

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/dist/cli/index.js CHANGED
@@ -812,6 +812,65 @@ ${serverOutput}` : "Server failed to start for pre-rendering";
812
812
  };
813
813
  var init_prerender = () => {};
814
814
 
815
+ // src/cli/scripts/build.ts
816
+ var exports_build = {};
817
+ __export(exports_build, {
818
+ build: () => build
819
+ });
820
+ import { resolve as resolve7 } from "path";
821
+ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, tryImportBuild2 = async (candidate) => {
822
+ try {
823
+ const mod = await import(candidate);
824
+ const buildFn = mod.build;
825
+ return buildFn;
826
+ } catch {
827
+ return null;
828
+ }
829
+ }, resolveBuildModule2 = async (candidates) => {
830
+ const [candidate, ...remaining] = candidates;
831
+ if (!candidate) {
832
+ return;
833
+ }
834
+ const mod = await tryImportBuild2(candidate);
835
+ if (mod) {
836
+ return mod;
837
+ }
838
+ return resolveBuildModule2(remaining);
839
+ }, build = async (outdir, configPath2) => {
840
+ const resolvedOutdir = resolve7(outdir ?? "build");
841
+ const buildStart = performance.now();
842
+ process.stdout.write(cliTag3("\x1B[36m", "Building assets"));
843
+ const buildConfig = await loadConfig(configPath2);
844
+ buildConfig.buildDirectory = resolvedOutdir;
845
+ buildConfig.mode = "production";
846
+ try {
847
+ const buildApp = await resolveBuildModule2([
848
+ resolve7(import.meta.dir, "..", "..", "core", "build"),
849
+ resolve7(import.meta.dir, "..", "build")
850
+ ]);
851
+ if (!buildApp)
852
+ throw new Error("Could not locate build module");
853
+ await buildApp(buildConfig);
854
+ } catch (err) {
855
+ sendTelemetryEvent("build:error", {
856
+ durationMs: Math.round(performance.now() - buildStart)
857
+ });
858
+ console.error(cliTag3("\x1B[31m", "Build step failed."));
859
+ console.error(err);
860
+ process.exit(1);
861
+ }
862
+ sendTelemetryEvent("build:complete", {
863
+ durationMs: Math.round(performance.now() - buildStart)
864
+ });
865
+ console.log(` \x1B[2m(${getDurationString(performance.now() - buildStart)})\x1B[0m`);
866
+ };
867
+ var init_build = __esm(() => {
868
+ init_getDurationString();
869
+ init_loadConfig();
870
+ init_startupBanner();
871
+ init_telemetryEvent();
872
+ });
873
+
815
874
  // src/cli/scripts/compile.ts
816
875
  var exports_compile = {};
817
876
  __export(exports_compile, {
@@ -819,8 +878,8 @@ __export(exports_compile, {
819
878
  });
820
879
  var {env: env3 } = globalThis.Bun;
821
880
  import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync9, unlinkSync as unlinkSync2 } from "fs";
822
- import { basename as basename2, join as join6, relative, resolve as resolve7 } from "path";
823
- var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
881
+ import { basename as basename2, join as join6, relative, resolve as resolve8 } from "path";
882
+ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
824
883
  const resolvedVersion = version2 || "unknown";
825
884
  console.log("");
826
885
  console.log(` \x1B[36m\x1B[1mABSOLUTEJS\x1B[0m \x1B[2mv${resolvedVersion}\x1B[0m \x1B[2mcompile\x1B[0m`);
@@ -856,7 +915,7 @@ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
856
915
  return version2;
857
916
  }
858
917
  return "";
859
- }, tryImportBuild2 = async (candidate) => {
918
+ }, tryImportBuild3 = async (candidate) => {
860
919
  try {
861
920
  const mod = await import(candidate);
862
921
  const buildFn = mod.build;
@@ -864,30 +923,30 @@ var cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
864
923
  } catch {
865
924
  return null;
866
925
  }
867
- }, resolveBuildModule2 = async (candidates) => {
926
+ }, resolveBuildModule3 = async (candidates) => {
868
927
  const [candidate, ...remaining] = candidates;
869
928
  if (!candidate) {
870
929
  return;
871
930
  }
872
- const mod = await tryImportBuild2(candidate);
931
+ const mod = await tryImportBuild3(candidate);
873
932
  if (mod) {
874
933
  return mod;
875
934
  }
876
- return resolveBuildModule2(remaining);
935
+ return resolveBuildModule3(remaining);
877
936
  }, resolveJsxDevRuntimeCompatPath2 = () => {
878
937
  const candidates = [
879
- resolve7(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
880
- resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
881
- resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
882
- resolve7(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
883
- resolve7(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
884
- resolve7(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
938
+ resolve8(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
939
+ resolve8(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
940
+ resolve8(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
941
+ resolve8(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
942
+ resolve8(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
943
+ resolve8(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
885
944
  ];
886
945
  for (const candidate of candidates) {
887
946
  if (existsSync9(candidate))
888
947
  return candidate;
889
948
  }
890
- return resolve7(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
949
+ return resolve8(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
891
950
  }, jsxDevRuntimeCompatPath2, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2) => {
892
951
  const allFiles = collectFiles2(distDir);
893
952
  const serverBundleName = `${basename2(serverEntry).replace(/\.[^.]+$/, "")}.js`;
@@ -1011,38 +1070,38 @@ console.log(\`
1011
1070
  const prerenderPort = Number(env3.COMPILE_PORT) || Number(env3.PORT) || DEFAULT_PORT + 1;
1012
1071
  killStaleProcesses(prerenderPort);
1013
1072
  const entryName = basename2(serverEntry).replace(/\.[^.]+$/, "");
1014
- const resolvedOutdir = resolve7(outdir ?? "dist");
1015
- const resolvedOutfile = resolve7(outfile ?? "compiled-server");
1073
+ const resolvedOutdir = resolve8(outdir ?? "dist");
1074
+ const resolvedOutfile = resolve8(outfile ?? "compiled-server");
1016
1075
  const absoluteVersion = resolvePackageVersion3([
1017
- resolve7(import.meta.dir, "..", "..", "..", "package.json"),
1018
- resolve7(import.meta.dir, "..", "..", "package.json")
1076
+ resolve8(import.meta.dir, "..", "..", "..", "package.json"),
1077
+ resolve8(import.meta.dir, "..", "..", "package.json")
1019
1078
  ]);
1020
1079
  compileBanner(absoluteVersion);
1021
1080
  const totalStart = performance.now();
1022
1081
  const buildStart = performance.now();
1023
- process.stdout.write(cliTag3("\x1B[36m", "Building assets"));
1082
+ process.stdout.write(cliTag4("\x1B[36m", "Building assets"));
1024
1083
  const buildConfig = await loadConfig(configPath2);
1025
1084
  buildConfig.buildDirectory = resolvedOutdir;
1026
1085
  buildConfig.mode = "production";
1027
1086
  try {
1028
- const build = await resolveBuildModule2([
1029
- resolve7(import.meta.dir, "..", "..", "core", "build"),
1030
- resolve7(import.meta.dir, "..", "build")
1087
+ const build2 = await resolveBuildModule3([
1088
+ resolve8(import.meta.dir, "..", "..", "core", "build"),
1089
+ resolve8(import.meta.dir, "..", "build")
1031
1090
  ]);
1032
- if (!build)
1091
+ if (!build2)
1033
1092
  throw new Error("Could not locate build module");
1034
- await build(buildConfig);
1093
+ await build2(buildConfig);
1035
1094
  } catch (err) {
1036
- console.error(cliTag3("\x1B[31m", "Build step failed."));
1095
+ console.error(cliTag4("\x1B[31m", "Build step failed."));
1037
1096
  console.error(err);
1038
1097
  process.exit(1);
1039
1098
  }
1040
1099
  console.log(` \x1B[2m(${getDurationString(performance.now() - buildStart)})\x1B[0m`);
1041
1100
  const bundleStart = performance.now();
1042
- process.stdout.write(cliTag3("\x1B[36m", "Bundling production server"));
1101
+ process.stdout.write(cliTag4("\x1B[36m", "Bundling production server"));
1043
1102
  const serverBundle = await Bun.build({
1044
1103
  define: { "process.env.NODE_ENV": '"production"' },
1045
- entrypoints: [resolve7(serverEntry)],
1104
+ entrypoints: [resolve8(serverEntry)],
1046
1105
  external: FRAMEWORK_EXTERNALS,
1047
1106
  outdir: resolvedOutdir,
1048
1107
  plugins: [stubPlugin],
@@ -1050,17 +1109,17 @@ console.log(\`
1050
1109
  });
1051
1110
  if (!serverBundle.success) {
1052
1111
  serverBundle.logs.forEach((log) => console.error(log));
1053
- console.error(cliTag3("\x1B[31m", "Server bundle failed."));
1112
+ console.error(cliTag4("\x1B[31m", "Server bundle failed."));
1054
1113
  process.exit(1);
1055
1114
  }
1056
- const outputPath = resolve7(resolvedOutdir, `${entryName}.js`);
1115
+ const outputPath = resolve8(resolvedOutdir, `${entryName}.js`);
1057
1116
  if (!existsSync9(outputPath)) {
1058
- console.error(cliTag3("\x1B[31m", `Expected output not found: ${outputPath}`));
1117
+ console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
1059
1118
  process.exit(1);
1060
1119
  }
1061
1120
  console.log(` \x1B[2m(${getDurationString(performance.now() - bundleStart)})\x1B[0m`);
1062
1121
  const prerenderStart = performance.now();
1063
- process.stdout.write(cliTag3("\x1B[36m", "Pre-rendering pages"));
1122
+ process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
1064
1123
  const staticConfig = buildConfig.static ?? { routes: "all" };
1065
1124
  const prerenderResult = await prerenderWithServer(outputPath, prerenderPort, resolvedOutdir, staticConfig, {
1066
1125
  ABSOLUTE_BUILD_DIR: resolvedOutdir,
@@ -1072,7 +1131,7 @@ console.log(\`
1072
1131
  const prerenderMap = prerenderResult.routes;
1073
1132
  console.log(` \x1B[2m(${prerenderMap.size} pages, ${getDurationString(performance.now() - prerenderStart)})\x1B[0m`);
1074
1133
  const compileStart = performance.now();
1075
- process.stdout.write(cliTag3("\x1B[36m", "Compiling standalone executable"));
1134
+ process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
1076
1135
  const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion);
1077
1136
  const entrypointPath = join6(resolvedOutdir, "_compile_entrypoint.ts");
1078
1137
  await Bun.write(entrypointPath, entrypointCode);
@@ -1084,7 +1143,7 @@ console.log(\`
1084
1143
  });
1085
1144
  if (!result.success) {
1086
1145
  result.logs.forEach((log) => console.error(log));
1087
- console.error(cliTag3("\x1B[31m", "Compilation failed."));
1146
+ console.error(cliTag4("\x1B[31m", "Compilation failed."));
1088
1147
  process.exit(1);
1089
1148
  }
1090
1149
  console.log(` \x1B[2m(${getDurationString(performance.now() - compileStart)})\x1B[0m`);
@@ -1094,8 +1153,8 @@ console.log(\`
1094
1153
  const BYTES_PER_MB = 1048576;
1095
1154
  const size = (Bun.file(resolvedOutfile).size / BYTES_PER_MB).toFixed(0);
1096
1155
  const totalDuration = getDurationString(performance.now() - totalStart);
1097
- console.log(cliTag3("\x1B[32m", `Compiled to ${resolvedOutfile} (${size}MB) in ${totalDuration}`));
1098
- console.log(cliTag3("\x1B[2m", `Run with: ./${basename2(resolvedOutfile)}`));
1156
+ console.log(cliTag4("\x1B[32m", `Compiled to ${resolvedOutfile} (${size}MB) in ${totalDuration}`));
1157
+ console.log(cliTag4("\x1B[2m", `Run with: ./${basename2(resolvedOutfile)}`));
1099
1158
  sendTelemetryEvent("compile:complete", {
1100
1159
  durationMs: Math.round(performance.now() - totalStart),
1101
1160
  entry: serverEntry,
@@ -1195,7 +1254,7 @@ var exports_typecheck = {};
1195
1254
  __export(exports_typecheck, {
1196
1255
  typecheck: () => typecheck
1197
1256
  });
1198
- import { resolve as resolve8, join as join7 } from "path";
1257
+ import { resolve as resolve9, join as join7 } from "path";
1199
1258
  import { existsSync as existsSync10 } from "fs";
1200
1259
  import { mkdir as mkdir2, writeFile } from "fs/promises";
1201
1260
  var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), getTypecheckTargets = async (configPath2) => {
@@ -1216,7 +1275,7 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
1216
1275
  const exitCode = await proc.exited;
1217
1276
  return { exitCode, name, output: (stdout + stderr).trim() };
1218
1277
  }, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
1219
- const local = resolve8("node_modules", ".bin", name);
1278
+ const local = resolve9("node_modules", ".bin", name);
1220
1279
  return existsSync10(local) ? local : null;
1221
1280
  }, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi3 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
1222
1281
  const cwd = `${process.cwd()}/`;
@@ -1264,10 +1323,10 @@ Found ${errorCount} error${suffix}.`;
1264
1323
  return formatted;
1265
1324
  }, TYPECHECK_EXCLUDE, TYPECHECK_INCLUDE, resolveAbsoluteTypeFile = (fileName) => {
1266
1325
  const candidates = [
1267
- resolve8("node_modules/@absolutejs/absolute/dist/types", fileName),
1268
- resolve8(import.meta.dir, "../types", fileName),
1269
- resolve8(import.meta.dir, "../../types", fileName),
1270
- resolve8(import.meta.dir, "../../../types", fileName)
1326
+ resolve9("node_modules/@absolutejs/absolute/dist/types", fileName),
1327
+ resolve9(import.meta.dir, "../types", fileName),
1328
+ resolve9(import.meta.dir, "../../types", fileName),
1329
+ resolve9(import.meta.dir, "../../../types", fileName)
1271
1330
  ];
1272
1331
  return candidates.find((candidate) => existsSync10(candidate)) ?? candidates[0];
1273
1332
  }, ABSOLUTE_TYPECHECK_INCLUDE, ABSOLUTE_TYPECHECK_FILES, buildVueTscCheck = (cacheDir) => {
@@ -1282,14 +1341,14 @@ Found ${errorCount} error${suffix}.`;
1282
1341
  rootDir: ".."
1283
1342
  },
1284
1343
  exclude: TYPECHECK_EXCLUDE,
1285
- extends: resolve8("tsconfig.json"),
1344
+ extends: resolve9("tsconfig.json"),
1286
1345
  files: ABSOLUTE_TYPECHECK_FILES,
1287
1346
  include: ABSOLUTE_TYPECHECK_INCLUDE
1288
1347
  }, null, "\t")).then(() => run("vue-tsc", [
1289
1348
  vueTscBin,
1290
1349
  "--noEmit",
1291
1350
  "--project",
1292
- resolve8(vueTsconfigPath),
1351
+ resolve9(vueTsconfigPath),
1293
1352
  "--incremental",
1294
1353
  "--tsBuildInfoFile",
1295
1354
  join7(cacheDir, "vue-tsc.tsbuildinfo"),
@@ -1311,10 +1370,10 @@ Found ${errorCount} error${suffix}.`;
1311
1370
  rootDir: ".."
1312
1371
  },
1313
1372
  exclude: TYPECHECK_EXCLUDE,
1314
- extends: resolve8("tsconfig.json"),
1373
+ extends: resolve9("tsconfig.json"),
1315
1374
  include: [`../${angularDir}/**/*`]
1316
1375
  }, null, "\t"));
1317
- return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve8(angularTsconfigPath))}`);
1376
+ return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve9(angularTsconfigPath))}`);
1318
1377
  }, buildTscCheck = (cacheDir) => {
1319
1378
  const tscBin = findBin("tsc");
1320
1379
  if (!tscBin) {
@@ -1327,14 +1386,14 @@ Found ${errorCount} error${suffix}.`;
1327
1386
  rootDir: ".."
1328
1387
  },
1329
1388
  exclude: TYPECHECK_EXCLUDE,
1330
- extends: resolve8("tsconfig.json"),
1389
+ extends: resolve9("tsconfig.json"),
1331
1390
  files: ABSOLUTE_TYPECHECK_FILES,
1332
1391
  include: ABSOLUTE_TYPECHECK_INCLUDE
1333
1392
  }, null, "\t")).then(() => run("tsc", [
1334
1393
  tscBin,
1335
1394
  "--noEmit",
1336
1395
  "--project",
1337
- resolve8(tscConfigPath),
1396
+ resolve9(tscConfigPath),
1338
1397
  "--incremental",
1339
1398
  "--tsBuildInfoFile",
1340
1399
  join7(cacheDir, "tsc.tsbuildinfo"),
@@ -1348,14 +1407,14 @@ Found ${errorCount} error${suffix}.`;
1348
1407
  }
1349
1408
  const svelteTsconfigPath = join7(cacheDir, "tsconfig.svelte-check.json");
1350
1409
  await writeFile(svelteTsconfigPath, JSON.stringify({
1351
- extends: resolve8("tsconfig.json"),
1410
+ extends: resolve9("tsconfig.json"),
1352
1411
  files: ABSOLUTE_TYPECHECK_FILES,
1353
1412
  include: [`../${svelteDir}/**/*`]
1354
1413
  }, null, "\t"));
1355
1414
  return run("svelte-check", [
1356
1415
  svelteBin,
1357
1416
  "--tsconfig",
1358
- resolve8(svelteTsconfigPath),
1417
+ resolve9(svelteTsconfigPath),
1359
1418
  "--threshold",
1360
1419
  "error",
1361
1420
  "--compiler-warnings",
@@ -4033,6 +4092,12 @@ if (command === "dev") {
4033
4092
  const positionalArgs = stripNamedArgs("--outdir", "--config");
4034
4093
  const serverEntry = positionalArgs[0] ?? DEFAULT_SERVER_ENTRY;
4035
4094
  await start(serverEntry, outdir, configPath2);
4095
+ } else if (command === "build") {
4096
+ sendTelemetryEvent("cli:command", { command });
4097
+ const outdir = parseNamedArg("--outdir");
4098
+ const configPath2 = parseNamedArg("--config");
4099
+ const { build: build2 } = await Promise.resolve().then(() => (init_build(), exports_build));
4100
+ await build2(outdir, configPath2);
4036
4101
  } else if (command === "workspace") {
4037
4102
  sendTelemetryEvent("cli:command", {
4038
4103
  command: `workspace:${workspaceCommand ?? "unknown"}`
@@ -4076,6 +4141,7 @@ if (command === "dev") {
4076
4141
  console.error("Commands:");
4077
4142
  console.error(" dev [entry] Start development server");
4078
4143
  console.error(" workspace dev Start multi-service workspace dev");
4144
+ console.error(" build [--outdir dir] Build production assets");
4079
4145
  console.error(" start [entry] [--outdir dir] Start production server");
4080
4146
  console.error(" compile [entry] [--outdir dir] [--outfile path] Compile standalone executable");
4081
4147
  console.error(" eslint Run ESLint (cached)");
@@ -0,0 +1 @@
1
+ export declare const build: (outdir?: string, configPath?: string) => Promise<void>;
package/package.json CHANGED
@@ -187,12 +187,12 @@
187
187
  "main": "./dist/index.js",
188
188
  "name": "@absolutejs/absolute",
189
189
  "optionalDependencies": {
190
- "@absolutejs/native-darwin-arm64": "0.19.0-beta.704",
191
- "@absolutejs/native-darwin-x64": "0.19.0-beta.704",
192
- "@absolutejs/native-linux-arm64": "0.19.0-beta.704",
193
- "@absolutejs/native-linux-x64": "0.19.0-beta.704",
194
- "@absolutejs/native-windows-arm64": "0.19.0-beta.704",
195
- "@absolutejs/native-windows-x64": "0.19.0-beta.704"
190
+ "@absolutejs/native-darwin-arm64": "0.19.0-beta.756",
191
+ "@absolutejs/native-darwin-x64": "0.19.0-beta.756",
192
+ "@absolutejs/native-linux-arm64": "0.19.0-beta.756",
193
+ "@absolutejs/native-linux-x64": "0.19.0-beta.756",
194
+ "@absolutejs/native-windows-arm64": "0.19.0-beta.756",
195
+ "@absolutejs/native-windows-x64": "0.19.0-beta.756"
196
196
  },
197
197
  "overrides": {
198
198
  "@typescript-eslint/utils": "8.56.1"
@@ -349,5 +349,5 @@
349
349
  ]
350
350
  }
351
351
  },
352
- "version": "0.19.0-beta.755"
352
+ "version": "0.19.0-beta.756"
353
353
  }