From 568fd83c34598d6b47ccc95f79216f80f069601d Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Sat, 2 Aug 2025 23:48:23 -0400 Subject: [PATCH] fix: node 22 wasn't stopped by compat check --- framework/hot.ts | 2 -- run.js | 43 +++++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/framework/hot.ts b/framework/hot.ts index aaf936c..c5560d7 100644 --- a/framework/hot.ts +++ b/framework/hot.ts @@ -19,8 +19,6 @@ export const load = createRequire( }; export const { cache } = load; -load("source-map-support").install({ hookRequire: true }); - // Register extensions by overwriting `require.extensions` const require = load; const exts = require.extensions; diff --git a/run.js b/run.js index a2ac3b0..ea0c1dd 100644 --- a/run.js +++ b/run.js @@ -3,25 +3,9 @@ import * as util from "node:util"; import * as zlib from "node:zlib"; import * as url from "node:url"; +import * as module from "node:module"; import process from "node:process"; -if (!zlib.zstdCompress) { - const brand = process.versions.bun - ? `bun ${process.versions.bun}` - : process.versions.deno - ? `deno ${process.versions.deno}` - : null; - - globalThis.console.error( - `sitegen depends on a node.js v24. your runtime is missing feature\n` + - `this is node.js version ${process.version}${ - brand ? ` (${brand})` : "" - }\n\n` + - `get node.js --> https://nodejs.org/en/download/current`, - ); - process.exit(1); -} - // Disable experimental warnings (Type Stripping, etc) const { emit: originalEmit } = process; const warnings = ["ExperimentalWarning"]; @@ -31,9 +15,32 @@ process.emit = function (event, error) { : originalEmit.apply(process, arguments); }; +try { + // fails in a runtime without ts support + await import("#debug"); + + // required APIs + ASSERT(zlib.zstdCompress); + + // seems to fail in bun + (await import("source-map-support")).install({ hookRequire: true }); +} catch { + const brand = process.versions.bun + ? `bun ${process.versions.bun}` + : process.versions.deno + ? `deno ${process.versions.deno}` + : null; + const brandText = brand ? ` (${brand})` : ""; + globalThis.console.error( + `sitegen depends on a node.js v24. your runtime is missing features.\n` + + `this is node.js version ${process.version}${brandText}\n\n` + + `get node.js --> https://nodejs.org/en/download/current`, + ); + process.exit(1); +} + // Init hooks const hot = await import("./framework/hot.ts"); -await import("#debug"); const console = hot.load("@paperclover/console"); globalThis.console["log"] = console.info;