wasi: no longer require flag to enable wasi

- no longer require flag to enable experimental wasi feature
- wasi is still documented as experimental

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/47286
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Michael Dawson 2023-03-28 15:28:41 -04:00
parent dad0b072c5
commit 978b57d750
17 changed files with 8 additions and 84 deletions

View File

@ -626,6 +626,10 @@ added:
- v13.3.0
- v12.16.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47286
description: This option is no longer required as WASI is
enabled by default, but can still be passed.
- version: v13.6.0
pr-url: https://github.com/nodejs/node/pull/30980
description: changed from `--experimental-wasi-unstable-preview0` to

View File

@ -97,9 +97,6 @@ Use [wabt](https://github.com/WebAssembly/wabt) to compile `.wat` to `.wasm`
$ wat2wasm demo.wat
```
The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
example to run.
## Class: `WASI`
<!-- YAML

View File

@ -194,7 +194,8 @@ Disable top-level await keyword support in REPL.
Enable experimental ES module support in VM module.
.
.It Fl -experimental-wasi-unstable-preview1
Enable experimental WebAssembly System Interface support.
Enable experimental WebAssembly System Interface support. This
flag is no longer required as WASI is enabled by default.
.
.It Fl -experimental-wasm-modules
Enable experimental WebAssembly module support.

View File

@ -79,7 +79,6 @@ function prepareExecution(options) {
initializeSourceMapsHandlers();
initializeDeprecations();
initializeWASI();
require('internal/dns/utils').initializeDns();
@ -596,13 +595,6 @@ function readPolicyFromDisk() {
}
}
function initializeWASI() {
const { BuiltinModule } = require('internal/bootstrap/loaders');
const mod = BuiltinModule.map.get('wasi');
mod.canBeRequiredByUsers =
getOptionValue('--experimental-wasi-unstable-preview1');
}
function initializeCJSLoader() {
const { initializeCJS } = require('internal/modules/cjs/loader');
initializeCJS();

View File

@ -447,10 +447,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
kAllowedInEnvvar);
AddOption("--experimental-worker", "", NoOp{}, kAllowedInEnvvar);
AddOption("--experimental-report", "", NoOp{}, kAllowedInEnvvar);
AddOption("--experimental-wasi-unstable-preview1",
"experimental WASI support",
&EnvironmentOptions::experimental_wasi,
kAllowedInEnvvar);
AddOption(
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
AddOption("--frozen-intrinsics",
"experimental frozen intrinsics support",

View File

@ -190,7 +190,6 @@ class EnvironmentOptions : public Options {
bool syntax_check_only = false;
bool has_eval_string = false;
bool experimental_wasi = false;
std::string eval_string;
bool print_eval = false;
bool force_repl = false;

View File

@ -1,48 +0,0 @@
'use strict';
require('../common');
const assert = require('assert');
const cp = require('child_process');
function runREPLWithAdditionalFlags(flags) {
// Use -i to force node into interactive mode, despite stdout not being a TTY
const args = ['-i'].concat(flags);
const ret = cp.execFileSync(process.execPath, args, {
input: 'require(\'events\');\nrequire(\'wasi\');',
encoding: 'utf8',
});
return ret;
}
// Run REPL in normal mode.
let stdout = runREPLWithAdditionalFlags([]);
assert.match(stdout, /\[Function: EventEmitter\] {/);
assert.match(
stdout,
/Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/);
// Run REPL with '--experimental-wasi-unstable-preview1'
stdout = runREPLWithAdditionalFlags([
'--experimental-wasi-unstable-preview1',
]);
assert.match(stdout, /\[Function: EventEmitter\] {/);
assert.doesNotMatch(
stdout,
/Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/);
assert.match(stdout, /{ WASI: \[class WASI\] }/);
{
const res = cp.execFileSync(process.execPath, ['-i'], {
input: "'wasi' in global",
encoding: 'utf8',
});
// `wasi` shouldn't be defined on global when the flag is not set
assert.match(res, /false\n/);
}
{
const res = cp.execFileSync(process.execPath, ['-i', '--experimental-wasi-unstable-preview1'], {
input: "'wasi' in global",
encoding: 'utf8',
});
assert.match(res, /true\n/);
}

View File

@ -1,4 +1,3 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');
const assert = require('assert');

View File

@ -1,4 +1,3 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');

View File

@ -28,7 +28,6 @@ if (process.argv[2] === 'wasi-child') {
const cp = require('child_process');
const child = cp.spawnSync(process.execPath, [
'--experimental-wasi-unstable-preview1',
__filename,
'wasi-child',
], {

View File

@ -1,7 +1,5 @@
'use strict';
// Flags: --experimental-wasi-unstable-preview1
require('../common');
const assert = require('assert');
const { WASI } = require('wasi');

View File

@ -1,9 +0,0 @@
'use strict';
// This test verifies that the WASI module cannot be require()'ed without a
// CLI flag while it is still experimental.
require('../common');
const assert = require('assert');
assert.throws(() => {
require('wasi');
}, /^Error: Cannot find module 'wasi'/);

View File

@ -1,4 +1,3 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');

View File

@ -1,4 +1,3 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');

View File

@ -63,7 +63,6 @@ if (process.argv[2] === 'wasi-child') {
console.log('executing', options.test);
const opts = { env: { ...process.env, NODE_DEBUG_NATIVE: 'wasi' } };
const child = cp.spawnSync(process.execPath, [
'--experimental-wasi-unstable-preview1',
__filename,
'wasi-child',
options.test,

View File

@ -1,4 +1,3 @@
// Flags: --experimental-wasi-unstable-preview1
'use strict';
const common = require('../common');

View File

@ -88,7 +88,6 @@ if (process.argv[2] === 'wasi-child-default') {
const child = cp.spawnSync(process.execPath, [
...args,
'--experimental-wasi-unstable-preview1',
__filename,
'wasi-child-' + flavor,
options.test,