fix: suppress ExperimentalWarning for node:sqlite (#179) #180
@@ -1,3 +1,5 @@
|
||||
import "@uncaged/nerve-core/experimental-warning-suppression.js";
|
||||
|
||||
import { defineCommand, runMain } from "citty";
|
||||
|
||||
import { consumeGlobalDaemonCliFlags } from "./cli-global.js";
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import "@uncaged/nerve-core/experimental-warning-suppression.js";
|
||||
|
||||
import { runForegroundKernelSession } from "./run-foreground-kernel.js";
|
||||
import { loadDaemonModule } from "./workspace-daemon.js";
|
||||
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
"version": "0.4.0",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./experimental-warning-suppression.js": {
|
||||
"types": "./dist/experimental-warning-suppression.d.ts",
|
||||
"default": "./dist/experimental-warning-suppression.js"
|
||||
}
|
||||
},
|
||||
"files": ["dist"],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -18,6 +28,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rslib/core": "^0.21.3",
|
||||
"@types/node": "^22.0.0",
|
||||
"vitest": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export default defineConfig({
|
||||
source: {
|
||||
entry: {
|
||||
index: "src/index.ts",
|
||||
"experimental-warning-suppression": "src/experimental-warning-suppression.ts",
|
||||
},
|
||||
},
|
||||
output: {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Patches `process.emit` so `ExperimentalWarning` (e.g. from `node:sqlite`) is not
|
||||
* forwarded to the default handler. Other warning types are unchanged.
|
||||
*
|
||||
* Import this module before any code that loads `node:sqlite`.
|
||||
*/
|
||||
|
||||
const WARNING_EVENT = "warning";
|
||||
const EXPERIMENTAL_WARNING_NAME = "ExperimentalWarning";
|
||||
|
||||
type EmitFn = typeof process.emit;
|
||||
|
||||
const originalEmit = process.emit.bind(process) as EmitFn;
|
||||
|
||||
process.emit = ((event: string | symbol, ...args: unknown[]): boolean => {
|
||||
if (event === WARNING_EVENT) {
|
||||
const w = args[0];
|
||||
if (w instanceof Error && w.name === EXPERIMENTAL_WARNING_NAME) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return Reflect.apply(originalEmit, process, [event, ...args]) as boolean;
|
||||
}) as EmitFn;
|
||||
@@ -14,6 +14,8 @@
|
||||
* nerve.yaml ← config
|
||||
*/
|
||||
|
||||
import "@uncaged/nerve-core/experimental-warning-suppression.js";
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
* workflows/<name>/index.ts (or .js) ← user workflow definition
|
||||
*/
|
||||
|
||||
import "@uncaged/nerve-core/experimental-warning-suppression.js";
|
||||
|
||||
import { existsSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
|
||||
|
||||
Generated
+4
-1
@@ -58,9 +58,12 @@ importers:
|
||||
'@rslib/core':
|
||||
specifier: ^0.21.3
|
||||
version: 0.21.3(typescript@5.9.3)
|
||||
'@types/node':
|
||||
specifier: ^22.0.0
|
||||
version: 22.19.17
|
||||
vitest:
|
||||
specifier: ^4.1.5
|
||||
version: 4.1.5(@types/node@25.6.0)(vite@8.0.9(@types/node@25.6.0)(esbuild@0.27.7)(yaml@2.8.3))
|
||||
version: 4.1.5(@types/node@22.19.17)(vite@8.0.9(@types/node@22.19.17)(esbuild@0.27.7)(yaml@2.8.3))
|
||||
|
||||
packages/daemon:
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user