fix(node): stub missing process.sourceMapsEnabled (#31358)

See https://nodejs.org/api/process.html#processsourcemapsenabled

This fixes an issue in Fresh with vite's environment API which relies on
this property to check if vite should map stack traces
https://github.com/vitejs/vite/blob/main/packages/vite/src/module-runner/sourcemap/index.ts#L17
This commit is contained in:
Marvin Hagemeister 2025-11-20 10:39:24 +01:00 committed by GitHub
parent 030826f589
commit dbe35b03fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -756,6 +756,15 @@ process.setSourceMapsEnabled = (_val: boolean) => {
// TODO(@satyarohith): support disabling source maps if needed.
};
// Source maps are always enabled in Deno.
Object.defineProperty(process, "sourceMapsEnabled", {
get() {
return true; // Source maps are always enabled in Deno.
},
enumerable: true,
configurable: true,
});
/**
* Returns the current high-resolution real time in a [seconds, nanoseconds]
* tuple.

View file

@ -1207,6 +1207,14 @@ Deno.test({
},
});
Deno.test({
name: "process.sourceMapsEnabled",
fn() {
// @ts-ignore: not available in the types yet.
assertEquals(process.sourceMapsEnabled, true);
},
});
// Regression test for https://github.com/denoland/deno/issues/23761
Deno.test({
name: "process.uptime without this",