cli: add flag for disabling globals
Per https://github.com/nodejs/node/pull/50412#issuecomment-1783405435, this creates a new flag --disable-global
to provide the user a way to disable certain global APIs. The globals that can be disabled include CustomEvent
, fetch
(and its associated FormData
, Headers
, Request
, and Response
), navigator
, and WebSocket
.
The motivation for this flag is both to provide a compatibility escape hatch and also to abstract this ability for future global APIs. We currently have several flags for specific web APIs, like --no-experimental-fetch
and --no-experimental-global-customevent
; as we continue to add web APIs, which are often globals, these per-API flags will proliferate. Rather than continue to grow our long list of CLI flags, a single flag that takes multiple options seems preferable.
@nodejs/web-standards @nodejs/tsc