function buildErrorHTML
buildErrorHTML(buildError: { type: string; formatted: string; }): string

Generates a self-contained HTML error page for a build failure, styled to match the QUnit HTML reporter (same element IDs, colors, and layout as qunit.css / qunitjs.com). Includes a WebSocket reconnect script that reloads the page on 'refresh' (next successful build). Uses location.port so no port needs to be baked in at generation time; the script is a no-op when the page is opened as a static file (location.port is empty).

import * as WebServer from './web-server.ts';

const html = WebServer.buildErrorHTML({ type: 'SyntaxError', formatted: 'x.ts:1:0: Unexpected "<"' });
html.includes('Build Error: SyntaxError'); // true — the formatted esbuild output, HTML-escaped

Parameters

buildError: { type: string; formatted: string; }

Return Type

string

Usage

import { buildErrorHTML } from "lib/setup/web-server.ts";