| ... | @@ -3,37 +3,44 @@ | ... | @@ -3,37 +3,44 @@ |
| 3 | import * as util from "node:util"; | 3 | import * as util from "node:util"; |
| 4 | import * as zlib from "node:zlib"; | 4 | import * as zlib from "node:zlib"; |
| 5 | import * as url from "node:url"; | 5 | import * as url from "node:url"; |
| | 6 | import * as module from "node:module"; |
| 6 | import process from "node:process"; | 7 | import process from "node:process"; |
| 7 | | 8 | |
| 8 | if (!zlib.zstdCompress) { | 9 | // Disable experimental warnings (Type Stripping, etc) |
| | 10 | const { emit: originalEmit } = process; |
| | 11 | const warnings = ["ExperimentalWarning"]; |
| | 12 | process.emit = function (event, error) { |
| | 13 | return event === "warning" && warnings.includes(error.name) |
| | 14 | ? false |
| | 15 | : originalEmit.apply(process, arguments); |
| | 16 | }; |
| | 17 | |
| | 18 | try { |
| | 19 | // fails in a runtime without ts support |
| | 20 | await import("#debug"); |
| | 21 | |
| | 22 | // required APIs |
| | 23 | ASSERT(zlib.zstdCompress); |
| | 24 | |
| | 25 | // seems to fail in bun |
| | 26 | (await import("source-map-support")).install({ hookRequire: true }); |
| | 27 | } catch { |
| 9 | const brand = process.versions.bun | 28 | const brand = process.versions.bun |
| 10 | ? `bun ${process.versions.bun}` | 29 | ? `bun ${process.versions.bun}` |
| 11 | : process.versions.deno | 30 | : process.versions.deno |
| 12 | ? `deno ${process.versions.deno}` | 31 | ? `deno ${process.versions.deno}` |
| 13 | : null; | 32 | : null; |
| 14 | | 33 | const brandText = brand ? ` (${brand})` : ""; |
| 15 | globalThis.console.error( | 34 | globalThis.console.error( |
| 16 | `sitegen depends on a node.js v24. your runtime is missing feature\n` + | 35 | `sitegen depends on a node.js v24. your runtime is missing features.\n` + |
| 17 | `this is node.js version ${process.version}${ | 36 | `this is node.js version ${process.version}${brandText}\n\n` + |
| 18 | brand ? ` (${brand})` : "" | | |
| 19 | }\n\n` + | | |
| 20 | `get node.js --> https://nodejs.org/en/download/current`, | 37 | `get node.js --> https://nodejs.org/en/download/current`, |
| 21 | ); | 38 | ); |
| 22 | process.exit(1); | 39 | process.exit(1); |
| 23 | } | 40 | } |
| 24 | | 41 | |
| 25 | // Disable experimental warnings (Type Stripping, etc) | | |
| 26 | const { emit: originalEmit } = process; | | |
| 27 | const warnings = ["ExperimentalWarning"]; | | |
| 28 | process.emit = function (event, error) { | | |
| 29 | return event === "warning" && warnings.includes(error.name) | | |
| 30 | ? false | | |
| 31 | : originalEmit.apply(process, arguments); | | |
| 32 | }; | | |
| 33 | | | |
| 34 | // Init hooks | 42 | // Init hooks |
| 35 | const hot = await import("./framework/hot.ts"); | 43 | const hot = await import("./framework/hot.ts"); |
| 36 | await import("#debug"); | | |
| 37 | | 44 | |
| 38 | const console = hot.load("@paperclover/console"); | 45 | const console = hot.load("@paperclover/console"); |
| 39 | globalThis.console["log"] = console.info; | 46 | globalThis.console["log"] = console.info; |