Skip to content

Commit 32ba9ef

Browse files
Fix: Update pages workflow and fix async wasm binary.
1 parent 7659640 commit 32ba9ef

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

.github/workflows/pages.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: pages
33
on:
44
push:
55
branches: [main]
6-
release:
7-
types: [published]
86
workflow_dispatch:
97

108
permissions:
@@ -25,6 +23,36 @@ jobs:
2523
steps:
2624
- uses: actions/checkout@v5
2725

26+
- name: Cache Rust
27+
uses: Swatinem/rust-cache@v2
28+
with:
29+
workspaces: compiler
30+
31+
- uses: dtolnay/rust-toolchain@stable
32+
33+
- name: Install wasm target
34+
run: rustup target add wasm32-unknown-unknown
35+
working-directory: compiler
36+
37+
- name: Install wasm-opt
38+
run: sudo apt-get update && sudo apt-get install -y binaryen
39+
40+
- name: Build wasm
41+
run: cargo build --target wasm32-unknown-unknown --features wasm --lib --release
42+
working-directory: compiler
43+
44+
- name: Optimize wasm
45+
run: |
46+
wasm-opt -Oz --converge --strip-debug \
47+
--enable-bulk-memory \
48+
--enable-nontrapping-float-to-int \
49+
--enable-sign-ext \
50+
-o compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm \
51+
compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm
52+
53+
- name: Stage demo
54+
run: cp compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm demo/
55+
2856
- name: Setup Pages
2957
uses: actions/configure-pages@v5
3058
with:

demo/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
</div>
5757

5858
<script>
59-
const WASM_URL = 'https://github.com/dylan-sutton-chavez/edge-python/releases/latest/download/compiler_lib.wasm';
6059
const SZ = 1 << 20;
6160

6261
const ed = document.getElementById('ed');
@@ -69,11 +68,10 @@
6968

7069
async function loadWasm() {
7170
try {
72-
status.textContent = 'fetching latest wasm…';
73-
const res = await fetch(WASM_URL, { cache: 'no-cache' });
71+
status.textContent = 'loading wasm…';
72+
const res = await fetch('./compiler_lib.wasm');
7473
if (!res.ok) throw new Error(`HTTP ${res.status}`);
75-
const bytes = await res.arrayBuffer();
76-
const { instance } = await WebAssembly.instantiate(bytes, {});
74+
const { instance } = await WebAssembly.instantiateStreaming(res, {});
7775
wasm = instance.exports;
7876
btn.disabled = false;
7977
status.textContent = 'ready';

0 commit comments

Comments
 (0)