Skip to content

Commit

Permalink
module: unflag WASM modules
Browse files Browse the repository at this point in the history
WebAssembly has been unflagged in V8 for years, and is presented on
equal footing with Javascript in [how V8 describes itself][v8.dev] for
years now ("Google’s open source high-performance JavaScript and
WebAssembly engine").

I can't find any specified reasons to keep it flagged and called
experimental in Node (though maybe this PR will draw those out?).

Following #41736 as a model, this PR
leaves the flag present as a no-op and removes it from documentation,
but keeps the "Stability: 1 - Experimental" in esm.md and the runtime
warning message.  I want to remove those too (or else draw out some
specified reasons not to :) ) but there appears to be a convention of
decoupling unflagging from stabilizing:
#41736 (comment), so,
like JSON modules, maybe drop the warning in 18.0.0?

[v8.dev]: https://v8.dev/
  • Loading branch information
gthb committed Mar 12, 2022
1 parent 457567f commit 34310f2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 40 deletions.
14 changes: 2 additions & 12 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ Otherwise, the file is loaded using the CommonJS module loader. See
### ECMAScript modules loader entry point caveat

When loading [ECMAScript module loader][] loads the program entry point, the `node`
command will only accept as input only files with `.js`, `.mjs`, or `.cjs`
extensions; and with `.wasm` extensions when
[`--experimental-wasm-modules`][] is enabled.
command will only accept as input only files with `.js`, `.mjs`, `.cjs`, or
`.wasm` extensions.

## Options

Expand Down Expand Up @@ -381,14 +380,6 @@ changes:

Enable experimental WebAssembly System Interface (WASI) support.

### `--experimental-wasm-modules`

<!-- YAML
added: v12.3.0
-->

Enable experimental WebAssembly module support.

### `--force-context-aware`

<!-- YAML
Expand Down Expand Up @@ -1995,7 +1986,6 @@ $ node --max-old-space-size=1536 index.js
[`"type"`]: packages.md#type
[`--cpu-prof-dir`]: #--cpu-prof-dir
[`--diagnostic-dir`]: #--diagnostic-dirdirectory
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
[`--heap-prof-dir`]: #--heap-prof-dir
[`--openssl-config`]: #--openssl-configfile
[`--redirect-warnings`]: #--redirect-warningsfile
Expand Down
11 changes: 2 additions & 9 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,8 @@ imported from the same path.
> Stability: 1 - Experimental
Importing WebAssembly modules is supported under the
`--experimental-wasm-modules` flag, allowing any `.wasm` files to be
imported as normal modules while also supporting their module imports.
WebAssembly modules can be imported as normal modules while also supporting
their module imports.
This integration is in line with the
[ES Module Integration Proposal for WebAssembly][].
Expand All @@ -551,12 +550,6 @@ import * as M from './module.wasm';
console.log(M);
```
executed under:
```bash
node --experimental-wasm-modules index.mjs
```
would provide the exports interface for the instantiation of `module.wasm`.
<i id="esm_experimental_top_level_await"></i>
Expand Down
3 changes: 0 additions & 3 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ Enable experimental ES module support in VM module.
.It Fl -experimental-wasi-unstable-preview1
Enable experimental WebAssembly System Interface support.
.
.It Fl -experimental-wasm-modules
Enable experimental WebAssembly module support.
.
.It Fl -force-context-aware
Disable loading native addons that are not context-aware.
.
Expand Down
12 changes: 3 additions & 9 deletions lib/internal/modules/esm/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
const {
RegExpPrototypeTest,
} = primordials;
const { getOptionValue } = require('internal/options');


const experimentalWasmModules = getOptionValue('--experimental-wasm-modules');

const extensionFormatMap = {
'__proto__': null,
'.cjs': 'commonjs',
'.js': 'module',
'.json': 'json',
'.mjs': 'module',
'.wasm': 'wasm',
};

const legacyExtensionFormatMap = {
Expand All @@ -23,12 +20,9 @@ const legacyExtensionFormatMap = {
'.json': 'commonjs',
'.mjs': 'module',
'.node': 'commonjs',
'.wasm': 'wasm',
};

if (experimentalWasmModules) {
extensionFormatMap['.wasm'] = legacyExtensionFormatMap['.wasm'] = 'wasm';
}

function mimeToFormat(mime) {
if (
RegExpPrototypeTest(
Expand All @@ -37,7 +31,7 @@ function mimeToFormat(mime) {
)
) return 'module';
if (mime === 'application/json') return 'json';
if (experimentalWasmModules && mime === 'application/wasm') return 'wasm';
if (mime === 'application/wasm') return 'wasm';
return null;
}

Expand Down
5 changes: 1 addition & 4 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"experimental https: support for the ES Module loader",
&EnvironmentOptions::experimental_https_modules,
kAllowedInEnvironment);
AddOption("--experimental-wasm-modules",
"experimental ES Module support for webassembly modules",
&EnvironmentOptions::experimental_wasm_modules,
kAllowedInEnvironment);
AddOption("--experimental-wasm-modules", "", NoOp{}, kAllowedInEnvironment);
AddOption("--experimental-import-meta-resolve",
"experimental ES Module import.meta.resolve() support",
&EnvironmentOptions::experimental_import_meta_resolve,
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class EnvironmentOptions : public Options {
bool experimental_global_web_crypto = false;
bool experimental_https_modules = false;
std::string experimental_specifier_resolution;
bool experimental_wasm_modules = false;
bool experimental_import_meta_resolve = false;
std::string module_type;
std::string experimental_policy;
Expand Down
2 changes: 0 additions & 2 deletions test/es-module/test-esm-wasm.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-wasm-modules
import '../common/index.mjs';
import { path } from '../common/fixtures.mjs';
import { add, addImported } from '../fixtures/es-modules/simple.wasm';
Expand All @@ -18,7 +17,6 @@ strictEqual(addImported(1), 43);

// Test warning message
const child = spawn(process.execPath, [
'--experimental-wasm-modules',
path('/es-modules/wasm-modules.mjs'),
]);

Expand Down

0 comments on commit 34310f2

Please sign in to comment.