From 5bc8b594d1deebb62bbde4af589afff39982aad3 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 26 Oct 2023 18:35:13 +0200 Subject: [PATCH 1/3] lib: hide `navigator` behind a flag --- doc/api/cli.md | 12 ++++++++++++ .../bootstrap/web/exposed-window-or-worker.js | 4 ---- lib/internal/process/pre_execution.js | 14 ++++++++++++++ src/node_options.cc | 4 ++++ src/node_options.h | 1 + 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 3cb36818ae4997..023dfd103112c5 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -646,6 +646,16 @@ CommonJS. This includes `import` and `export` statements and `import.meta` references. It does _not_ include `import()` expressions, which are valid in CommonJS. +### `--experimental-global-navigator` + + + +> Stability: 1 - Experimental + +Enable exposition of [Navigator API][] on the global scope. + ### `--experimental-import-meta-resolve` -> Stability: 1.1 - Active development +> Stability: 1.1 - Active development. Use `--experimental-global-navigator` to +> enable this feature. A partial implementation of the [Navigator API][]. @@ -608,20 +613,17 @@ A partial implementation of the [Navigator API][]. -> Stability: 1.1 - Active development +> Stability: 1.1 - Active development. Use `--experimental-global-navigator` to +> enable this feature. A partial implementation of [`window.navigator`][]. -If your app or a dependency uses a check for `navigator` to determine whether it -is running in a browser, the following can be used to delete the `navigator` -global before app code runs: - -```bash -node --import 'data:text/javascript,delete globalThis.navigator' app.js -``` - ### `navigator.hardwareConcurrency` > Stability: 1.1 - Active development. Use `--experimental-global-navigator` to @@ -614,9 +614,9 @@ A partial implementation of the [Navigator API][]. > Stability: 1.1 - Active development. Use `--experimental-global-navigator` to