Fix: load HS modules as bytecode, not source — restores IO suspension chain

Reverts the source-loading workaround. Bytecode modules go through the
VM which handles IO suspension (perform/wait/fetch) correctly. The
endModuleLoad sync copies VM globals to CEK env, so eval-expr-cek in
hs-handler can find hs-on/hs-toggle-class!/etc.

All three HS examples fully working on live site:
  Toggle Color — toggle classes on click
  Bounce — add class, wait 1s (IO suspend+resume), remove class
  Count Clicks — increment counter, update innerHTML

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 21:28:58 +00:00
parent 0365ecb2b9
commit cf10e9a2d6
2 changed files with 6 additions and 26 deletions

View File

@@ -506,19 +506,9 @@
// will see it as already loaded and skip rather than infinite-looping.
_loadedLibs[name] = true;
// Load this module.
// Non-library modules (no space in name, e.g. "hs-runtime") use source
// loading so their defines go into the CEK global env — needed when
// eval-expr-cek evaluates compiled hyperscript at runtime.
var isLibrary = name.indexOf(' ') >= 0 || name === '_entry';
var ok;
if (isLibrary) {
ok = loadBytecodeFile("sx/" + info.file);
if (!ok) {
var sxFile = info.file.replace(/\.sxbc$/, '.sx');
ok = loadSxFile("sx/" + sxFile);
}
} else {
// Load this module (bytecode first, fallback to source)
var ok = loadBytecodeFile("sx/" + info.file);
if (!ok) {
var sxFile = info.file.replace(/\.sxbc$/, '.sx');
ok = loadSxFile("sx/" + sxFile);
}

View File

@@ -506,19 +506,9 @@
// will see it as already loaded and skip rather than infinite-looping.
_loadedLibs[name] = true;
// Load this module.
// Non-library modules (no space in name, e.g. "hs-runtime") use source
// loading so their defines go into the CEK global env — needed when
// eval-expr-cek evaluates compiled hyperscript at runtime.
var isLibrary = name.indexOf(' ') >= 0 || name === '_entry';
var ok;
if (isLibrary) {
ok = loadBytecodeFile("sx/" + info.file);
if (!ok) {
var sxFile = info.file.replace(/\.sxbc$/, '.sx');
ok = loadSxFile("sx/" + sxFile);
}
} else {
// Load this module (bytecode first, fallback to source)
var ok = loadBytecodeFile("sx/" + info.file);
if (!ok) {
var sxFile = info.file.replace(/\.sxbc$/, '.sx');
ok = loadSxFile("sx/" + sxFile);
}