From 6550e9b2e4c46f07380f2c6ae05363ddf282d5c5 Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 31 Mar 2026 17:05:31 +0000 Subject: [PATCH] Fix build-all.sh: deploy platform JS to shared/static/wasm/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build-all.sh was missing the sx-platform.js → sx-platform-2.js copy, so the served file was stale (still requesting .sxbc.json instead of .sxbc). Co-Authored-By: Claude Opus 4.6 (1M context) --- hosts/ocaml/browser/build-all.sh | 1 + shared/static/wasm/sx-platform-2.js | 21 +++++++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/hosts/ocaml/browser/build-all.sh b/hosts/ocaml/browser/build-all.sh index 01fd8d35..ed3d43c7 100755 --- a/hosts/ocaml/browser/build-all.sh +++ b/hosts/ocaml/browser/build-all.sh @@ -26,6 +26,7 @@ cp dist/sx_browser.bc.wasm.js "$DEST/" cp dist/sx_browser.bc.js "$DEST/" rm -rf "$DEST/sx_browser.bc.wasm.assets" cp -r dist/sx_browser.bc.wasm.assets "$DEST/" +cp dist/sx-platform.js "$DEST/sx-platform-2.js" cp dist/sx/*.sx "$DEST/sx/" cp dist/sx/*.sxbc "$DEST/sx/" 2>/dev/null || true # Keep assets dir for Node.js WASM tests diff --git a/shared/static/wasm/sx-platform-2.js b/shared/static/wasm/sx-platform-2.js index acee5482..320bf33c 100644 --- a/shared/static/wasm/sx-platform-2.js +++ b/shared/static/wasm/sx-platform-2.js @@ -234,35 +234,28 @@ } /** - * Try loading a pre-compiled .sxbc.json bytecode module. + * Try loading a pre-compiled .sxbc bytecode module (SX text format). * Returns true on success, null on failure (caller falls back to .sx source). */ function loadBytecodeFile(path) { - var bcPath = path.replace(/\.sx$/, '.sxbc.json'); - var url = _baseUrl + bcPath + _sxbcCacheBust; + var sxbcPath = path.replace(/\.sx$/, '.sxbc'); + var url = _baseUrl + sxbcPath + _sxbcCacheBust; try { var xhr = new XMLHttpRequest(); xhr.open("GET", url, false); xhr.send(); if (xhr.status !== 200) return null; - var json = JSON.parse(xhr.responseText); - if (!json.module || json.magic !== 'SXBC') return null; - - var module = { - _type: 'dict', - bytecode: { _type: 'list', items: json.module.bytecode }, - constants: { _type: 'list', items: json.module.constants.map(deserializeConstant) }, - }; - - var result = K.loadModule(module); + window.__sxbcText = xhr.responseText; + var result = K.eval('(load-sxbc (first (parse (host-global "__sxbcText"))))'); + delete window.__sxbcText; if (typeof result === 'string' && result.indexOf('Error') === 0) { console.warn("[sx-platform] bytecode FAIL " + path + ":", result); return null; } - console.log("[sx-platform] ok " + path + " (bytecode)"); return true; } catch(e) { + delete window.__sxbcText; return null; } }