Skip to content

Commit b6d4790

Browse files
committed
esm: unflag --experimental-wasm-modules
PR-URL: nodejs#57038 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 3c7a39b commit b6d4790

File tree

12 files changed

+33
-63
lines changed

12 files changed

+33
-63
lines changed

doc/api/cli.md

Lines changed: 2 additions & 14 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
@@ -1219,14 +1217,6 @@ changes:
12191217

12201218
Enable experimental WebAssembly System Interface (WASI) support.
12211219

1222-
### `--experimental-wasm-modules`
1223-
1224-
<!-- YAML
1225-
added: v12.3.0
1226-
-->
1227-
1228-
Enable experimental WebAssembly module support.
1229-
12301220
### `--experimental-webstorage`
12311221

12321222
<!-- YAML
@@ -3338,7 +3328,6 @@ one is included in the list below.
33383328
* `--experimental-transform-types`
33393329
* `--experimental-vm-modules`
33403330
* `--experimental-wasi-unstable-preview1`
3341-
* `--experimental-wasm-modules`
33423331
* `--experimental-webstorage`
33433332
* `--force-context-aware`
33443333
* `--force-fips`
@@ -3908,7 +3897,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
39083897
[`--env-file`]: #--env-fileconfig
39093898
[`--experimental-default-type=module`]: #--experimental-default-typetype
39103899
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3911-
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
39123900
[`--heap-prof-dir`]: #--heap-prof-dir
39133901
[`--import`]: #--importmodule
39143902
[`--no-experimental-strip-types`]: #--no-experimental-strip-types

doc/api/esm.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,24 @@ imported from the same path.
639639
640640
## Wasm modules
641641
642+
<!-- YAML
643+
changes:
644+
- version: REPLACEME
645+
pr-url: https://github.com/nodejs/node/pull/57038
646+
description: Wasm modules no longer require the `--experimental-wasm-modules` flag.
647+
-->
648+
649+
Importing both WebAssembly module instances and WebAssembly source phase
650+
imports is supported.
651+
652+
This integration is in line with the
653+
[ES Module Integration Proposal for WebAssembly][].
654+
655+
## Wasm modules
656+
642657
> Stability: 1 - Experimental
643658
644-
Importing WebAssembly modules is supported under the
645-
`--experimental-wasm-modules` flag, allowing any `.wasm` files to be
659+
Importing WebAssembly modules is supported allowing any `.wasm` files to be
646660
imported as normal modules while also supporting their module imports.
647661
648662
This integration is in line with the
@@ -658,7 +672,7 @@ console.log(M);
658672
executed under:
659673
660674
```bash
661-
node --experimental-wasm-modules index.mjs
675+
node index.mjs
662676
```
663677
664678
would provide the exports interface for the instantiation of `module.wasm`.
@@ -1020,7 +1034,7 @@ _isImports_, _conditions_)
10201034
> 1. Return _"commonjs"_.
10211035
> 4. If _url_ ends in _".json"_, then
10221036
> 1. Return _"json"_.
1023-
> 5. If `--experimental-wasm-modules` is enabled and _url_ ends in
1037+
> 5. If _url_ ends in
10241038
> _".wasm"_, then
10251039
> 1. Return _"wasm"_.
10261040
> 6. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_url_).
@@ -1035,9 +1049,8 @@ _isImports_, _conditions_)
10351049
> 1. Return _"module"_.
10361050
> 3. Return _"commonjs"_.
10371051
> 11. If _url_ does not have any extension, then
1038-
> 1. If _packageType_ is _"module"_ and `--experimental-wasm-modules` is
1039-
> enabled and the file at _url_ contains the header for a WebAssembly
1040-
> module, then
1052+
> 1. If _packageType_ is _"module"_ and the file at _url_ contains the
1053+
> header for a WebAssembly module, then
10411054
> 1. Return _"wasm"_.
10421055
> 2. If _packageType_ is not **null**, then
10431056
> 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 -force-context-aware
241238
Disable loading native addons that are not context-aware.
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
@@ -432,8 +432,6 @@ translators.set('json', function jsonStrategy(url, source) {
432432
*/
433433
const wasmInstances = new SafeWeakMap();
434434
translators.set('wasm', async function(url, source) {
435-
emitExperimentalWarning('Importing WebAssembly modules');
436-
437435
assertBufferSource(source, false, 'load');
438436

439437
debug(`Translating WASMModule ${url}`);
@@ -470,6 +468,7 @@ translators.set('wasm', async function(url, source) {
470468
const createDynamicModule = require('internal/modules/esm/create_dynamic_module');
471469

472470
const { module } = createDynamicModule([...importsList], [...exportsList], url, (reflect) => {
471+
emitExperimentalWarning('Importing WebAssembly module instances');
473472
for (const impt of importsList) {
474473
const importNs = reflect.imports[impt];
475474
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

test/es-module/test-esm-wasm.mjs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
99
it('should load exports', async () => {
1010
const { code, stderr, stdout } = await spawnPromisified(execPath, [
1111
'--no-warnings',
12-
'--experimental-wasm-modules',
1312
'--input-type=module',
1413
'--eval',
1514
[
@@ -32,7 +31,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
3231
it('should not allow code injection through export names', async () => {
3332
const { code, stderr, stdout } = await spawnPromisified(execPath, [
3433
'--no-warnings',
35-
'--experimental-wasm-modules',
3634
'--input-type=module',
3735
'--eval',
3836
`import * as wasmExports from ${JSON.stringify(fixtures.fileURL('es-modules/export-name-code-injection.wasm'))};`,
@@ -46,7 +44,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
4644
it('should allow non-identifier export names', async () => {
4745
const { code, stderr, stdout } = await spawnPromisified(execPath, [
4846
'--no-warnings',
49-
'--experimental-wasm-modules',
5047
'--input-type=module',
5148
'--eval',
5249
[
@@ -64,7 +61,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
6461
it('should properly handle all WebAssembly global types', async () => {
6562
const { code, stderr, stdout } = await spawnPromisified(execPath, [
6663
'--no-warnings',
67-
'--experimental-wasm-modules',
6864
'--input-type=module',
6965
'--eval',
7066
[
@@ -211,7 +207,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
211207
it('should properly escape import names as well', async () => {
212208
const { code, stderr, stdout } = await spawnPromisified(execPath, [
213209
'--no-warnings',
214-
'--experimental-wasm-modules',
215210
'--input-type=module',
216211
'--eval',
217212
[
@@ -226,22 +221,20 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
226221
strictEqual(code, 0);
227222
});
228223

229-
it('should emit experimental warning', async () => {
224+
it('should emit experimental warning for module instances', async () => {
230225
const { code, signal, stderr } = await spawnPromisified(execPath, [
231-
'--experimental-wasm-modules',
232226
fixtures.path('es-modules/wasm-modules.mjs'),
233227
]);
234228

235229
strictEqual(code, 0);
236230
strictEqual(signal, null);
237231
match(stderr, /ExperimentalWarning/);
238-
match(stderr, /WebAssembly/);
232+
match(stderr, /Importing WebAssembly module instances/);
239233
});
240234

241235
it('should support top-level execution', async () => {
242236
const { code, stderr, stdout } = await spawnPromisified(execPath, [
243237
'--no-warnings',
244-
'--experimental-wasm-modules',
245238
fixtures.path('es-modules/top-level-wasm.wasm'),
246239
]);
247240

@@ -254,7 +247,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
254247
it.skip('should support static source phase imports', async () => {
255248
const { code, stderr, stdout } = await spawnPromisified(execPath, [
256249
'--no-warnings',
257-
'--experimental-wasm-modules',
258250
'--input-type=module',
259251
'--eval',
260252
[
@@ -276,7 +268,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
276268
it.skip('should support dynamic source phase imports', async () => {
277269
const { code, stderr, stdout } = await spawnPromisified(execPath, [
278270
'--no-warnings',
279-
'--experimental-wasm-modules',
280271
'--input-type=module',
281272
'--eval',
282273
[
@@ -299,7 +290,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
299290
it.skip('should not execute source phase imports', async () => {
300291
const { code, stderr, stdout } = await spawnPromisified(execPath, [
301292
'--no-warnings',
302-
'--experimental-wasm-modules',
303293
'--input-type=module',
304294
'--eval',
305295
[
@@ -319,7 +309,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
319309
it.skip('should not execute dynamic source phase imports', async () => {
320310
const { code, stderr, stdout } = await spawnPromisified(execPath, [
321311
'--no-warnings',
322-
'--experimental-wasm-modules',
323312
'--input-type=module',
324313
'--eval',
325314
`await import.source(${JSON.stringify(fixtures.fileURL('es-modules/unimportable.wasm'))})`,
@@ -335,7 +324,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
335324
const fileUrl = fixtures.fileURL('es-modules/wasm-source-phase.js');
336325
const { code, stderr, stdout } = await spawnPromisified(execPath, [
337326
'--no-warnings',
338-
'--experimental-wasm-modules',
339327
'--input-type=module',
340328
'--eval',
341329
[
@@ -358,7 +346,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
358346
const fileUrl = fixtures.fileURL('es-modules/wasm-source-phase.js');
359347
const { code, stderr, stdout } = await spawnPromisified(execPath, [
360348
'--no-warnings',
361-
'--experimental-wasm-modules',
362349
'--input-type=module',
363350
'--eval',
364351
`import source nosource from ${JSON.stringify(fileUrl)};`,
@@ -373,7 +360,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
373360
it.skip('should throw for vm source phase static import', async () => {
374361
const { code, stderr, stdout } = await spawnPromisified(execPath, [
375362
'--no-warnings',
376-
'--experimental-wasm-modules',
377363
'--experimental-vm-modules',
378364
'--input-type=module',
379365
'--eval',
@@ -393,7 +379,6 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
393379
it.skip('should throw for vm source phase dynamic import', async () => {
394380
const { code, stderr, stdout } = await spawnPromisified(execPath, [
395381
'--no-warnings',
396-
'--experimental-wasm-modules',
397382
'--experimental-vm-modules',
398383
'--input-type=module',
399384
'--eval',

test/module-hooks/test-module-hooks-import-wasm.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Flags: --no-experimental-wasm-modules
21
// This tests that module.registerHooks() can be used to support unknown formats, like
3-
// import(wasm) (without --experimental-wasm-modules).
2+
// import(wasm)
43
import '../common/index.mjs';
54

65
import assert from 'node:assert';

0 commit comments

Comments
 (0)