My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix notebook worker loading: patch findlib_index.json with worker_url

When --no-worker is used with jtw, the compiler.worker_url field
is omitted from findlib_index.json. x-ocaml.js reads this field
to locate the worker. Without it, the worker never starts, and
the "Unexpected token '<'" error occurs when x-ocaml falls back
to loading a default path that returns HTML.

Add patch_findlib_index helper that injects the compiler field
after copying the dune-built worker.js.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+14
+14
build-site.sh
··· 19 19 SERVE=false 20 20 FRESH=false 21 21 22 + # Add compiler.worker_url to a findlib_index.json (--no-worker skips this) 23 + patch_findlib_index() { 24 + python3 -c ' 25 + import json, sys 26 + f = sys.argv[1] 27 + d = json.load(open(f)) 28 + d["compiler"] = {"worker_url": "worker.js"} 29 + json.dump(d, open(f, "w")) 30 + ' "$1" 31 + } 32 + 22 33 for arg in "$@"; do 23 34 case "$arg" in 24 35 --serve) SERVE=true ;; ··· 76 87 tessera-zarr-jsoo \ 77 88 onnxrt -o "$SITE/_opam" 78 89 cp "$WORKER_JS" "$SITE/_opam/worker.js" 90 + patch_findlib_index "$SITE/_opam/findlib_index.json" 79 91 echo " universe built → $SITE/_opam/" 80 92 fi 81 93 ··· 104 116 echo " building default universe (cmdliner, 5.2.0+ox switch)..." 105 117 dune exec -- jtw opam --no-worker --switch=5.2.0+ox -o "$UNIVERSES/default" cmdliner 106 118 cp "$WORKER_JS" "$UNIVERSES/default/worker.js" 119 + patch_findlib_index "$UNIVERSES/default/findlib_index.json" 107 120 108 121 echo " building oxcaml universe (5.2.0+ox switch)..." 109 122 dune exec -- jtw opam --no-worker --switch=5.2.0+ox -o "$UNIVERSES/oxcaml" 110 123 cp "$WORKER_JS" "$UNIVERSES/oxcaml/worker.js" 124 + patch_findlib_index "$UNIVERSES/oxcaml/findlib_index.json" 111 125 112 126 for d in universe universe-oxcaml; do 113 127 rm -rf "$DEMO_DIR/$d"