diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-12-04 01:11:29 +0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-12-05 10:31:44 -0800 |
commit | 28efa4fe953c0da6be25cd10e708b84deaada15f (patch) | |
tree | d6ae76a768589e6b4e10ac8cc67293242ee74b7c /lib/internal/bootstrap | |
parent | 7113d999dcb7e93ac1504f3ae622df61a9495a1c (diff) | |
download | android-node-v8-28efa4fe953c0da6be25cd10e708b84deaada15f.tar.gz android-node-v8-28efa4fe953c0da6be25cd10e708b84deaada15f.tar.bz2 android-node-v8-28efa4fe953c0da6be25cd10e708b84deaada15f.zip |
lib: delay access to CLI option to pre-execution
CLI options should not be added through the config binding, instead
they are already available in the JS land via
`require('internal/options')`. Also CLI options in principle should
be processed in pre-execution instead of bootstrap scripts.
PR-URL: https://github.com/nodejs/node/pull/30778
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/bootstrap')
-rw-r--r-- | lib/internal/bootstrap/loaders.js | 3 | ||||
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 12 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 044bea3114..cfefc56bd8 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -157,9 +157,6 @@ function NativeModule(id) { this.loaded = false; this.loading = false; this.canBeRequiredByUsers = !id.startsWith('internal/'); - - if (id === 'wasi') - this.canBeRequiredByUsers = !!internalBinding('config').experimentalWasi; } // To be called during pre-execution when --expose-internals is on. diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index b373801592..0529bd6585 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -61,6 +61,7 @@ function prepareMainThreadExecution(expandArgv1 = false) { initializeClusterIPC(); initializeDeprecations(); + initializeWASI(); initializeCJSLoader(); initializeESMLoader(); @@ -399,6 +400,14 @@ function initializePolicy() { } } +function initializeWASI() { + if (getOptionValue('--experimental-wasi-unstable-preview0')) { + const { NativeModule } = require('internal/bootstrap/loaders'); + const mod = NativeModule.map.get('wasi'); + mod.canBeRequiredByUsers = true; + } +} + function initializeCJSLoader() { const CJSLoader = require('internal/modules/cjs/loader'); CJSLoader.Module._initPaths(); @@ -456,5 +465,6 @@ module.exports = { setupTraceCategoryState, setupInspectorHooks, initializeReport, - initializeCJSLoader + initializeCJSLoader, + initializeWASI }; |