diff options
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 }; |