Skip to content

Commit 707b973

Browse files
aduh95ruyadorno
authored andcommitted
doc: use ESM syntax for WASI example
PR-URL: #36848 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
1 parent 8dc8adc commit 707b973

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module.exports = {
5757
'doc/api/module.md',
5858
'doc/api/modules.md',
5959
'doc/api/packages.md',
60+
'doc/api/wasi.md',
6061
'test/es-module/test-esm-type-flag.js',
6162
'test/es-module/test-esm-type-flag-alias.js',
6263
'*.mjs',

doc/api/wasi.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ specification. WASI gives sandboxed WebAssembly applications access to the
1111
underlying operating system via a collection of POSIX-like functions.
1212

1313
```js
14-
'use strict';
15-
const fs = require('fs');
16-
const { WASI } = require('wasi');
14+
import fs from 'fs';
15+
import { WASI } from 'wasi';
16+
1717
const wasi = new WASI({
1818
args: process.argv,
1919
env: process.env,
@@ -23,12 +23,10 @@ const wasi = new WASI({
2323
});
2424
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
2525

26-
(async () => {
27-
const wasm = await WebAssembly.compile(fs.readFileSync('./demo.wasm'));
28-
const instance = await WebAssembly.instantiate(wasm, importObject);
26+
const wasm = await WebAssembly.compile(fs.readFileSync('./demo.wasm'));
27+
const instance = await WebAssembly.instantiate(wasm, importObject);
2928

30-
wasi.start(instance);
31-
})();
29+
wasi.start(instance);
3230
```
3331

3432
To run the above example, create a new WebAssembly text format file named

0 commit comments

Comments
 (0)