fix: node 22 wasn't stopped by compat check

This commit is contained in:
clover caruso 2025-08-02 23:48:23 -04:00
parent 11ce8149f9
commit 568fd83c34
2 changed files with 25 additions and 20 deletions

View file

@ -19,8 +19,6 @@ export const load = createRequire(
};
export const { cache } = load;
load<any>("source-map-support").install({ hookRequire: true });
// Register extensions by overwriting `require.extensions`
const require = load;
const exts = require.extensions;

43
run.js
View file

@ -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;