feat: make 'Buffer' and 'global' available as globals (#29416)

Follow up to https://github.com/denoland/deno/pull/29323.

This effort is to reduce a number of different globals available to user
code and npm dependencies. Also improves performance when these globals
are used.

Towards https://github.com/denoland/deno/issues/29703
This commit is contained in:
Bartek Iwańczuk 2025-06-24 14:31:06 +02:00 committed by GitHub
parent 38f6720185
commit ed0c77edb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 8 additions and 60 deletions

View file

@ -343,16 +343,6 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
)),
FixSuggestion::hint(cstr!("Use <u>import.meta.dirname</> instead.")),
];
} else if msg.contains("Buffer is not defined") {
return vec![
FixSuggestion::info(cstr!(
"<u>Buffer</> is not available in the global scope in Deno."
)),
FixSuggestion::hint_multiline(&[
cstr!("Import it explicitly with <u>import { Buffer } from \"node:buffer\";</>,"),
cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
]),
];
} else if msg.contains("clearImmediate is not defined") {
return vec![
FixSuggestion::info(cstr!(
@ -373,16 +363,6 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
]),
];
} else if msg.contains("global is not defined") {
return vec![
FixSuggestion::info(cstr!(
"<u>global</> is not available in the global scope in Deno."
)),
FixSuggestion::hint_multiline(&[
cstr!("Use <u>globalThis</> instead, or assign <u>globalThis.global = globalThis</>,"),
cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
]),
];
} else if msg.contains("openKv is not a function") {
return vec![
FixSuggestion::info("Deno.openKv() is an unstable API."),