Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: unflag WASM modules #42309

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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