Fix server import suspension, dist sync, JIT errors
- cek_run patched to handle import suspensions via _import_hook. define-library (import ...) now resolves cleanly on the server. IO suspension errors: 190 → 0. JIT failures: ~50 → 0. - _import_hook wired in sx_server.ml to load .sx files on demand. - compile-modules.js syncs source .sx files to dist/sx/ before compiling — eliminates stale bytecode from out-of-date copies. - WASM binary rebuilt with all fixes. - 2658/2658 tests pass (8 new — previously failing import tests). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,12 +16,53 @@ const { execSync, spawnSync } = require('child_process');
|
||||
|
||||
const distDir = process.argv[2] || path.join(__dirname, 'dist');
|
||||
const sxDir = path.join(distDir, 'sx');
|
||||
const projectRoot = path.resolve(__dirname, '..', '..', '..');
|
||||
|
||||
if (!fs.existsSync(sxDir)) {
|
||||
console.error('sx dir not found:', sxDir);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Sync source .sx files to dist/sx/ before compiling.
|
||||
// Source locations: spec/ for core, lib/ for compiler/vm, web/ and web/lib/ for web stack.
|
||||
const SOURCE_MAP = {
|
||||
// spec/
|
||||
'render.sx': 'spec/render.sx',
|
||||
'core-signals.sx': 'spec/signals.sx',
|
||||
// lib/
|
||||
'bytecode.sx': 'lib/bytecode.sx', 'compiler.sx': 'lib/compiler.sx',
|
||||
'vm.sx': 'lib/vm.sx', 'freeze.sx': 'lib/freeze.sx',
|
||||
'highlight.sx': 'lib/highlight.sx',
|
||||
// web/lib/
|
||||
'dom.sx': 'web/lib/dom.sx', 'browser.sx': 'web/lib/browser.sx',
|
||||
// web/
|
||||
'signals.sx': 'web/signals.sx', 'deps.sx': 'web/deps.sx',
|
||||
'router.sx': 'web/router.sx', 'page-helpers.sx': 'web/page-helpers.sx',
|
||||
'adapter-html.sx': 'web/adapter-html.sx', 'adapter-sx.sx': 'web/adapter-sx.sx',
|
||||
'adapter-dom.sx': 'web/adapter-dom.sx',
|
||||
'boot-helpers.sx': 'web/lib/boot-helpers.sx',
|
||||
'hypersx.sx': 'web/hypersx.sx',
|
||||
'harness.sx': 'spec/harness.sx', 'harness-reactive.sx': 'web/harness-reactive.sx',
|
||||
'harness-web.sx': 'web/harness-web.sx',
|
||||
'engine.sx': 'web/engine.sx', 'orchestration.sx': 'web/orchestration.sx',
|
||||
'boot.sx': 'web/boot.sx',
|
||||
'tw-layout.sx': 'web/tw-layout.sx', 'tw-type.sx': 'web/tw-type.sx', 'tw.sx': 'web/tw.sx',
|
||||
};
|
||||
let synced = 0;
|
||||
for (const [dist, src] of Object.entries(SOURCE_MAP)) {
|
||||
const srcPath = path.join(projectRoot, src);
|
||||
const dstPath = path.join(sxDir, dist);
|
||||
if (fs.existsSync(srcPath)) {
|
||||
const srcContent = fs.readFileSync(srcPath);
|
||||
const dstExists = fs.existsSync(dstPath);
|
||||
if (!dstExists || !fs.readFileSync(dstPath).equals(srcContent)) {
|
||||
fs.writeFileSync(dstPath, srcContent);
|
||||
synced++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (synced > 0) console.log('Synced ' + synced + ' source files to dist/sx/');
|
||||
|
||||
// Find the native OCaml binary
|
||||
const binPaths = [
|
||||
path.join(__dirname, '..', '_build', 'default', 'bin', 'sx_server.exe'),
|
||||
|
||||
Reference in New Issue
Block a user