diff --git a/framework/hot.ts b/framework/hot.ts index aaf936c1d35c4337f173bccd70b6f02edbdd5e5d..c5560d757bb19ba6e4dc9b90967afadb5254ee25 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 a2ac3b0364fb296a90786dda0291530e9bd9ccfb..ea0c1ddd54dc96ac852f85ae276f85c73f5d1e58 100644 --- a/run.js +++ b/run.js @@ -3,37 +3,44 @@ 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) { +// Disable experimental warnings (Type Stripping, etc) +const { emit: originalEmit } = process; +const warnings = ["ExperimentalWarning"]; +process.emit = function (event, error) { + return event === "warning" && warnings.includes(error.name) + ? false + : 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 feature\n` + - `this is node.js version ${process.version}${ - brand ? ` (${brand})` : "" - }\n\n` + + `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); } -// Disable experimental warnings (Type Stripping, etc) -const { emit: originalEmit } = process; -const warnings = ["ExperimentalWarning"]; -process.emit = function (event, error) { - return event === "warning" && warnings.includes(error.name) - ? false - : originalEmit.apply(process, arguments); -}; - // Init hooks const hot = await import("./framework/hot.ts"); -await import("#debug"); const console = hot.load("@paperclover/console"); globalThis.console["log"] = console.info;