-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment: compiling wasm for use in docs
- Loading branch information
Showing
8 changed files
with
651 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# WASM assets | ||
|
||
A quick guide to building WASM binaries using nodeadm functions. | ||
|
||
you can see the [go.dev webassembly](https://go.dev/wiki/WebAssembly) wiki for | ||
greater detail, but the high level steps involved are: | ||
|
||
cd into the nodeadm directory | ||
``` | ||
git clone [email protected]:awslabs/amazon-eks-ami.git | ||
cd amazon-eks-ami/nodeadm | ||
``` | ||
|
||
Copy the javascript glue code from | ||
``` | ||
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./wasm/assets/ | ||
``` | ||
|
||
Compile the wasm binary | ||
``` | ||
GOOS=js GOARCH=wasm go build -o ./wasm/assets/main.wasm wasm/check/main.go | ||
``` | ||
|
||
Serve the assets | ||
``` | ||
cd ./wasm/assets | ||
python -m http.server # or http server variant | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<html> | ||
<head> | ||
<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-monaco-editor@1/index.js"></script> | ||
<meta charset="utf-8"/> | ||
<script src="wasm_exec.js"></script> | ||
<script> | ||
const go = new Go(); | ||
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => { | ||
go.run(result.instance); | ||
}); | ||
function check() { | ||
document.getElementById("response").value = nodeadmCheck(editor.value) | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div style="display: grid; margin: auto; width: 90vw"> | ||
<wc-monaco-editor style="height:80vh" language="yaml"></wc-monaco-editor> | ||
<button onclick="check()">check</button> | ||
<textarea style="height:15vh" id="response"></textarea> | ||
</div> | ||
</body> | ||
</html> |
Binary file not shown.
Oops, something went wrong.