@riebeckite/honox 0.0.41 → 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
@@ -1819,13 +1819,29 @@ async function runSsg(options) {
1819
1819
  },
1820
1820
  {
1821
1821
  dir: options.outDir,
1822
- plugins: [redirectPlugin(), ...options.plugins ?? []],
1822
+ plugins: [
1823
+ redirectPlugin(),
1824
+ failOnServerError(),
1825
+ ...options.plugins ?? []
1826
+ ],
1823
1827
  extensionMap: options.extensionMap ?? defaultExtensionMap,
1824
1828
  ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
1825
1829
  }
1826
1830
  )
1827
1831
  );
1828
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
+ }
1829
1845
  async function withSsgRenderEnvironment(incremental, operation) {
1830
1846
  const previousFullRegeneration = process.env.RIEBECKITE_SSG_FULL_REGENERATION;
1831
1847
  const previousSkipUnchanged = process.env.RIEBECKITE_SSG_SKIP_UNCHANGED;
@@ -1851,10 +1867,12 @@ function restoreEnvironmentVariable(name, value) {
1851
1867
 
1852
1868
  // src/ssg/standalone.ts
1853
1869
  import { mkdir as mkdir4 } from "node:fs/promises";
1870
+ import { createRequire } from "node:module";
1854
1871
  import { relative as relative3, resolve as resolve3 } from "node:path";
1855
1872
  import { pathToFileURL } from "node:url";
1856
1873
  import { build } from "vite";
1857
1874
  var standaloneSsgMode = "riebeckite-ssr";
1875
+ var frameworkRequire = createRequire(import.meta.url);
1858
1876
  async function loadStandaloneSsgBundle(input) {
1859
1877
  const root = resolve3(input.root);
1860
1878
  const outputDirectory = resolve3(input.outputDirectory);
@@ -1870,6 +1888,7 @@ async function loadStandaloneSsgBundle(input) {
1870
1888
  ...input.config.plugins.filter(
1871
1889
  (plugin) => plugin.name !== "riebeckite-ssg" && plugin.name !== "riebeckite-ssr-externals" && !plugin.name.startsWith("@hono/vite-build/")
1872
1890
  ),
1891
+ createFrameworkResolutionPlugin(),
1873
1892
  createRuntimeExternalPlugin(),
1874
1893
  ...input.clientOutputDirectory ? [createClientManifestPlugin(root, input.clientOutputDirectory)] : []
1875
1894
  ],
@@ -1895,6 +1914,18 @@ async function loadStandaloneSsgBundle(input) {
1895
1914
  }
1896
1915
  return { app: module.default, module };
1897
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
+ }
1898
1929
  var runtimeExternalPackages = /* @__PURE__ */ new Set(["@d2lang/d2", "@marp-team/marp-core"]);
1899
1930
  function createRuntimeExternalPlugin() {
1900
1931
  return {
@@ -1949,11 +1980,15 @@ function riebeckiteSsg(options = {}) {
1949
1980
  }
1950
1981
  };
1951
1982
  },
1952
- configResolved(config) {
1983
+ async configResolved(config) {
1953
1984
  resolvedConfig = config;
1954
1985
  if (config.mode === "client") {
1955
1986
  clientOutputDirectory = resolve4(config.root, config.build.outDir);
1987
+ return;
1956
1988
  }
1989
+ await emptyBuildOutputDirectory(
1990
+ resolve4(config.root, config.build.outDir)
1991
+ );
1957
1992
  },
1958
1993
  async buildStart() {
1959
1994
  const config = resolvedConfig;
@@ -1976,9 +2011,6 @@ function riebeckiteSsg(options = {}) {
1976
2011
  );
1977
2012
  }
1978
2013
  if (!clientBuildArtifacts) {
1979
- if (await isDirectory2(publicationOutputDirectory)) {
1980
- await artifactWriter.copyFrom(publicationOutputDirectory);
1981
- }
1982
2014
  return;
1983
2015
  }
1984
2016
  logSsgDiagnostics(
@@ -2033,6 +2065,10 @@ function riebeckiteSsg(options = {}) {
2033
2065
  "outputDependencyResolution",
2034
2066
  async () => module.content?.getOutputChangeSet()
2035
2067
  );
2068
+ const previousOutputDirectory = publicationOutputDirectory;
2069
+ if (!clientBuildArtifacts && artifactWriter && previousOutputDirectory && await isDirectory2(previousOutputDirectory)) {
2070
+ await artifactWriter.copyFrom(previousOutputDirectory);
2071
+ }
2036
2072
  const appFingerprint = await measure(
2037
2073
  timingsMs,
2038
2074
  "appFingerprint",
@@ -2459,6 +2495,7 @@ function riebeckiteSsg(options = {}) {
2459
2495
  0,
2460
2496
  process.memoryUsage().rss - outputPlanRssBefore
2461
2497
  );
2498
+ assertRequiredOutputsWereGenerated(outputPlanComparison);
2462
2499
  const publicDir = outputCache.publicDir;
2463
2500
  outputCache.state.publicDirectory = publicDir ? resolve4(publicDir) : void 0;
2464
2501
  outputCache.state.publicFingerprint = publicDir ? await measure(
@@ -2520,6 +2557,12 @@ function findBuildOutputSiteCollisions(buildOutputPaths, siteOwnedOutputPaths) {
2520
2557
  }
2521
2558
  return [...collisions].sort();
2522
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
+ }
2523
2566
  async function emitGeneratedOutputs(module, emit, affectedPaths, shadowedPaths, onShadowed) {
2524
2567
  const content = module.content;
2525
2568
  if (!content) return 0;
@@ -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;
@@ -13,3 +13,6 @@ export type RiebeckiteSsgOptions = {
13
13
  export declare function riebeckiteSsg(options?: RiebeckiteSsgOptions): Plugin;
14
14
  export declare function shouldApplyRiebeckiteSsg(_config: unknown, env: ConfigEnv): boolean;
15
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.41",
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.41",
44
- "@riebeckite/dev-inspector": "0.0.41",
45
- "@riebeckite/node": "0.0.41",
46
- "@riebeckite/plugin-color-mode": "0.0.41",
47
- "@riebeckite/spa": "0.0.41",
48
- "@riebeckite/ui": "0.0.41",
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.41",
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"