Skip to content

Commit b41afa4

Browse files
committed
src: use the config binding to carry --no-browser-globals
Instead of setting it in the process object, since this is a configure-time option. Also added a shim that can be deprecated and removed some time later.
1 parent 3770ab9 commit b41afa4

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

lib/internal/bootstrap/node.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ if (config.hasInspector) {
180180
internalBinding('inspector').registerAsyncHook(enable, disable);
181181
}
182182

183-
const browserGlobals = !process._noBrowserGlobals;
184-
if (browserGlobals) {
183+
if (!config.noBrowserGlobals) {
185184
// Override global console from the one provided by the VM
186185
// to the one implemented by Node.js
187186
// https://console.spec.whatwg.org/#console-namespace

lib/internal/bootstrap/pre_execution.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ function initializeDeprecations() {
136136
'DEP0103') :
137137
types[name];
138138
}
139+
140+
// TODO(joyeecheung): this is a legacy property exposed to process.
141+
// Now that we use the config binding to carry this information, remove
142+
// it from the process. We may consider exposing it properly in
143+
// process.features.
144+
const { noBrowserGlobals } = internalBinding('config');
145+
if (noBrowserGlobals) {
146+
Object.defineProperty(process, '_noBrowserGlobals', {
147+
writable: false,
148+
enumerable: true,
149+
configurable: true,
150+
value: noBrowserGlobals
151+
});
152+
}
139153
}
140154

141155
function setupChildProcessIpcChannel() {

src/node_config.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ static void Initialize(Local<Object> target,
6464
READONLY_FALSE_PROPERTY(target, "hasInspector");
6565
#endif
6666

67+
// configure --no-browser-globals
68+
#ifdef NODE_NO_BROWSER_GLOBALS
69+
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");
70+
#else
71+
READONLY_FALSE_PROPERTY(target, "noBrowserGlobals");
72+
#endif // NODE_NO_BROWSER_GLOBALS
73+
6774
READONLY_PROPERTY(target,
6875
"bits",
6976
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

src/node_process_object.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@ MaybeLocal<Object> CreateProcessObject(
233233
READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate()));
234234
}
235235

236-
#ifdef NODE_NO_BROWSER_GLOBALS
237-
// configure --no-browser-globals
238-
READONLY_PROPERTY(process, "_noBrowserGlobals", True(env->isolate()));
239-
#endif // NODE_NO_BROWSER_GLOBALS
240-
241236
// --prof-process
242237
// TODO(addaleax): Remove this.
243238
if (env->options()->prof_process) {

0 commit comments

Comments
 (0)