GeezerVison is showing github.com — wasi: require CLI flag to require() wasi module · nodejs/node@5d2ae05
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/bootstrap/pre_execution.js +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -402,11 +402,10 @@ function initializePolicy() { |
402 | 402 | } |
403 | 403 |
|
404 | 404 | function initializeWASI() { |
405 | | - if (getOptionValue('--experimental-wasi-unstable-preview0')) { |
406 | | - const { NativeModule } = require('internal/bootstrap/loaders'); |
407 | | - const mod = NativeModule.map.get('wasi'); |
408 | | - mod.canBeRequiredByUsers = true; |
409 | | - } |
| 405 | + const { NativeModule } = require('internal/bootstrap/loaders'); |
| 406 | + const mod = NativeModule.map.get('wasi'); |
| 407 | + mod.canBeRequiredByUsers = |
| 408 | + getOptionValue('--experimental-wasi-unstable-preview0'); |
410 | 409 | } |
411 | 410 |
|
412 | 411 | function initializeCJSLoader() { |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_native_module.cc +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -98,6 +98,7 @@ void NativeModuleLoader::InitializeModuleCategories() { |
98 | 98 | #endif // !HAVE_OPENSSL |
99 | 99 |
|
100 | 100 | "sys", // Deprecated. |
| 101 | + "wasi", // Experimental. |
101 | 102 | "internal/test/binding", |
102 | 103 | "internal/v8_prof_polyfill", |
103 | 104 | "internal/v8_prof_processor", |
|
Collapse file
Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +// This test verifies that the WASI module cannot be require()'ed without a |
| 3 | +// CLI flag while it is still experimental. |
| 4 | +require('../common'); |
| 5 | +const assert = require('assert'); |
| 6 | + |
| 7 | +assert.throws(() => { |
| 8 | + require('wasi'); |
| 9 | +}, /^Error: Cannot find module 'wasi'/); |