2017-10-30 20:56:57 +08:00
|
|
|
This very simple example shows usage of WebAssembly.
|
|
|
|
|
|
2019-05-24 19:54:49 +08:00
|
|
|
WebAssembly modules can be imported like other async modules with `import await` or `import()`.
|
|
|
|
|
They are downloaded and instantiated in a streaming way when importing.
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
# example.js
|
|
|
|
|
|
2019-04-05 05:04:47 +08:00
|
|
|
```javascript
|
|
|
|
|
_{{example.js}}_
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# math.js
|
|
|
|
|
|
2019-04-05 05:04:47 +08:00
|
|
|
```javascript
|
|
|
|
|
_{{math.js}}_
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|
|
|
|
|
|
2018-01-05 04:39:29 +08:00
|
|
|
# dist/output.js
|
2017-10-30 20:56:57 +08:00
|
|
|
|
2019-04-05 05:04:47 +08:00
|
|
|
```javascript
|
|
|
|
|
_{{dist/output.js}}_
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
2017-12-14 17:09:09 +08:00
|
|
|
## Unoptimized
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
```
|
2019-04-05 05:04:47 +08:00
|
|
|
_{{stdout}}_
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|
|
|
|
|
|
2017-12-14 17:09:09 +08:00
|
|
|
## Production mode
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
```
|
2019-04-05 05:04:47 +08:00
|
|
|
_{{production:stdout}}_
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|