@riebeckite/honox 0.0.40 → 0.0.42

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/index.js CHANGED
@@ -368,7 +368,11 @@ async function computeBundleFingerprint(root, configFile) {
368
368
  return hash.digest("hex");
369
369
  }
370
370
  async function fingerprintDirectory(directory) {
371
- const inventory = await fingerprintOutputDirectory(directory);
371
+ return fingerprintOutputInventory(
372
+ await fingerprintOutputDirectory(directory)
373
+ );
374
+ }
375
+ function fingerprintOutputInventory(inventory) {
372
376
  const hash = createHash("sha256");
373
377
  for (const [path12, checksum] of Object.entries(inventory).sort(
374
378
  ([left], [right]) => left.localeCompare(right)
@@ -377,7 +381,10 @@ async function fingerprintDirectory(directory) {
377
381
  }
378
382
  return hash.digest("hex");
379
383
  }
380
- async function fingerprintOutputDirectory(directory, relativeDirectory = "", metrics) {
384
+ function fingerprintOutputContent(content) {
385
+ return createHash("sha256").update(content).digest("hex");
386
+ }
387
+ async function fingerprintOutputDirectory(directory, relativeDirectory = "", metrics, knownChecksums) {
381
388
  const entries = await readdir(directory, { withFileTypes: true }).catch(
382
389
  (error) => {
383
390
  if (isMissingDirectoryError(error)) return void 0;
@@ -395,14 +402,24 @@ async function fingerprintOutputDirectory(directory, relativeDirectory = "", met
395
402
  if (entry.isDirectory()) {
396
403
  Object.assign(
397
404
  inventory,
398
- await fingerprintOutputDirectory(file, relativePath, metrics)
405
+ await fingerprintOutputDirectory(
406
+ file,
407
+ relativePath,
408
+ metrics,
409
+ knownChecksums
410
+ )
399
411
  );
400
412
  continue;
401
413
  }
402
414
  if (entry.isFile()) {
415
+ const knownChecksum = knownChecksums?.get(relativePath);
416
+ if (knownChecksum !== void 0) {
417
+ inventory[relativePath] = knownChecksum;
418
+ continue;
419
+ }
403
420
  const hashedAt = performance.now();
404
421
  const content = await readFile(file);
405
- inventory[relativePath] = createHash("sha256").update(content).digest("hex");
422
+ inventory[relativePath] = fingerprintOutputContent(content);
406
423
  if (metrics) {
407
424
  metrics.outputHashValidationDurationMs += performance.now() - hashedAt;
408
425
  metrics.outputFilesHashed += 1;
@@ -740,6 +757,7 @@ import { constants } from "node:fs";
740
757
  import {
741
758
  copyFile,
742
759
  cp,
760
+ link,
743
761
  lstat,
744
762
  mkdir,
745
763
  readFile as readFile2,
@@ -783,14 +801,18 @@ async function createBuildArtifactWriter(input) {
783
801
  ensureOpen(completed);
784
802
  const target = resolveArtifactPath(stagingDirectory, path12);
785
803
  await mkdir(dirname2(target), { recursive: true });
786
- await writeFile(target, data);
804
+ await replaceArtifactFile(target, data);
787
805
  },
788
806
  async copyFileFrom(source, path12) {
789
807
  ensureOpen(completed);
790
808
  const target = resolveArtifactPath(stagingDirectory, path12);
791
809
  await mkdir(dirname2(target), { recursive: true });
792
810
  await rm(target, { force: true });
793
- await copyFile(source, target, constants.COPYFILE_FICLONE);
811
+ try {
812
+ await link(source, target);
813
+ } catch {
814
+ await copyFile(source, target, constants.COPYFILE_FICLONE);
815
+ }
794
816
  },
795
817
  async publish() {
796
818
  ensureOpen(completed);
@@ -807,6 +829,21 @@ async function createBuildArtifactWriter(input) {
807
829
  function ensureOpen(completed) {
808
830
  if (completed) throw new Error("Build artifact writer is already closed.");
809
831
  }
832
+ async function replaceArtifactFile(target, data) {
833
+ const temporaryPath = `${target}.${randomUUID()}.tmp`;
834
+ try {
835
+ await writeFile(temporaryPath, data);
836
+ try {
837
+ await rename(temporaryPath, target);
838
+ } catch {
839
+ await rm(target, { force: true });
840
+ await rename(temporaryPath, target);
841
+ }
842
+ } catch (error) {
843
+ await rm(temporaryPath, { force: true }).catch(() => void 0);
844
+ throw error;
845
+ }
846
+ }
810
847
  function resolveArtifactPath(directory, path12) {
811
848
  return resolveWithinDirectory(directory, path12, "Build artifact path");
812
849
  }
@@ -1244,17 +1281,33 @@ async function verifyNoChangeFastPath(input) {
1244
1281
  )) {
1245
1282
  return { used: false, blockReason: "output-cache-incomplete" };
1246
1283
  }
1284
+ const knownChecksums = await matchingOutputChecksums(
1285
+ input.outputDirectory,
1286
+ cache.finalOutputInventory,
1287
+ cache.finalOutputStats
1288
+ );
1247
1289
  const inventoryStartedAt = performance3.now();
1248
1290
  const currentInventory = await fingerprintOutputDirectory(
1249
1291
  input.outputDirectory,
1250
1292
  "",
1251
- input.metrics
1293
+ input.metrics,
1294
+ knownChecksums
1252
1295
  );
1253
1296
  if (input.metrics)
1254
1297
  input.metrics.outputInventoryValidationDurationMs += performance3.now() - inventoryStartedAt;
1255
1298
  if (!inventoriesEqual(cache.finalOutputInventory, currentInventory)) {
1256
1299
  return { used: false, blockReason: "output-inventory-mismatch" };
1257
1300
  }
1301
+ const currentStats = await collectOutputFileStats(
1302
+ input.outputDirectory,
1303
+ cache.finalOutputInventory
1304
+ );
1305
+ if (!outputStatsEqual(cache.finalOutputStats, currentStats)) {
1306
+ await saveFastPathCache(fastPathCachePath(outputCachePath), {
1307
+ ...cache,
1308
+ finalOutputStats: currentStats
1309
+ }).catch(() => void 0);
1310
+ }
1258
1311
  return { used: true };
1259
1312
  }
1260
1313
  async function loadOutputCacheMetadata(path12, timingsMs, log = () => {
@@ -1349,7 +1402,7 @@ async function saveOutputCache(path12, state, outputDirectory, timingsMs) {
1349
1402
  if (state.finalOutputInventory && state.configFile) {
1350
1403
  await saveFastPathCache(
1351
1404
  fastPathCachePath(path12),
1352
- createFastPathCacheState(state, checksum),
1405
+ await createFastPathCacheState(state, checksum, outputDirectory),
1353
1406
  timingsMs
1354
1407
  );
1355
1408
  }
@@ -1374,14 +1427,22 @@ function isOutputInventory(value) {
1374
1427
  ([outputPath, checksum]) => isSafeLogicalOutputPath(outputPath) && isChecksum(checksum)
1375
1428
  );
1376
1429
  }
1430
+ function isOutputFileStats(value) {
1431
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.entries(value).every(
1432
+ ([outputPath, stats]) => isSafeLogicalOutputPath(outputPath) && typeof stats === "object" && stats !== null && isOptionalNonNegativeNumber(stats.size) && stats.size !== void 0 && isOptionalNonNegativeNumber(stats.modifiedAtMs) && stats.modifiedAtMs !== void 0
1433
+ );
1434
+ }
1377
1435
  function isOutputCacheEntries(value) {
1378
1436
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
1379
1437
  return false;
1380
1438
  }
1381
1439
  return Object.entries(value).every(
1382
- ([outputPath, entry]) => isSafeLogicalOutputPath(outputPath) && typeof entry === "object" && entry !== null && typeof entry.cachePath === "string" && entry.cachePath === outputCacheEntryName(outputPath) && isChecksum(entry.checksum)
1440
+ ([outputPath, entry]) => isSafeLogicalOutputPath(outputPath) && typeof entry === "object" && entry !== null && typeof entry.cachePath === "string" && entry.cachePath === outputCacheEntryName(outputPath) && isChecksum(entry.checksum) && isOptionalNonNegativeNumber(entry.size) && isOptionalNonNegativeNumber(entry.modifiedAtMs)
1383
1441
  );
1384
1442
  }
1443
+ function isOptionalNonNegativeNumber(value) {
1444
+ return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
1445
+ }
1385
1446
  function outputCacheEntriesPath(outputCachePath) {
1386
1447
  return outputCachePath.replace(/\.json$/, ".entries");
1387
1448
  }
@@ -1395,7 +1456,10 @@ async function saveOutputCacheEntries(directory, outputDirectory, outputs, final
1395
1456
  if (existing.cachePath !== outputCacheEntryName(outputPath) || !isChecksum(existing.checksum)) {
1396
1457
  throw new Error(`Invalid SSG output cache entry: ${outputPath}`);
1397
1458
  }
1398
- entries[outputPath] = existing;
1459
+ entries[outputPath] = await withOutputCacheEntryStat(
1460
+ existing,
1461
+ join4(directory, existing.cachePath)
1462
+ );
1399
1463
  continue;
1400
1464
  }
1401
1465
  const source = resolveOutputCacheFile(outputDirectory, outputPath);
@@ -1408,13 +1472,24 @@ async function saveOutputCacheEntries(directory, outputDirectory, outputs, final
1408
1472
  if (!cachedChecksum) {
1409
1473
  throw new Error(`Could not checksum cached output: ${outputPath}`);
1410
1474
  }
1411
- entries[outputPath] = { cachePath, checksum: cachedChecksum };
1475
+ entries[outputPath] = await withOutputCacheEntryStat(
1476
+ { cachePath, checksum: cachedChecksum },
1477
+ destination
1478
+ );
1412
1479
  continue;
1413
1480
  }
1414
- entries[outputPath] = { cachePath, checksum };
1481
+ entries[outputPath] = await withOutputCacheEntryStat(
1482
+ { cachePath, checksum },
1483
+ destination
1484
+ );
1415
1485
  }
1416
1486
  return entries;
1417
1487
  }
1488
+ async function withOutputCacheEntryStat(entry, path12) {
1489
+ const info = await lstat2(path12).catch(() => void 0);
1490
+ if (!info?.isFile() || info.isSymbolicLink()) return entry;
1491
+ return { ...entry, size: info.size, modifiedAtMs: info.mtimeMs };
1492
+ }
1418
1493
  async function validateOutputCacheEntries(outputCachePath, entries, timingsMs) {
1419
1494
  try {
1420
1495
  const directory = outputCacheEntriesPath(outputCachePath);
@@ -1432,16 +1507,24 @@ async function validateOutputCacheEntries(outputCachePath, entries, timingsMs) {
1432
1507
  return;
1433
1508
  }
1434
1509
  const path12 = resolveOutputCacheFile(directory, entry.cachePath);
1435
- if (!await isRegularFile(path12)) {
1510
+ const info = await lstat2(path12).catch(() => void 0);
1511
+ if (!info?.isFile() || info.isSymbolicLink()) {
1436
1512
  valid = false;
1437
1513
  return;
1438
1514
  }
1515
+ if (entry.size === info.size && entry.modifiedAtMs === info.mtimeMs) {
1516
+ continue;
1517
+ }
1439
1518
  if (await measure(
1440
1519
  timingsMs,
1441
1520
  "outputCacheEntryChecksum",
1442
1521
  () => checksumFile(path12)
1443
- ) !== entry.checksum)
1522
+ ) !== entry.checksum) {
1444
1523
  valid = false;
1524
+ return;
1525
+ }
1526
+ entry.size = info.size;
1527
+ entry.modifiedAtMs = info.mtimeMs;
1445
1528
  }
1446
1529
  };
1447
1530
  await Promise.all(
@@ -1463,7 +1546,7 @@ async function validateOutputCacheEntries(outputCachePath, entries, timingsMs) {
1463
1546
  function fastPathCachePath(outputCachePath) {
1464
1547
  return outputCachePath.replace(/\.json$/, ".fast-path.json");
1465
1548
  }
1466
- function createFastPathCacheState(state, outputCacheChecksum) {
1549
+ async function createFastPathCacheState(state, outputCacheChecksum, outputDirectory) {
1467
1550
  if (!state.finalOutputInventory || !state.configFile) {
1468
1551
  throw new Error("SSG output cache is missing fast-path validation data.");
1469
1552
  }
@@ -1472,12 +1555,65 @@ function createFastPathCacheState(state, outputCacheChecksum) {
1472
1555
  outputCacheChecksum,
1473
1556
  appFingerprint: state.appFingerprint,
1474
1557
  finalOutputInventory: state.finalOutputInventory,
1558
+ finalOutputStats: await collectOutputFileStats(
1559
+ outputDirectory,
1560
+ state.finalOutputInventory
1561
+ ),
1475
1562
  publicDirectory: state.publicDirectory,
1476
1563
  publicFingerprint: state.publicFingerprint,
1477
1564
  configFile: state.configFile,
1478
1565
  outputPaths: Object.keys(state.outputs).sort()
1479
1566
  };
1480
1567
  }
1568
+ async function matchingOutputChecksums(outputDirectory, inventory, stats) {
1569
+ const checksums = /* @__PURE__ */ new Map();
1570
+ if (!stats) return checksums;
1571
+ for (const [outputPath, checksum] of Object.entries(inventory)) {
1572
+ const expected = stats[outputPath];
1573
+ if (!expected) continue;
1574
+ const info = await lstat2(
1575
+ resolveWithinDirectory(
1576
+ outputDirectory,
1577
+ outputPath,
1578
+ "SSG fast-path output path"
1579
+ )
1580
+ ).catch(() => void 0);
1581
+ if (info?.isFile() && !info.isSymbolicLink() && outputFileStatMatches(info, expected)) {
1582
+ checksums.set(outputPath, checksum);
1583
+ }
1584
+ }
1585
+ return checksums;
1586
+ }
1587
+ async function collectOutputFileStats(outputDirectory, inventory) {
1588
+ const stats = {};
1589
+ for (const outputPath of Object.keys(inventory)) {
1590
+ const info = await lstat2(
1591
+ resolveWithinDirectory(
1592
+ outputDirectory,
1593
+ outputPath,
1594
+ "SSG fast-path output path"
1595
+ )
1596
+ ).catch(() => void 0);
1597
+ if (info?.isFile() && !info.isSymbolicLink()) {
1598
+ stats[outputPath] = {
1599
+ size: info.size,
1600
+ modifiedAtMs: info.mtimeMs
1601
+ };
1602
+ }
1603
+ }
1604
+ return stats;
1605
+ }
1606
+ function outputFileStatMatches(info, expected) {
1607
+ return info.size === expected.size && info.mtimeMs === expected.modifiedAtMs;
1608
+ }
1609
+ function outputStatsEqual(left, right) {
1610
+ if (!left) return false;
1611
+ const paths = Object.keys(left);
1612
+ if (paths.length !== Object.keys(right).length) return false;
1613
+ return paths.every(
1614
+ (path12) => right[path12] !== void 0 && left[path12]?.size === right[path12].size && left[path12]?.modifiedAtMs === right[path12].modifiedAtMs
1615
+ );
1616
+ }
1481
1617
  async function saveFastPathCache(path12, state, timingsMs) {
1482
1618
  const directory = dirname4(path12);
1483
1619
  await mkdir3(directory, { recursive: true });
@@ -1518,7 +1654,7 @@ async function loadFastPathCache(path12) {
1518
1654
  function isFastPathCacheState(value) {
1519
1655
  if (typeof value !== "object" || value === null) return false;
1520
1656
  const candidate = value;
1521
- return candidate.version === 1 && typeof candidate.outputCacheChecksum === "string" && (candidate.appFingerprint === void 0 || typeof candidate.appFingerprint === "string") && isOutputInventory(candidate.finalOutputInventory) && (candidate.publicDirectory === void 0 || typeof candidate.publicDirectory === "string") && (candidate.publicFingerprint === void 0 || typeof candidate.publicFingerprint === "string") && typeof candidate.configFile === "string" && Array.isArray(candidate.outputPaths) && candidate.outputPaths.every(isSafeLogicalOutputPath) && candidate.outputPaths.every(
1657
+ return candidate.version === 1 && typeof candidate.outputCacheChecksum === "string" && (candidate.appFingerprint === void 0 || typeof candidate.appFingerprint === "string") && isOutputInventory(candidate.finalOutputInventory) && (candidate.finalOutputStats === void 0 || isOutputFileStats(candidate.finalOutputStats)) && (candidate.publicDirectory === void 0 || typeof candidate.publicDirectory === "string") && (candidate.publicFingerprint === void 0 || typeof candidate.publicFingerprint === "string") && typeof candidate.configFile === "string" && Array.isArray(candidate.outputPaths) && candidate.outputPaths.every(isSafeLogicalOutputPath) && candidate.outputPaths.every(
1522
1658
  (path12, index, paths) => index === 0 || paths[index - 1] < path12
1523
1659
  );
1524
1660
  }
@@ -1683,12 +1819,29 @@ async function runSsg(options) {
1683
1819
  },
1684
1820
  {
1685
1821
  dir: options.outDir,
1686
- plugins: [redirectPlugin(), ...options.plugins ?? []],
1687
- extensionMap: options.extensionMap ?? defaultExtensionMap
1822
+ plugins: [
1823
+ redirectPlugin(),
1824
+ failOnServerError(),
1825
+ ...options.plugins ?? []
1826
+ ],
1827
+ extensionMap: options.extensionMap ?? defaultExtensionMap,
1828
+ ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
1688
1829
  }
1689
1830
  )
1690
1831
  );
1691
1832
  }
1833
+ function failOnServerError() {
1834
+ return {
1835
+ afterResponseHook(response) {
1836
+ if (response.status >= 500) {
1837
+ throw new Error(
1838
+ `SSG route responded with status ${response.status}: ${response.statusText}`
1839
+ );
1840
+ }
1841
+ return response;
1842
+ }
1843
+ };
1844
+ }
1692
1845
  async function withSsgRenderEnvironment(incremental, operation) {
1693
1846
  const previousFullRegeneration = process.env.RIEBECKITE_SSG_FULL_REGENERATION;
1694
1847
  const previousSkipUnchanged = process.env.RIEBECKITE_SSG_SKIP_UNCHANGED;
@@ -1714,10 +1867,12 @@ function restoreEnvironmentVariable(name, value) {
1714
1867
 
1715
1868
  // src/ssg/standalone.ts
1716
1869
  import { mkdir as mkdir4 } from "node:fs/promises";
1870
+ import { createRequire } from "node:module";
1717
1871
  import { relative as relative3, resolve as resolve3 } from "node:path";
1718
1872
  import { pathToFileURL } from "node:url";
1719
1873
  import { build } from "vite";
1720
1874
  var standaloneSsgMode = "riebeckite-ssr";
1875
+ var frameworkRequire = createRequire(import.meta.url);
1721
1876
  async function loadStandaloneSsgBundle(input) {
1722
1877
  const root = resolve3(input.root);
1723
1878
  const outputDirectory = resolve3(input.outputDirectory);
@@ -1733,6 +1888,7 @@ async function loadStandaloneSsgBundle(input) {
1733
1888
  ...input.config.plugins.filter(
1734
1889
  (plugin) => plugin.name !== "riebeckite-ssg" && plugin.name !== "riebeckite-ssr-externals" && !plugin.name.startsWith("@hono/vite-build/")
1735
1890
  ),
1891
+ createFrameworkResolutionPlugin(),
1736
1892
  createRuntimeExternalPlugin(),
1737
1893
  ...input.clientOutputDirectory ? [createClientManifestPlugin(root, input.clientOutputDirectory)] : []
1738
1894
  ],
@@ -1758,6 +1914,18 @@ async function loadStandaloneSsgBundle(input) {
1758
1914
  }
1759
1915
  return { app: module.default, module };
1760
1916
  }
1917
+ function createFrameworkResolutionPlugin() {
1918
+ return {
1919
+ name: "riebeckite-ssg-framework-resolution",
1920
+ enforce: "pre",
1921
+ resolveId(source) {
1922
+ if (!(source === "hono" || source.startsWith("hono/") || source === "honox" || source.startsWith("honox/"))) {
1923
+ return void 0;
1924
+ }
1925
+ return frameworkRequire.resolve(source);
1926
+ }
1927
+ };
1928
+ }
1761
1929
  var runtimeExternalPackages = /* @__PURE__ */ new Set(["@d2lang/d2", "@marp-team/marp-core"]);
1762
1930
  function createRuntimeExternalPlugin() {
1763
1931
  return {
@@ -1793,6 +1961,7 @@ function riebeckiteSsg(options = {}) {
1793
1961
  let artifactWriter;
1794
1962
  let pendingOutputCache;
1795
1963
  let clientBuildArtifacts;
1964
+ const outputChecksums = /* @__PURE__ */ new Map();
1796
1965
  return {
1797
1966
  name: "riebeckite-ssg",
1798
1967
  apply: (_config, env) => env.command === "build",
@@ -1811,15 +1980,20 @@ function riebeckiteSsg(options = {}) {
1811
1980
  }
1812
1981
  };
1813
1982
  },
1814
- configResolved(config) {
1983
+ async configResolved(config) {
1815
1984
  resolvedConfig = config;
1816
1985
  if (config.mode === "client") {
1817
1986
  clientOutputDirectory = resolve4(config.root, config.build.outDir);
1987
+ return;
1818
1988
  }
1989
+ await emptyBuildOutputDirectory(
1990
+ resolve4(config.root, config.build.outDir)
1991
+ );
1819
1992
  },
1820
1993
  async buildStart() {
1821
1994
  const config = resolvedConfig;
1822
1995
  if (!config || config.mode === "client") return;
1996
+ outputChecksums.clear();
1823
1997
  if (!publicationOutputDirectory) {
1824
1998
  throw new Error(
1825
1999
  "Riebeckite SSG could not resolve the publication output directory."
@@ -1837,9 +2011,6 @@ function riebeckiteSsg(options = {}) {
1837
2011
  );
1838
2012
  }
1839
2013
  if (!clientBuildArtifacts) {
1840
- if (await isDirectory2(publicationOutputDirectory)) {
1841
- await artifactWriter.copyFrom(publicationOutputDirectory);
1842
- }
1843
2014
  return;
1844
2015
  }
1845
2016
  logSsgDiagnostics(
@@ -1894,6 +2065,10 @@ function riebeckiteSsg(options = {}) {
1894
2065
  "outputDependencyResolution",
1895
2066
  async () => module.content?.getOutputChangeSet()
1896
2067
  );
2068
+ const previousOutputDirectory = publicationOutputDirectory;
2069
+ if (!clientBuildArtifacts && artifactWriter && previousOutputDirectory && await isDirectory2(previousOutputDirectory)) {
2070
+ await artifactWriter.copyFrom(previousOutputDirectory);
2071
+ }
1897
2072
  const appFingerprint = await measure(
1898
2073
  timingsMs,
1899
2074
  "appFingerprint",
@@ -2036,6 +2211,7 @@ function riebeckiteSsg(options = {}) {
2036
2211
  incremental: canUseIncremental,
2037
2212
  plugins: options.plugins,
2038
2213
  extensionMap: options.extensionMap,
2214
+ ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency },
2039
2215
  write: async (filePath, data) => {
2040
2216
  const fileName = relative4(outDir, filePath).replaceAll("\\", "/");
2041
2217
  if (!inventoryPaths.has(fileName)) {
@@ -2067,6 +2243,7 @@ function riebeckiteSsg(options = {}) {
2067
2243
  "outputWrite",
2068
2244
  () => writer.write(fileName, data)
2069
2245
  );
2246
+ outputChecksums.set(fileName, fingerprintOutputContent(data));
2070
2247
  metrics.emittedOutputCount += 1;
2071
2248
  nextOutputCache.outputs[fileName] = {
2072
2249
  cachePath: "",
@@ -2103,6 +2280,10 @@ function riebeckiteSsg(options = {}) {
2103
2280
  "outputWrite",
2104
2281
  () => writer.write(asset.fileName, asset.source)
2105
2282
  );
2283
+ outputChecksums.set(
2284
+ asset.fileName,
2285
+ fingerprintOutputContent(asset.source)
2286
+ );
2106
2287
  metrics.emittedOutputCount += 1;
2107
2288
  nextOutputCache.outputs[asset.fileName] = {
2108
2289
  cachePath: "",
@@ -2142,6 +2323,7 @@ function riebeckiteSsg(options = {}) {
2142
2323
  path12
2143
2324
  )
2144
2325
  );
2326
+ outputChecksums.set(path12, cached.checksum);
2145
2327
  metrics.emittedOutputCount += 1;
2146
2328
  metrics.reusedOutputCount += 1;
2147
2329
  nextOutputCache.outputs[path12] = cached;
@@ -2260,9 +2442,15 @@ function riebeckiteSsg(options = {}) {
2260
2442
  outputCache.state.finalOutputInventory = await measure(
2261
2443
  outputCache.timingsMs,
2262
2444
  "outputInventory",
2263
- () => fingerprintOutputDirectory(outputCache.outDir)
2445
+ () => fingerprintOutputDirectory(
2446
+ outputCache.outDir,
2447
+ "",
2448
+ void 0,
2449
+ outputChecksums
2450
+ )
2264
2451
  );
2265
2452
  const finalOutputInventory = outputCache.state.finalOutputInventory;
2453
+ const artifactFingerprint = fingerprintOutputInventory(finalOutputInventory);
2266
2454
  if (outputCache.provenance && outputCache.content) {
2267
2455
  await outputCache.content.attachFinalOutputArtifacts(
2268
2456
  outputCache.provenance.buildId,
@@ -2307,6 +2495,7 @@ function riebeckiteSsg(options = {}) {
2307
2495
  0,
2308
2496
  process.memoryUsage().rss - outputPlanRssBefore
2309
2497
  );
2498
+ assertRequiredOutputsWereGenerated(outputPlanComparison);
2310
2499
  const publicDir = outputCache.publicDir;
2311
2500
  outputCache.state.publicDirectory = publicDir ? resolve4(publicDir) : void 0;
2312
2501
  outputCache.state.publicFingerprint = publicDir ? await measure(
@@ -2332,6 +2521,7 @@ function riebeckiteSsg(options = {}) {
2332
2521
  root: resolvedConfig.root,
2333
2522
  outputDirectory,
2334
2523
  publicationFingerprint: outputCache.publicationFingerprint,
2524
+ artifactFingerprint,
2335
2525
  warn: (message) => this.warn(message)
2336
2526
  });
2337
2527
  } finally {
@@ -2367,6 +2557,12 @@ function findBuildOutputSiteCollisions(buildOutputPaths, siteOwnedOutputPaths) {
2367
2557
  }
2368
2558
  return [...collisions].sort();
2369
2559
  }
2560
+ function assertRequiredOutputsWereGenerated(comparison) {
2561
+ if (comparison.missingInDist.length === 0) return;
2562
+ throw new Error(
2563
+ `SSG did not generate required output: ${comparison.missingInDist.join(", ")}`
2564
+ );
2565
+ }
2370
2566
  async function emitGeneratedOutputs(module, emit, affectedPaths, shadowedPaths, onShadowed) {
2371
2567
  const content = module.content;
2372
2568
  if (!content) return 0;
@@ -2406,6 +2602,7 @@ async function writePublicationMarker(input) {
2406
2602
  createBuildOutputMarker({
2407
2603
  outputDirectory: input.outputDirectory,
2408
2604
  ...input.publicationFingerprint === void 0 ? {} : { publicationFingerprint: input.publicationFingerprint },
2605
+ ...input.artifactFingerprint === void 0 ? {} : { artifactFingerprint: input.artifactFingerprint },
2409
2606
  completedAt: /* @__PURE__ */ new Date()
2410
2607
  })
2411
2608
  ),
@@ -2,5 +2,7 @@ import type { NoChangeFastPathOutputMetrics } from "./types.js";
2
2
  export declare function computeAppFingerprint(root: string, configFile: string | undefined): Promise<string>;
3
3
  export declare function computeBundleFingerprint(root: string, configFile: string | undefined): Promise<string>;
4
4
  export declare function fingerprintDirectory(directory: string): Promise<string>;
5
- export declare function fingerprintOutputDirectory(directory: string, relativeDirectory?: string, metrics?: NoChangeFastPathOutputMetrics): Promise<Record<string, string>>;
5
+ export declare function fingerprintOutputInventory(inventory: Readonly<Record<string, string>>): string;
6
+ export declare function fingerprintOutputContent(content: string | Uint8Array): string;
7
+ export declare function fingerprintOutputDirectory(directory: string, relativeDirectory?: string, metrics?: NoChangeFastPathOutputMetrics, knownChecksums?: ReadonlyMap<string, string>): Promise<Record<string, string>>;
6
8
  export declare function inventoriesEqual(left: Record<string, string>, right: Record<string, string>): boolean;
@@ -2,6 +2,8 @@ import type { NoChangeFastPathOutputMetrics, NoChangeFastPathResult, OutputCache
2
2
  type OutputCacheEntry = {
3
3
  cachePath: string;
4
4
  checksum: string;
5
+ size?: number;
6
+ modifiedAtMs?: number;
5
7
  };
6
8
  export type OutputCacheState = {
7
9
  version: 4;
@@ -6,6 +6,7 @@ export type SsgRunnerOptions = {
6
6
  readonly write: (path: string, data: string | Uint8Array) => Promise<void>;
7
7
  readonly plugins?: ToSsgOptions["plugins"];
8
8
  readonly extensionMap?: Record<string, string>;
9
+ readonly concurrency?: number;
9
10
  readonly incremental: boolean;
10
11
  };
11
12
  export declare function runSsg(options: SsgRunnerOptions): Promise<import("hono/ssg").ToSSGResult>;
@@ -11,5 +11,6 @@ export declare function loadStandaloneSsgBundle(input: {
11
11
  readonly clientOutputDirectory?: string;
12
12
  readonly config?: Pick<ResolvedConfig, "define" | "oxc" | "plugins" | "resolve">;
13
13
  }): Promise<StandaloneSsgBundle>;
14
+ export declare function createFrameworkResolutionPlugin(): Plugin;
14
15
  export declare function createClientManifestPlugin(root: string, clientOutputDirectory: string): Plugin;
15
16
  export declare function isStandaloneSsgMode(mode: string): boolean;
@@ -8,7 +8,11 @@ export type RiebeckiteSsgOptions = {
8
8
  entry?: string;
9
9
  plugins?: ToSsgOptions["plugins"];
10
10
  extensionMap?: Record<string, string>;
11
+ concurrency?: number;
11
12
  };
12
13
  export declare function riebeckiteSsg(options?: RiebeckiteSsgOptions): Plugin;
13
14
  export declare function shouldApplyRiebeckiteSsg(_config: unknown, env: ConfigEnv): boolean;
14
15
  export declare function findBuildOutputSiteCollisions(buildOutputPaths: Iterable<string>, siteOwnedOutputPaths: ReadonlySet<string>): readonly string[];
16
+ export declare function assertRequiredOutputsWereGenerated(comparison: {
17
+ readonly missingInDist: readonly string[];
18
+ }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/honox",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,22 +40,25 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@babel/parser": "^7.29.3",
43
- "@riebeckite/core": "0.0.40",
44
- "@riebeckite/dev-inspector": "0.0.40",
45
- "@riebeckite/node": "0.0.40",
46
- "@riebeckite/plugin-color-mode": "0.0.40",
47
- "@riebeckite/spa": "0.0.40",
48
- "@riebeckite/ui": "0.0.40",
49
43
  "esbuild": "^0.28.2",
50
44
  "hono": "^4.12.25",
51
45
  "honox": "0.1.62",
52
- "vite": "^8.3.5"
46
+ "vite": "^8.3.5",
47
+ "@riebeckite/plugin-color-mode": "0.0.42",
48
+ "@riebeckite/core": "0.0.42",
49
+ "@riebeckite/dev-inspector": "0.0.42",
50
+ "@riebeckite/node": "0.0.42",
51
+ "@riebeckite/spa": "0.0.42",
52
+ "@riebeckite/ui": "0.0.42"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@d2lang/d2": "^0.1.34",
56
+ "@hono/node-server": "2.1.3",
57
+ "@hono/vite-build": "^1.11.1",
56
58
  "@marp-team/marp-core": "^4.4.0",
57
- "@riebeckite/test": "0.0.40",
58
- "tsx": "^4.22.4"
59
+ "tsx": "^4.22.4",
60
+ "@riebeckite/plugin-bases": "0.0.42",
61
+ "@riebeckite/test": "0.0.42"
59
62
  },
60
63
  "publishConfig": {
61
64
  "access": "public"