#!/usr/bin/env node // SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC // SPDX-License-Identifier: Apache-2.0 // The assembled site's index.html, from the one in the repository: scripts/assemble.sh runs this on site/. // node scripts/assemble-page.mjs // It adds two things a checkout served as it is (pixi run dev) does without: // - , the commit in site/VERSION, which the footer shows (no request needed); // - a for every module the page's static import graph reaches. Without a bundler the // browser finds the modules one level of imports at a time, so a first visit waits for a chain of round trips // (six levels today); with the list it asks for them all at once. The links go after the import map, which a // browser must have read before it loads any module. // Nothing else in the page changes, so the hashes of its inline scripts (docs/Caddyfile's CSP) still hold. import { readFileSync, writeFileSync, existsSync } from 'node:fs'; import { resolve, dirname, relative, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const IMPORT = /(?:^|[;\n}])\s*(?:import|export)\s*(?:[\w*{}\s,$]*?\sfrom\s*)?['"]([^'"]+)['"]/g; /** * Every module the page's entry imports, directly or through others, as hrefs relative to the page ('./dist/…', * './core/dist/…'), shallowest first; the entry itself is not listed (its own