Add build-all.sh, bytecode test mode — 5 failures with SX_TEST_BYTECODE=1
The hydration bug root cause: .sxbc bytecoded modules break effect closures. Source-loaded modules work (15/15), bytecoded fail (10/15). Run: SX_TEST_BYTECODE=1 node hosts/ocaml/browser/test_wasm_native.js Failing: scoped static class, signal attr initial, reactive-spread, CSSX in island scope, reactive attr update. Also adds build-all.sh (full WASM pipeline) and sx_build target="wasm" MCP tool integration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
hosts/ocaml/browser/build-all.sh
Executable file
37
hosts/ocaml/browser/build-all.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Full build: OCaml WASM kernel + bundle + bytecode compile + deploy to shared/static/wasm/
|
||||
#
|
||||
# Usage: bash hosts/ocaml/browser/build-all.sh
|
||||
# Or via MCP: sx_build target="wasm"
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "=== 1. Build WASM kernel ==="
|
||||
# Remove assets dir that conflicts with dune's output target
|
||||
rm -rf sx_browser.bc.wasm.assets
|
||||
eval $(opam env 2>/dev/null)
|
||||
cd ..
|
||||
dune build browser/sx_browser.bc.wasm.js browser/sx_browser.bc.js bin/sx_server.exe 2>&1
|
||||
cd browser
|
||||
|
||||
echo "=== 2. Bundle ==="
|
||||
bash bundle.sh
|
||||
|
||||
echo "=== 3. Compile .sxbc bytecode ==="
|
||||
node compile-modules.js dist
|
||||
|
||||
echo "=== 4. Deploy to shared/static/wasm/ ==="
|
||||
DEST=../../../shared/static/wasm
|
||||
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/*.sx "$DEST/sx/"
|
||||
cp dist/sx/*.sxbc "$DEST/sx/" 2>/dev/null || true
|
||||
# Keep assets dir for Node.js WASM tests
|
||||
cp -r dist/sx_browser.bc.wasm.assets ./ 2>/dev/null || true
|
||||
|
||||
echo "=== 5. Run WASM tests ==="
|
||||
node test_wasm_native.js
|
||||
|
||||
echo "=== Done ==="
|
||||
@@ -65,8 +65,8 @@ cp "$ROOT/web/engine.sx" "$DIST/sx/"
|
||||
cp "$ROOT/web/orchestration.sx" "$DIST/sx/"
|
||||
cp "$ROOT/web/boot.sx" "$DIST/sx/"
|
||||
|
||||
# 9. CSSX (stylesheet language)
|
||||
cp "$ROOT/sx/sx/cssx.sx" "$DIST/sx/"
|
||||
# 9. CSSX (stylesheet language — runtime with tw, ~cssx/tw, cssx-process-token etc.)
|
||||
cp "$ROOT/shared/sx/templates/cssx.sx" "$DIST/sx/"
|
||||
|
||||
# Summary
|
||||
WASM_SIZE=$(du -sh "$DIST/sx_browser.bc.wasm.assets" | cut -f1)
|
||||
|
||||
@@ -42,6 +42,7 @@ const FILES = [
|
||||
'harness-web.sx', 'engine.sx', 'orchestration.sx', 'boot.sx',
|
||||
];
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Build the full input script — all commands in one batch
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -196,6 +196,12 @@ async function main() {
|
||||
K.eval('(do (define test-set-attr (fn (el name val) (effect (fn () (dom-set-attr el name val))))) (let ((el (dom-create-element "div" nil))) (test-set-attr el "class" "from-define") (dom-get-attr el "class")))'),
|
||||
'from-define');
|
||||
|
||||
// Verify the effect body ACTUALLY EXECUTES (not just returning a value).
|
||||
// In browser WASM, the effect body silently doesn't run.
|
||||
assert('define+effect body executes',
|
||||
K.eval('(do (define test-fx-log (fn (el log) (effect (fn () (append! log "ran") (dom-set-attr el "class" "fx"))))) (let ((el (dom-create-element "div" nil)) (log (list))) (test-fx-log el log) (str (len log) ":" (first log))))'),
|
||||
'1:ran');
|
||||
|
||||
// Same thing with let works (proves it's define-specific)
|
||||
assert('let+effect+host-obj',
|
||||
K.eval('(let ((test-set-attr (fn (el name val) (effect (fn () (dom-set-attr el name val)))))) (let ((el (dom-create-element "div" nil))) (test-set-attr el "class" "from-let") (dom-get-attr el "class")))'),
|
||||
|
||||
Reference in New Issue
Block a user