Skip to content

Commit b919fe0

Browse files
guybedfordaduh95
authored andcommitted
esm: unflag --experimental-wasm-modules
PR-URL: #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 88b99ee commit b919fe0

File tree

13 files changed

+49
-89
lines changed

13 files changed

+49
-89
lines changed

doc/api/cli.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ If a file is found, its path will be passed to the
3333

3434
* The program was started with a command-line flag that forces the entry
3535
point to be loaded with ECMAScript module loader, such as `--import`.
36-
* The file has an `.mjs` or `.wasm` (with `--experimental-wasm-modules`)
37-
extension.
36+
* The file has an `.mjs` or `.wasm` extension.
3837
* The file does not have a `.cjs` extension, and the nearest parent
3938
`package.json` file contains a top-level [`"type"`][] field with a value of
4039
`"module"`.
@@ -49,7 +48,6 @@ entry point, the `node` command will accept as input only files with `.js`,
4948
`.mjs`, or `.cjs` extensions. With the following flags, additional file
5049
extensions are enabled:
5150

52-
* [`--experimental-wasm-modules`][] for files with `.wasm` extension.
5351
* [`--experimental-addon-modules`][] for files with `.node` extension.
5452

5553
## Options
@@ -1217,14 +1215,6 @@ changes:
12171215

12181216
Enable experimental WebAssembly System Interface (WASI) support.
12191217

1220-
### `--experimental-wasm-modules`
1221-
1222-
<!-- YAML
1223-
added: v12.3.0
1224-
-->
1225-
1226-
Enable experimental WebAssembly module support.
1227-
12281218
### `--experimental-webstorage`
12291219

12301220
<!-- YAML
@@ -3364,7 +3354,6 @@ one is included in the list below.
33643354
* `--experimental-transform-types`
33653355
* `--experimental-vm-modules`
33663356
* `--experimental-wasi-unstable-preview1`
3367-
* `--experimental-wasm-modules`
33683357
* `--experimental-webstorage`
33693358
* `--force-context-aware`
33703359
* `--force-fips`
@@ -3943,7 +3932,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
39433932
[`--env-file`]: #--env-filefile
39443933
[`--experimental-addon-modules`]: #--experimental-addon-modules
39453934
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3946-
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
39473935
[`--heap-prof-dir`]: #--heap-prof-dir
39483936
[`--import`]: #--importmodule
39493937
[`--no-experimental-strip-types`]: #--no-experimental-strip-types

doc/api/esm.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -701,34 +701,23 @@ imported from the same path.
701701
702702
## Wasm modules
703703
704-
> Stability: 1 - Experimental
704+
<!-- YAML
705+
changes:
706+
- version: REPLACEME
707+
pr-url: https://github.com/nodejs/node/pull/57038
708+
description: Wasm modules no longer require the `--experimental-wasm-modules` flag.
709+
-->
705710
706711
Importing both WebAssembly module instances and WebAssembly source phase
707-
imports are supported under the `--experimental-wasm-modules` flag.
712+
imports is supported.
708713
709714
Both of these integrations are in line with the
710715
[ES Module Integration Proposal for WebAssembly][].
711716
712-
Instance imports allow any `.wasm` files to be imported as normal modules,
713-
supporting their module imports in turn.
714-
715-
For example, an `index.js` containing:
716-
717-
```js
718-
import * as M from './library.wasm';
719-
console.log(M);
720-
```
721-
722-
executed under:
723-
724-
```bash
725-
node --experimental-wasm-modules index.mjs
726-
```
727-
728-
would provide the exports interface for the instantiation of `library.wasm`.
729-
730717
### Wasm Source Phase Imports
731718
719+
> Stability: 1.2 - Release candidate
720+
732721
<!-- YAML
733722
added: v24.0.0
734723
-->
@@ -762,6 +751,8 @@ const instance = await WebAssembly.instantiate(dynamicLibrary, importObject);
762751
763752
### JavaScript String Builtins
764753
754+
> Stability: 1.2 - Release candidate
755+
765756
<!-- YAML
766757
added: REPLACEME
767758
-->
@@ -811,14 +802,36 @@ const { exports: { getLength } } = await WebAssembly.instantiate(mod, {});
811802
getLength('foo'); // Also returns 3.
812803
```
813804
805+
### Wasm Instance Phase Imports
806+
807+
> Stability: 1.1 - Active development
808+
809+
Instance imports allow any `.wasm` files to be imported as normal modules,
810+
supporting their module imports in turn.
811+
812+
For example, an `index.js` containing:
813+
814+
```js
815+
import * as M from './library.wasm';
816+
console.log(M);
817+
```
818+
819+
executed under:
820+
821+
```bash
822+
node index.mjs
823+
```
824+
825+
would provide the exports interface for the instantiation of `library.wasm`.
826+
814827
### Reserved Wasm Namespaces
815828
816829
<!-- YAML
817830
added: REPLACEME
818831
-->
819832
820-
When importing WebAssembly modules through the ESM Integration, they cannot use
821-
import module names or import/export names that start with reserved prefixes:
833+
When importing WebAssembly module instances, they cannot use import module
834+
names or import/export names that start with reserved prefixes:
822835
823836
* `wasm-js:` - reserved in all module import names, module names and export
824837
names.
@@ -1185,7 +1198,7 @@ _isImports_, _conditions_)
11851198
> 1. Return _"commonjs"_.
11861199
> 4. If _url_ ends in _".json"_, then
11871200
> 1. Return _"json"_.
1188-
> 5. If `--experimental-wasm-modules` is enabled and _url_ ends in
1201+
> 5. If _url_ ends in
11891202
> _".wasm"_, then
11901203
> 1. Return _"wasm"_.
11911204
> 6. If `--experimental-addon-modules` is enabled and _url_ ends in
@@ -1203,9 +1216,8 @@ _isImports_, _conditions_)
12031216
> 1. Return _"module"_.
12041217
> 3. Return _"commonjs"_.
12051218
> 12. If _url_ does not have any extension, then
1206-
> 1. If _packageType_ is _"module"_ and `--experimental-wasm-modules` is
1207-
> enabled and the file at _url_ contains the header for a WebAssembly
1208-
> module, then
1219+
> 1. If _packageType_ is _"module"_ and the file at _url_ contains the
1220+
> "application/wasm" content type header for a WebAssembly module, then
12091221
> 1. Return _"wasm"_.
12101222
> 2. If _packageType_ is not **null**, then
12111223
> 1. Return _packageType_.

doc/node-config-schema.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@
177177
"experimental-vm-modules": {
178178
"type": "boolean"
179179
},
180-
"experimental-wasm-modules": {
181-
"type": "boolean"
182-
},
183180
"experimental-websocket": {
184181
"type": "boolean"
185182
},

doc/node.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ Enable experimental ES module support in VM module.
220220
Enable experimental WebAssembly System Interface support. This
221221
flag is no longer required as WASI is enabled by default.
222222
.
223-
.It Fl -experimental-wasm-modules
224-
Enable experimental WebAssembly module support.
225-
.
226223
.It Fl -experimental-quic
227224
Enable the experimental QUIC support.
228225
.

lib/internal/modules/esm/formats.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ 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');
1312
const experimentalAddonModules = getOptionValue('--experimental-addon-modules');
1413

1514
const extensionFormatMap = {
@@ -18,12 +17,9 @@ const extensionFormatMap = {
1817
'.js': 'module',
1918
'.json': 'json',
2019
'.mjs': 'module',
20+
'.wasm': 'wasm',
2121
};
2222

23-
if (experimentalWasmModules) {
24-
extensionFormatMap['.wasm'] = 'wasm';
25-
}
26-
2723
if (experimentalAddonModules) {
2824
extensionFormatMap['.node'] = 'addon';
2925
}
@@ -46,7 +42,7 @@ function mimeToFormat(mime) {
4642
) !== null
4743
) { return 'module'; }
4844
if (mime === 'application/json') { return 'json'; }
49-
if (experimentalWasmModules && mime === 'application/wasm') { return 'wasm'; }
45+
if (mime === 'application/wasm') { return 'wasm'; }
5046
return null;
5147
}
5248

@@ -58,7 +54,6 @@ function mimeToFormat(mime) {
5854
* @returns {'wasm'|'module'}
5955
*/
6056
function getFormatOfExtensionlessFile(url) {
61-
if (!experimentalWasmModules) { return 'module'; }
6257
const path = getValidatedPath(url);
6358
switch (fsBindings.getFormatOfExtensionlessFile(path)) {
6459
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
@@ -495,8 +495,6 @@ translators.set('json', function jsonStrategy(url, source) {
495495
*/
496496
const wasmInstances = new SafeWeakMap();
497497
translators.set('wasm', async function(url, source) {
498-
emitExperimentalWarning('Importing WebAssembly modules');
499-
500498
assertBufferSource(source, false, 'load');
501499

502500
debug(`Translating WASMModule ${url}`);
@@ -546,6 +544,7 @@ translators.set('wasm', async function(url, source) {
546544
const createDynamicModule = require('internal/modules/esm/create_dynamic_module');
547545

548546
const { module } = createDynamicModule([...importsList], [...exportsList], url, (reflect) => {
547+
emitExperimentalWarning('Importing WebAssembly module instances');
549548
for (const impt of importsList) {
550549
const importNs = reflect.imports[impt];
551550
const wasmInstance = wasmInstances.get(importNs);

src/node.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,7 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
773773
env_opts->abort_on_uncaught_exception = true;
774774
}
775775

776-
if (env_opts->experimental_wasm_modules) {
777-
v8_args.emplace_back("--js-source-phase-imports");
778-
}
776+
v8_args.emplace_back("--js-source-phase-imports");
779777

780778
#ifdef __POSIX__
781779
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the

src/node_options.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
536536
kAllowedInEnvvar);
537537
AddAlias("--loader", "--experimental-loader");
538538
AddOption("--experimental-modules", "", NoOp{}, kAllowedInEnvvar);
539-
AddOption("--experimental-wasm-modules",
540-
"experimental ES Module support for webassembly modules",
541-
&EnvironmentOptions::experimental_wasm_modules,
542-
kAllowedInEnvvar);
539+
AddOption("--experimental-wasm-modules", "", NoOp{}, kAllowedInEnvvar);
543540
AddOption("--experimental-import-meta-resolve",
544541
"experimental ES Module import.meta.resolve() parentURL support",
545542
&EnvironmentOptions::experimental_import_meta_resolve,

src/node_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class EnvironmentOptions : public Options {
133133
std::string localstorage_file;
134134
bool experimental_global_navigator = true;
135135
bool experimental_global_web_crypto = true;
136-
bool experimental_wasm_modules = false;
137136
bool experimental_import_meta_resolve = false;
138137
std::string input_type; // Value of --input-type
139138
bool entry_is_url = false;

0 commit comments

Comments
 (0)