// Test server for e2e runs: static files from the repo root plus /ssr, // which server-renders the counter app and serves a hydration page — the // same app module the import map hands to the browser. import { createServer } from 'node:http' import { readFile } from 'node:fs/promises' import { join, normalize, extname, dirname } from 'node:path' import { fileURLToPath } from 'node:url' import createApp from '../../examples/counter/app.js' const root = normalize(join(dirname(fileURLToPath(import.meta.url)), '..', '..')) const MIME = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.mjs': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json; charset=utf-8' } const IMPORT_MAP = JSON.stringify({ imports: { '@choojs/core': '/packages/core/index.js', '@choojs/core/timing': '/packages/core/lib/timing.js', '@choojs/html': '/packages/html/browser.js', '@choojs/html/raw': '/packages/html/raw.js', '@choojs/html/morph': '/packages/html/morph.js', '@choojs/html/hydrate': '/packages/html/hydrate.js' } }) function ssrPage () { const body = createApp().toString('/') // When a view owns
, scripts belong in : type="module" is // deferred by definition, and body must contain only what the view // renders or hydration would (rightly) flag the extra nodes. return `