Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: --no-dom-globals CLI flag #5853

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ parser.add_option('--enable-static',
dest='enable_static',
help='build as static library')

parser.add_option('--no-browser-globals',
action='store_true',
dest='no_browser_globals',
help='do not export browser globals like setTimeout, console, etc. ' +
'(This mode is not officially supported for regular applications)')

(options, args) = parser.parse_args()

# Expand ~ in the install prefix now, it gets written to multiple files.
Expand Down Expand Up @@ -762,6 +768,8 @@ def configure_node(o):
if options.enable_static:
o['variables']['node_target_type'] = 'static_library'

o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)

if options.linked_module:
o['variables']['library_files'] = options.linked_module

Expand Down
6 changes: 4 additions & 2 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
setupProcessFatal();

setupGlobalVariables();
setupGlobalTimeouts();
setupGlobalConsole();
if (!process._noBrowserGlobals) {
setupGlobalTimeouts();
setupGlobalConsole();
}

const _process = NativeModule.require('internal/process');

Expand Down
4 changes: 4 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'node_use_lttng%': 'false',
'node_use_etw%': 'false',
'node_use_perfctr%': 'false',
'node_no_browser_globals%': 'false',
'node_has_winsdk%': 'false',
'node_shared_zlib%': 'false',
'node_shared_http_parser%': 'false',
Expand Down Expand Up @@ -366,6 +367,9 @@
'tools/msvs/genfiles/node_perfctr_provider.rc',
]
} ],
[ 'node_no_browser_globals=="true"', {
'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
} ],
[ 'v8_postmortem_support=="true"', {
'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
'conditions': [
Expand Down
5 changes: 5 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3058,6 +3058,11 @@ void SetupProcessObject(Environment* env,
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
if (prof_process) {
READONLY_PROPERTY(process, "profProcess", True(env->isolate()));
Expand Down