Skip to content

Commit fa9a9e9

Browse files
guybedfordaduh95
authored andcommitted
esm: unflag --experimental-wasm-modules
PR-URL: #57038 Backport-PR-URL: #59179 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 177ed3b commit fa9a9e9

File tree

12 files changed

+32
-80
lines changed

12 files changed

+32
-80
lines changed

doc/api/cli.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ If a file is found, its path will be passed to the
3636
point to be loaded with ECMAScript module loader, such as `--import` or
3737
[`--experimental-default-type=module`][].
3838
* The file has an `.mjs` extension.
39-
* The file has an `.mjs` or `.wasm` (with `--experimental-wasm-modules`)
40-
extension.
39+
* The file has an `.mjs` or `.wasm` extension.
4140
* The file does not have a `.cjs` extension, and the nearest parent
4241
`package.json` file contains a top-level [`"type"`][] field with a value of
4342
`"module"`.
@@ -49,8 +48,7 @@ Otherwise, the file is loaded using the CommonJS module loader. See
4948

5049
When loading, the [ES module loader][Modules loaders] loads the program
5150
entry point, the `node` command will accept as input only files with `.js`,
52-
`.mjs`, or `.cjs` extensions; with `.wasm` extensions when
53-
[`--experimental-wasm-modules`][] is enabled; and with no extension when
51+
`.mjs`, `.cjs` or `.wasm` extensions; and with no extension when
5452
[`--experimental-default-type=module`][] is passed.
5553

5654
## Options
@@ -1015,8 +1013,7 @@ Node.js currently defaults to CommonJS to instead default to ECMAScript modules,
10151013
with the exception of folders and subfolders below `node_modules`, for backward
10161014
compatibility.
10171015

1018-
Under `--experimental-default-type=module` and `--experimental-wasm-modules`,
1019-
files with no extension will be treated as WebAssembly if they begin with the
1016+
Files with no extension will be treated as WebAssembly if they begin with the
10201017
WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module
10211018
JavaScript.
10221019

@@ -1233,14 +1230,6 @@ changes:
12331230

12341231
Enable experimental WebAssembly System Interface (WASI) support.
12351232

1236-
### `--experimental-wasm-modules`
1237-
1238-
<!-- YAML
1239-
added: v12.3.0
1240-
-->
1241-
1242-
Enable experimental WebAssembly module support.
1243-
12441233
### `--experimental-webstorage`
12451234

12461235
<!-- YAML
@@ -3356,7 +3345,6 @@ one is included in the list below.
33563345
* `--experimental-transform-types`
33573346
* `--experimental-vm-modules`
33583347
* `--experimental-wasi-unstable-preview1`
3359-
* `--experimental-wasm-modules`
33603348
* `--experimental-webstorage`
33613349
* `--force-context-aware`
33623350
* `--force-fips`
@@ -3938,7 +3926,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
39383926
[`--env-file`]: #--env-fileconfig
39393927
[`--experimental-default-type=module`]: #--experimental-default-typetype
39403928
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3941-
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
39423929
[`--heap-prof-dir`]: #--heap-prof-dir
39433930
[`--import`]: #--importmodule
39443931
[`--no-experimental-strip-types`]: #--no-experimental-strip-types

doc/api/esm.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,24 @@ imported from the same path.
672672
673673
## Wasm modules
674674
675+
<!-- YAML
676+
changes:
677+
- version: REPLACEME
678+
pr-url: https://github.com/nodejs/node/pull/57038
679+
description: Wasm modules no longer require the `--experimental-wasm-modules` flag.
680+
-->
681+
682+
Importing both WebAssembly module instances and WebAssembly source phase
683+
imports is supported.
684+
685+
This integration is in line with the
686+
[ES Module Integration Proposal for WebAssembly][].
687+
688+
## Wasm modules
689+
675690
> Stability: 1 - Experimental
676691
677-
Importing WebAssembly modules is supported under the
678-
`--experimental-wasm-modules` flag, allowing any `.wasm` files to be
692+
Importing WebAssembly modules is supported allowing any `.wasm` files to be
679693
imported as normal modules while also supporting their module imports.
680694
681695
This integration is in line with the
@@ -691,7 +705,7 @@ console.log(M);
691705
executed under:
692706
693707
```bash
694-
node --experimental-wasm-modules index.mjs
708+
node index.mjs
695709
```
696710
697711
would provide the exports interface for the instantiation of `module.wasm`.
@@ -738,15 +752,6 @@ imports and they cannot be inspected via `WebAssembly.Module.imports(mod)`
738752
or virtualized unless recompiling the module using the direct
739753
`WebAssembly.compile` API with string builtins disabled.
740754
741-
Importing a module in the source phase before it has been instantiated will also
742-
use the compile-time builtins automatically:
743-
744-
```js
745-
import source mod from './string-len.wasm';
746-
const { exports: { getLength } } = await WebAssembly.instantiate(mod, {});
747-
getLength('foo'); // Also returns 3.
748-
```
749-
750755
### Reserved Wasm Namespaces
751756
752757
<!-- YAML
@@ -1121,7 +1126,7 @@ _isImports_, _conditions_)
11211126
> 1. Return _"commonjs"_.
11221127
> 4. If _url_ ends in _".json"_, then
11231128
> 1. Return _"json"_.
1124-
> 5. If `--experimental-wasm-modules` is enabled and _url_ ends in
1129+
> 5. If _url_ ends in
11251130
> _".wasm"_, then
11261131
> 1. Return _"wasm"_.
11271132
> 6. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_url_).
@@ -1136,9 +1141,8 @@ _isImports_, _conditions_)
11361141
> 1. Return _"module"_.
11371142
> 3. Return _"commonjs"_.
11381143
> 11. If _url_ does not have any extension, then
1139-
> 1. If _packageType_ is _"module"_ and `--experimental-wasm-modules` is
1140-
> enabled and the file at _url_ contains the header for a WebAssembly
1141-
> module, then
1144+
> 1. If _packageType_ is _"module"_ and the file at _url_ contains the
1145+
> header for a WebAssembly module, then
11421146
> 1. Return _"wasm"_.
11431147
> 2. If _packageType_ is not **null**, then
11441148
> 1. Return _packageType_.

doc/node-config-schema.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@
186186
"experimental-vm-modules": {
187187
"type": "boolean"
188188
},
189-
"experimental-wasm-modules": {
190-
"type": "boolean"
191-
},
192189
"experimental-websocket": {
193190
"type": "boolean"
194191
},

doc/node.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ Enable experimental ES module support in VM module.
234234
Enable experimental WebAssembly System Interface support. This
235235
flag is no longer required as WASI is enabled by default.
236236
.
237-
.It Fl -experimental-wasm-modules
238-
Enable experimental WebAssembly module support.
239-
.
240237
.It Fl -experimental-inspector-network-resource
241238
Enable experimental support for inspector network resources.
242239
.

lib/internal/modules/esm/formats.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@ const { getValidatedPath } = require('internal/fs/utils');
99
const fsBindings = internalBinding('fs');
1010
const { internal: internalConstants } = internalBinding('constants');
1111

12-
const experimentalWasmModules = getOptionValue('--experimental-wasm-modules');
13-
1412
const extensionFormatMap = {
1513
'__proto__': null,
1614
'.cjs': 'commonjs',
1715
'.js': 'module',
1816
'.json': 'json',
1917
'.mjs': 'module',
18+
'.wasm': 'wasm',
2019
};
2120

22-
if (experimentalWasmModules) {
23-
extensionFormatMap['.wasm'] = 'wasm';
24-
}
25-
2621
if (getOptionValue('--experimental-strip-types')) {
2722
extensionFormatMap['.ts'] = 'module-typescript';
2823
extensionFormatMap['.mts'] = 'module-typescript';
@@ -41,7 +36,7 @@ function mimeToFormat(mime) {
4136
) !== null
4237
) { return 'module'; }
4338
if (mime === 'application/json') { return 'json'; }
44-
if (experimentalWasmModules && mime === 'application/wasm') { return 'wasm'; }
39+
if (mime === 'application/wasm') { return 'wasm'; }
4540
return null;
4641
}
4742

@@ -52,7 +47,6 @@ function mimeToFormat(mime) {
5247
* @param {URL} url
5348
*/
5449
function getFormatOfExtensionlessFile(url) {
55-
if (!experimentalWasmModules) { return 'module'; }
5650
const path = getValidatedPath(url);
5751
switch (fsBindings.getFormatOfExtensionlessFile(path)) {
5852
case internalConstants.EXTENSIONLESS_FORMAT_WASM:

lib/internal/modules/esm/translators.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,6 @@ translators.set('json', function jsonStrategy(url, source) {
433433
*/
434434
const wasmInstances = new SafeWeakMap();
435435
translators.set('wasm', async function(url, source) {
436-
emitExperimentalWarning('Importing WebAssembly modules');
437-
438436
assertBufferSource(source, false, 'load');
439437

440438
debug(`Translating WASMModule ${url}`);
@@ -483,6 +481,7 @@ translators.set('wasm', async function(url, source) {
483481
const createDynamicModule = require('internal/modules/esm/create_dynamic_module');
484482

485483
const { module } = createDynamicModule([...importsList], [...exportsList], url, (reflect) => {
484+
emitExperimentalWarning('Importing WebAssembly module instances');
486485
for (const impt of importsList) {
487486
const importNs = reflect.imports[impt];
488487
const wasmInstance = wasmInstances.get(importNs);

src/node_options.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
479479
kAllowedInEnvvar);
480480
AddAlias("--loader", "--experimental-loader");
481481
AddOption("--experimental-modules", "", NoOp{}, kAllowedInEnvvar);
482-
AddOption("--experimental-wasm-modules",
483-
"experimental ES Module support for webassembly modules",
484-
&EnvironmentOptions::experimental_wasm_modules,
485-
kAllowedInEnvvar);
482+
AddOption("--experimental-wasm-modules", "", NoOp{}, kAllowedInEnvvar);
486483
AddOption("--experimental-import-meta-resolve",
487484
"experimental ES Module import.meta.resolve() parentURL support",
488485
&EnvironmentOptions::experimental_import_meta_resolve,

src/node_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ class EnvironmentOptions : public Options {
130130
bool experimental_global_customevent = true;
131131
bool experimental_global_navigator = true;
132132
bool experimental_global_web_crypto = true;
133-
bool experimental_wasm_modules = false;
134133
bool experimental_import_meta_resolve = false;
135134
std::string input_type; // Value of --input-type
136135
std::string type; // Value of --experimental-default-type

0 commit comments

Comments
 (0)