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

src: cleanup cli options on internalBinding('config') #25463

Closed
wants to merge 2 commits 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
7 changes: 3 additions & 4 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// This file is compiled as if it's wrapped in a function with arguments
// passed by node::LoadEnvironment()
/* global process, getBinding, getLinkedBinding, getInternalBinding */
/* global debugBreak */
/* global debugBreak, experimentalModules, exposeInternals */

if (debugBreak)
debugger; // eslint-disable-line no-debugger
Expand Down Expand Up @@ -162,7 +162,6 @@ internalBinding('module_wrap').callbackMap = new WeakMap();
// written in CommonJS style.
const loaderExports = { internalBinding, NativeModule };
const loaderId = 'internal/bootstrap/loaders';
const config = internalBinding('config');

// Set up NativeModule.
function NativeModule(id) {
Expand All @@ -177,7 +176,7 @@ function NativeModule(id) {
// Do not expose this to user land even with --expose-internals.
this.canBeRequiredByUsers = false;
} else if (id.startsWith('internal/')) {
this.canBeRequiredByUsers = config.exposeInternals;
this.canBeRequiredByUsers = exposeInternals;
} else {
this.canBeRequiredByUsers = true;
}
Expand Down Expand Up @@ -316,7 +315,7 @@ NativeModule.prototype.compile = function() {
const fn = compileFunction(id);
fn(this.exports, requireFn, this, process, internalBinding);

if (config.experimentalModules && this.canBeRequiredByUsers) {
if (experimentalModules && this.canBeRequiredByUsers) {
this.proxifyExports();
}

Expand Down
13 changes: 11 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,12 @@ void RunBootstrapping(Environment* env) {
FIXED_ONE_BYTE_STRING(isolate, "getBinding"),
FIXED_ONE_BYTE_STRING(isolate, "getLinkedBinding"),
FIXED_ONE_BYTE_STRING(isolate, "getInternalBinding"),
FIXED_ONE_BYTE_STRING(isolate, "debugBreak")};
// --inspect-brk-node
FIXED_ONE_BYTE_STRING(isolate, "debugBreak"),
// --experimental-modules
FIXED_ONE_BYTE_STRING(isolate, "experimentalModules"),
// --expose-internals
FIXED_ONE_BYTE_STRING(isolate, "exposeInternals")};
std::vector<Local<Value>> loaders_args = {
process,
env->NewFunctionTemplate(binding::GetBinding)
Expand All @@ -689,7 +694,11 @@ void RunBootstrapping(Environment* env) {
->GetFunction(context)
.ToLocalChecked(),
Boolean::New(isolate,
env->options()->debug_options().break_node_first_line)};
env->options()->debug_options().break_node_first_line),
Boolean::New(isolate,
env->options()->experimental_modules),
Boolean::New(isolate,
env->options()->expose_internals)};

MaybeLocal<Value> loader_exports;
// Bootstrap internal loaders
Expand Down
22 changes: 0 additions & 22 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,6 @@ static void Initialize(Local<Object> target,

#endif // NODE_HAVE_I18N_SUPPORT

if (env->options()->preserve_symlinks)
READONLY_TRUE_PROPERTY(target, "preserveSymlinks");
if (env->options()->preserve_symlinks_main)
READONLY_TRUE_PROPERTY(target, "preserveSymlinksMain");

if (env->options()->experimental_modules) {
READONLY_TRUE_PROPERTY(target, "experimentalModules");
const std::string& userland_loader = env->options()->userland_loader;
if (!userland_loader.empty()) {
READONLY_STRING_PROPERTY(target, "userLoader", userland_loader);
}
}

if (env->options()->experimental_vm_modules)
READONLY_TRUE_PROPERTY(target, "experimentalVMModules");

if (env->options()->experimental_repl_await)
READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");

if (env->options()->expose_internals)
READONLY_TRUE_PROPERTY(target, "exposeInternals");

if (env->abort_on_uncaught_exception())
READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");

Expand Down
12 changes: 0 additions & 12 deletions test/parallel/test-internal-modules-expose.js

This file was deleted.