heximon 0.27.0 → 0.28.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 CHANGED
@@ -230,6 +230,12 @@ the fix instructions plus a non-zero exit code.
230
230
  committed file, `--startup` fails and says how to write one. The starters do not run `--startup`.
231
231
  When an app has no usable route rows, the check prints one line with the first reason, and `--json` carries
232
232
  it in `startupNotes`. The `http/route-rows-fallback` warning gives every reason.
233
+ - **`heximon check --startup` records each hostless app.** A Durable Object that `cloudflare.durableObjectGraphs`
234
+ lists boots a hostless app: only the module that lists it and the modules that this module imports.
235
+ `heximon.startup.json` records the modules of each hostless app, and a module that joins one fails the check.
236
+ A module that leaves it, a new hostless app and a removed one are notes. With build output, the check also
237
+ prints the static closure of the chunk that holds the app's boot file, as a note only. `--json` carries both in
238
+ `startupHostlessApps`.
233
239
  - **`heximon check --startup` also checks the size of the built server code.** Each production build (`vp build`,
234
240
  or a Nitro or Nuxt build) records each server entry that it deploys in `.heximon/server-build.json`: the main
235
241
  entry, and the `dist/edge.js` bundle of a Vercel or Netlify build with edge controllers. From each entry, the
package/dist/bin.mjs CHANGED
@@ -5,7 +5,7 @@ import { cancel, confirm, intro, isCancel, log, outro, select, spinner } from "@
5
5
  import process from "node:process";
6
6
  import { defineCommand } from "citty";
7
7
  import { existsSync, globSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
8
- import { AstNodeType, CompileEnvironment, CompileMode, DeployPlatform, DiagnosticCode, DiagnosticRenderMode, DiagnosticRenderer, DiagnosticSeverity, ImportKind, ReexportIndex, RuntimeConfigFile, RuntimeSingletons, StartReasonKind, StartupBaselineFile, StartupChangeKind, StartupSizeBudget, StartupSizeChangeKind, StartupSizeMeasure, TerminalStyle, UpgradeBaselineFile } from "@heximon/compiler";
8
+ import { AstNodeType, CompileEnvironment, CompileMode, DeployPlatform, DiagnosticCode, DiagnosticRenderMode, DiagnosticRenderer, DiagnosticSeverity, ImportKind, ReexportIndex, RuntimeConfigFile, RuntimeSingletons, StartReasonKind, StartReportRole, StartupBaselineFile, StartupChangeKind, StartupSizeBudget, StartupSizeChangeKind, StartupSizeMeasure, TerminalStyle, UpgradeBaselineFile } from "@heximon/compiler";
9
9
  import { spawn } from "node:child_process";
10
10
  import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
11
11
  import tab from "@bomb.sh/tab/citty";
@@ -64,6 +64,15 @@ const StartupTargetSource = {
64
64
  /** The Nitro preset that the last production Nuxt run recorded in `.heximon/nuxt-target.json`. */
65
65
  NuxtRun: "nuxt-run"
66
66
  };
67
+ /** Why `heximon check --startup` has no size for the chunk of a hostless app. */
68
+ const CheckHostlessSizeUnavailable = {
69
+ /** The build record does not name the generated files of its chunks. */
70
+ NoChunkRecord: "no-chunk-record",
71
+ /** No chunk of the build holds the boot file of the app. The build is older than the compile. */
72
+ NoChunk: "no-chunk",
73
+ /** The size walk of the server entry does not reach the chunk. */
74
+ NotReached: "not-reached"
75
+ };
67
76
  //#endregion
68
77
  //#region src/compile-diagnostics.ts
69
78
  /**
@@ -1281,7 +1290,7 @@ var StartupBaseline = class StartupBaseline {
1281
1290
  const target = join(rootDir, StartupBaselineFile.fileName);
1282
1291
  const committed = StartupBaseline.readCommitted(target);
1283
1292
  const cliCodes = /* @__PURE__ */ new Map();
1284
- if (committed === void 0 || committed.apps === void 0) {
1293
+ if (committed === void 0 || committed.records === void 0) {
1285
1294
  const missing = committed === void 0;
1286
1295
  const diagnostic = {
1287
1296
  severity: DiagnosticSeverity.Error,
@@ -1301,12 +1310,12 @@ var StartupBaseline = class StartupBaseline {
1301
1310
  notes: []
1302
1311
  };
1303
1312
  }
1304
- const comparison = StartupBaselineFile.compare(committed.apps, reports);
1313
+ const comparison = StartupBaselineFile.compareRecords(committed.records, reports);
1305
1314
  const diagnostics = comparison.growth.map((change) => {
1306
1315
  const diagnostic = {
1307
1316
  severity: DiagnosticSeverity.Error,
1308
1317
  message: StartupBaseline.growthMessage(change),
1309
- hint: `Make the package wait for its first use (see the reasons), or accept the growth: run \`${StartupBaseline.updateCommand}\` and commit the file.`
1318
+ hint: change.kind === StartupChangeKind.HostlessGrowth ? `Find the import that brings the module into the hostless app, or accept the growth: run \`${StartupBaseline.updateCommand}\` and commit the file.` : `Make the package wait for its first use (see the reasons), or accept the growth: run \`${StartupBaseline.updateCommand}\` and commit the file.`
1310
1319
  };
1311
1320
  cliCodes.set(diagnostic, CheckDiagnosticCode.StartupGrowth);
1312
1321
  return diagnostic;
@@ -1331,7 +1340,7 @@ var StartupBaseline = class StartupBaseline {
1331
1340
  */
1332
1341
  static committedDocument(rootDir) {
1333
1342
  const committed = StartupBaseline.readCommitted(join(rootDir, StartupBaselineFile.fileName));
1334
- return committed?.apps === void 0 ? void 0 : committed.document;
1343
+ return committed?.records === void 0 ? void 0 : committed.document;
1335
1344
  }
1336
1345
  /**
1337
1346
  * Writes the file for the start reports of a compile when it differs from the committed one. The other
@@ -1359,6 +1368,7 @@ var StartupBaseline = class StartupBaseline {
1359
1368
  switch (change.kind) {
1360
1369
  case StartupChangeKind.NewApp: return `app '${change.app}' has no record in ${file}, so every package of its start is new.`;
1361
1370
  case StartupChangeKind.EntryGrowth: return `app '${change.app}': the first use of '${change.place}' now loads '${change.package}', and ${file} does not list it for this entry.`;
1371
+ case StartupChangeKind.HostlessGrowth: return `hostless app '${change.app}': the module '${change.module}' is now in the app, and ${file} does not list it there.`;
1362
1372
  default: return `app '${change.app}': '${change.package}' now loads at the start, and ${file} does not list it there. Reasons: ${(change.reasons ?? []).join("; ")}.`;
1363
1373
  }
1364
1374
  }
@@ -1372,11 +1382,14 @@ var StartupBaseline = class StartupBaseline {
1372
1382
  case StartupChangeKind.RemovedEntry: return `app '${change.app}': '${change.place}' is no longer an entry.`;
1373
1383
  case StartupChangeKind.RemovedApp: return `app '${change.app}' is no longer built.`;
1374
1384
  case StartupChangeKind.TargetChanged: return `app '${change.app}': the deploy target changed whether it defers packages.`;
1385
+ case StartupChangeKind.HostlessShrink: return `hostless app '${change.app}': the module '${change.module}' is no longer in the app.`;
1386
+ case StartupChangeKind.NewHostless: return `hostless app '${change.app}' is new.`;
1387
+ case StartupChangeKind.RemovedHostless: return `hostless app '${change.app}' is no longer built.`;
1375
1388
  default: return `app '${change.app}': '${change.package}' loads at the start for other reasons: ${(change.reasons ?? []).join("; ")}.`;
1376
1389
  }
1377
1390
  });
1378
1391
  if (lines.length === 0) return [];
1379
- const shrinks = notes.some((change) => change.kind === StartupChangeKind.StartShrink || change.kind === StartupChangeKind.EntryShrink);
1392
+ const shrinks = notes.some((change) => change.kind === StartupChangeKind.StartShrink || change.kind === StartupChangeKind.EntryShrink || change.kind === StartupChangeKind.HostlessShrink);
1380
1393
  return [...lines, shrinks ? `The app loads less than ${StartupBaselineFile.fileName} records. Run \`${StartupBaseline.updateCommand}\` to make the baseline smaller.` : `Run \`${StartupBaseline.updateCommand}\` to record these changes.`];
1381
1394
  }
1382
1395
  /** The committed file's text, its parsed form, and its app records, or `undefined` when the file is absent. */
@@ -1396,7 +1409,7 @@ var StartupBaseline = class StartupBaseline {
1396
1409
  return {
1397
1410
  content,
1398
1411
  document,
1399
- apps: StartupBaselineFile.parse(document)
1412
+ records: StartupBaselineFile.parseRecords(document)
1400
1413
  };
1401
1414
  }
1402
1415
  };
@@ -1929,7 +1942,7 @@ var StartupEntriesReport = class StartupEntriesReport {
1929
1942
  const serverEntry = measured?.entries.find((entry) => entry.name === ServerBuildRecord.mainEntryName) ?? measured?.entries[0];
1930
1943
  const chunks = serverEntry === void 0 ? void 0 : measured?.chunks;
1931
1944
  const bytesUnavailable = measuring.kind === "skipped" ? measuring.result.reason : chunks === void 0 ? "no-chunk-record" : void 0;
1932
- const apps = reports.map((report) => StartupEntriesReport.appReport(report, serverEntry === void 0 || chunks === void 0 ? void 0 : new StartupBuiltCode(serverEntry, chunks, measured?.generated, report.loads?.loaders), top));
1945
+ const apps = reports.filter((report) => report.role !== StartReportRole.Hostless).map((report) => StartupEntriesReport.appReport(report, serverEntry === void 0 || chunks === void 0 ? void 0 : new StartupBuiltCode(serverEntry, chunks, measured?.generated, report.loads?.loaders), top));
1933
1946
  const notice = measuring.kind === "skipped" ? `${measuring.message.replace(" The size check of the server code is skipped.", "")} The entries report has no bytes.` : chunks === void 0 ? `The build record ${ServerBuildRecord.relativePath} does not have the packages of its chunks, so the entries report has no bytes. Build the app again with this version of Heximon.` : void 0;
1934
1947
  return {
1935
1948
  result: {
@@ -2135,6 +2148,83 @@ var StartupEntriesReport = class StartupEntriesReport {
2135
2148
  }
2136
2149
  };
2137
2150
  //#endregion
2151
+ //#region src/startup-hostless-report.ts
2152
+ /**
2153
+ * The hostless apps of `heximon check --startup`: the modules of each app, from the start reports, and the static
2154
+ * closure of the chunk that holds its boot file, from the build output. The size is a note: it fails nothing.
2155
+ */
2156
+ var StartupHostlessReport = class StartupHostlessReport {
2157
+ /**
2158
+ * The report of the hostless apps of a compile.
2159
+ *
2160
+ * @param reports - The start report of each app. Only the records of hostless apps count.
2161
+ * @param measuring - The measurement of the build output, when the run measured it.
2162
+ */
2163
+ static report(reports, measuring) {
2164
+ const measured = measuring?.kind === "measured" ? measuring : void 0;
2165
+ const serverEntry = measured?.entries.find((entry) => entry.name === ServerBuildRecord.mainEntryName) ?? measured?.entries[0];
2166
+ const apps = reports.filter((report) => report.role === StartReportRole.Hostless).map((report) => {
2167
+ const base = {
2168
+ app: report.app,
2169
+ subject: report.subject ?? report.app,
2170
+ modules: report.modules ?? []
2171
+ };
2172
+ if (serverEntry === void 0 || report.bootFile === void 0) return base;
2173
+ const size = StartupHostlessReport.sizeOf(report.bootFile, serverEntry, measured?.generated);
2174
+ return typeof size === "string" ? {
2175
+ ...base,
2176
+ sizeUnavailable: size
2177
+ } : {
2178
+ ...base,
2179
+ size
2180
+ };
2181
+ });
2182
+ return {
2183
+ apps,
2184
+ lines: apps.map((app) => StartupHostlessReport.line(app, serverEntry?.measurement.entry))
2185
+ };
2186
+ }
2187
+ /** The static closure of the chunk that holds a boot file, or why there is none. */
2188
+ static sizeOf(bootFile, serverEntry, generated) {
2189
+ if (generated === void 0) return CheckHostlessSizeUnavailable.NoChunkRecord;
2190
+ const chunk = Object.keys(generated).sort().find((fileName) => generated[fileName].includes(bootFile));
2191
+ if (chunk === void 0) return CheckHostlessSizeUnavailable.NoChunk;
2192
+ const files = new Map(serverEntry.measurement.files.map((file) => [file.path, file]));
2193
+ const chunkFile = files.get(chunk);
2194
+ if (chunkFile === void 0) return CheckHostlessSizeUnavailable.NotReached;
2195
+ const reached = /* @__PURE__ */ new Set([chunk]);
2196
+ const pending = [chunk];
2197
+ for (let path = pending.pop(); path !== void 0; path = pending.pop()) for (const target of serverEntry.staticImports[path] ?? []) if (!reached.has(target)) {
2198
+ reached.add(target);
2199
+ pending.push(target);
2200
+ }
2201
+ return {
2202
+ chunk,
2203
+ start: {
2204
+ files: reached.size,
2205
+ bytes: [...reached].reduce((sum, path) => sum + (files.get(path)?.bytes ?? 0), 0)
2206
+ },
2207
+ ...chunkFile.isStart ? { inStartClosure: true } : {}
2208
+ };
2209
+ }
2210
+ /** The text line of one hostless app. */
2211
+ static line(app, entry) {
2212
+ const count = app.modules.length;
2213
+ const head = `Hostless app '${app.app}' (${app.subject}) has ${count} module${count === 1 ? "" : "s"}${count === 0 ? "" : `: ${app.modules.join(", ")}`}.`;
2214
+ if (app.size !== void 0) {
2215
+ const { files, bytes } = app.size.start;
2216
+ const closure = `${head} The static closure of its chunk ${app.size.chunk} has ${files} file${files === 1 ? "" : "s"}, ${StartupSizeCheck.formatBytes(bytes)}.`;
2217
+ return app.size.inStartClosure === true ? `${closure} The chunk is also in the static start closure of ${entry ?? "the server entry"}, so this code loads with the start and adds no startup cost of its own. The closure can also hold code of the main app's start.` : closure;
2218
+ }
2219
+ switch (app.sizeUnavailable) {
2220
+ case CheckHostlessSizeUnavailable.NoChunkRecord: return `${head} The build record ${ServerBuildRecord.relativePath} does not name the generated files of its chunks, so the app has no size. Build the app again with this version of Heximon.`;
2221
+ case CheckHostlessSizeUnavailable.NoChunk: return `${head} No chunk of the build holds its boot file, so the app has no size. Build the app again.`;
2222
+ case CheckHostlessSizeUnavailable.NotReached: return `${head} The size walk of ${entry ?? "the server entry"} does not reach the chunk of its boot file, so the app has no size.`;
2223
+ default: return head;
2224
+ }
2225
+ }
2226
+ };
2227
+ //#endregion
2138
2228
  //#region src/project-modules.ts
2139
2229
  /**
2140
2230
  * Imports packages the way the generated wiring imports them: through a small module written into the
@@ -2875,6 +2965,7 @@ const checkCommand = defineCommand({
2875
2965
  app: report.app,
2876
2966
  ...note
2877
2967
  }))) : void 0;
2968
+ const hostlessReport = startup && startupReports !== void 0 ? StartupHostlessReport.report(startupReports, sizeMeasuring) : void 0;
2878
2969
  const entriesReport = entries && startupReports !== void 0 && sizeMeasuring !== void 0 ? StartupEntriesReport.report(startupReports, sizeMeasuring, top) : void 0;
2879
2970
  const sizeResult = sizeMeasuring?.kind === "skipped" ? sizeMeasuring.result : sizeCompared?.result ?? sizeUpdated?.result;
2880
2971
  const diagnostics = [
@@ -2914,6 +3005,7 @@ const checkCommand = defineCommand({
2914
3005
  ...sizeResult === void 0 ? {} : { startupSize: sizeResult },
2915
3006
  ...entriesReport === void 0 ? {} : { startupEntries: entriesReport.result },
2916
3007
  ...startupNotes === void 0 ? {} : { startupNotes },
3008
+ ...hostlessReport === void 0 || hostlessReport.apps.length === 0 ? {} : { startupHostlessApps: hostlessReport.apps },
2917
3009
  ...startup && mode === CompileMode.App && checked.staleLibraries !== true ? { startupBaseline: startupChecked?.result ?? (startupUpdated === void 0 ? {
2918
3010
  action: "update",
2919
3011
  written: false,
@@ -2956,6 +3048,7 @@ const checkCommand = defineCommand({
2956
3048
  log.info(sizeNotes.join("\n"));
2957
3049
  if (sizeCompared?.result.action === "compare" && sizeCompared.result.committed && sizeCompared.result.growth.length === 0 && sizeCompared.result.notes.length === 0) log.success(`The server code is inside the size budget of ${StartupBaselineFile.fileName}.`);
2958
3050
  }
3051
+ for (const line of hostlessReport?.lines ?? []) log.info(line);
2959
3052
  for (const line of entriesReport?.lines ?? []) log.info(line);
2960
3053
  if (mode === CompileMode.Library && upgradeUpdate) log.warn(`${UpgradeBaselineFile.fileName} is an app-level artifact — a library's durable surface is baselined by each app that composes it, so there is nothing here to update.`);
2961
3054
  else if (previewed !== void 0) {
package/dist/index.d.mts CHANGED
@@ -422,6 +422,41 @@ interface CheckStartupNote {
422
422
  /** One sentence. */
423
423
  readonly message: string;
424
424
  }
425
+ /** Why `heximon check --startup` has no size for the chunk of a hostless app. */
426
+ declare const CheckHostlessSizeUnavailable: {
427
+ /** The build record does not name the generated files of its chunks. */
428
+ readonly NoChunkRecord: "no-chunk-record";
429
+ /** No chunk of the build holds the boot file of the app. The build is older than the compile. */
430
+ readonly NoChunk: "no-chunk";
431
+ /** The size walk of the server entry does not reach the chunk. */
432
+ readonly NotReached: "not-reached";
433
+ };
434
+ /** One of the {@link CheckHostlessSizeUnavailable} values. */
435
+ type CheckHostlessSizeUnavailable = (typeof CheckHostlessSizeUnavailable)[keyof typeof CheckHostlessSizeUnavailable];
436
+ /**
437
+ * A hostless app of the compile: an extra app that boots only some modules, such as the app of a Durable Object
438
+ * that `cloudflare.durableObjectGraphs` lists. `heximon.startup.json` records its modules.
439
+ */
440
+ interface CheckStartupHostlessApp {
441
+ readonly app: string;
442
+ /** What boots the app, for example "the Durable Object `StorageRoomDO`". */
443
+ readonly subject: string;
444
+ /** The identity of each module and composed package of the app, sorted. */
445
+ readonly modules: readonly string[];
446
+ /**
447
+ * The static closure of the chunk that holds the app's boot file, with build output: the chunk, relative to
448
+ * the output directory, and every file that it loads through static imports. A note only: it fails nothing.
449
+ * `inStartClosure` is `true` when the chunk is also in the static start closure of the server entry: the
450
+ * code then loads with the start, and the closure can hold code of the main app's start.
451
+ */
452
+ readonly size?: {
453
+ readonly chunk: string;
454
+ readonly start: ServerCodeSize;
455
+ readonly inStartClosure?: true;
456
+ };
457
+ /** Why the app has no {@link size}, with build output. */
458
+ readonly sizeUnavailable?: CheckHostlessSizeUnavailable;
459
+ }
425
460
  /** The `heximon check --json` document. */
426
461
  interface CheckJsonDocument extends CliJsonDocument {
427
462
  /** Which compile ran: `app`, or `library` for a published module package. */
@@ -448,6 +483,8 @@ interface CheckJsonDocument extends CliJsonDocument {
448
483
  readonly startupEntries?: CheckStartupEntriesResult;
449
484
  /** The facts that the plugins state about the start of each app, present only with `--startup` in an app. */
450
485
  readonly startupNotes?: readonly CheckStartupNote[];
486
+ /** The hostless apps of the compile, present only with `--startup` in an app that has one. */
487
+ readonly startupHostlessApps?: readonly CheckStartupHostlessApp[];
451
488
  }
452
489
  //#endregion
453
490
  //#region src/prompter.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heximon",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "The Heximon CLI: create, develop, build, migrate, and deploy Heximon apps.",
5
5
  "keywords": [
6
6
  "cli",
@@ -38,28 +38,28 @@
38
38
  "dependencies": {
39
39
  "@bomb.sh/tab": "^0.0.22",
40
40
  "@clack/prompts": "^1.8.1",
41
- "@heximon/compiler": "0.27.0",
42
- "@heximon/cqrs": "0.27.0",
43
- "@heximon/deploy": "0.27.0",
44
- "@heximon/http": "0.27.0",
45
- "@heximon/node": "0.27.0",
46
- "@heximon/runtime": "0.27.0",
47
- "@heximon/testing": "0.27.0",
41
+ "@heximon/compiler": "0.28.0",
42
+ "@heximon/cqrs": "0.28.0",
43
+ "@heximon/deploy": "0.28.0",
44
+ "@heximon/http": "0.28.0",
45
+ "@heximon/node": "0.28.0",
46
+ "@heximon/runtime": "0.28.0",
47
+ "@heximon/testing": "0.28.0",
48
48
  "citty": "^0.2.2",
49
49
  "giget": "^3.3.1",
50
50
  "pathe": "^2.0.3"
51
51
  },
52
52
  "devDependencies": {
53
- "@heximon/build": "0.27.0",
54
- "@heximon/cloudflare": "0.27.0",
55
- "@heximon/durable": "0.27.0",
56
- "@heximon/integration": "0.27.0",
57
- "@heximon/library": "0.27.0",
58
- "@heximon/nitro": "0.27.0",
59
- "@heximon/otel": "0.27.0",
60
- "@heximon/queue": "0.27.0",
61
- "@heximon/schedule": "0.27.0",
62
- "@heximon/schema": "0.27.0",
53
+ "@heximon/build": "0.28.0",
54
+ "@heximon/cloudflare": "0.28.0",
55
+ "@heximon/durable": "0.28.0",
56
+ "@heximon/integration": "0.28.0",
57
+ "@heximon/library": "0.28.0",
58
+ "@heximon/nitro": "0.28.0",
59
+ "@heximon/otel": "0.28.0",
60
+ "@heximon/queue": "0.28.0",
61
+ "@heximon/schedule": "0.28.0",
62
+ "@heximon/schema": "0.28.0",
63
63
  "@heximon/test-support": "0.0.1",
64
64
  "@types/node": "^24.19.0",
65
65
  "@typescript/native-preview": "^7.0.0-dev.20260707.2",