diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 766f9a6f4c6674..060593084ce27c 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -180,8 +180,7 @@ if (config.hasInspector) { internalBinding('inspector').registerAsyncHook(enable, disable); } -const browserGlobals = !process._noBrowserGlobals; -if (browserGlobals) { +if (!config.noBrowserGlobals) { // Override global console from the one provided by the VM // to the one implemented by Node.js // https://console.spec.whatwg.org/#console-namespace diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 739a78208b62da..d295a5fec7e286 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -135,6 +135,20 @@ function initializeDeprecations() { 'DEP0103') : types[name]; } + + // TODO(joyeecheung): this is a legacy property exposed to process. + // Now that we use the config binding to carry this information, remove + // it from the process. We may consider exposing it properly in + // process.features. + const { noBrowserGlobals } = internalBinding('config'); + if (noBrowserGlobals) { + Object.defineProperty(process, '_noBrowserGlobals', { + writable: false, + enumerable: true, + configurable: true, + value: noBrowserGlobals + }); + } } function setupChildProcessIpcChannel() { diff --git a/src/node_config.cc b/src/node_config.cc index 7ecf70fdb6256a..2b8ff8abff94d7 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -70,6 +70,13 @@ static void Initialize(Local target, READONLY_FALSE_PROPERTY(target, "hasInspector"); #endif +// configure --no-browser-globals +#ifdef NODE_NO_BROWSER_GLOBALS + READONLY_TRUE_PROPERTY(target, "noBrowserGlobals"); +#else + READONLY_FALSE_PROPERTY(target, "noBrowserGlobals"); +#endif // NODE_NO_BROWSER_GLOBALS + READONLY_PROPERTY(target, "bits", Number::New(env->isolate(), 8 * sizeof(intptr_t))); diff --git a/src/node_process_object.cc b/src/node_process_object.cc index b424920c629e69..e4d9d97c681bdd 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -233,11 +233,6 @@ MaybeLocal CreateProcessObject( READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate())); } -#ifdef NODE_NO_BROWSER_GLOBALS - // configure --no-browser-globals - READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate())); -#endif // NODE_NO_BROWSER_GLOBALS - // --prof-process // TODO(addaleax): Remove this. if (env->options()->prof_process) {