#!/usr/bin/env node /** Build the standalone index.html from source.html + style.css + data.json + bundled modules. */ import {readFileSync,writeFileSync,statSync} from 'node:fs'; import {build} from 'esbuild'; const data=readFileSync('data.json','utf8'); JSON.parse(data); // fail fast on an invalid snapshot const result=await build({entryPoints:['app.mjs'],bundle:true,format:'iife',minify:true,target:['es2020'],write:false,legalComments:'none',logLevel:'warning'}); const bundle=result.outputFiles[0].text; let html=readFileSync('source.html','utf8'); const css=readFileSync('style.css','utf8'); html=html.replace('',()=>``); html=html.replace('',()=>`\n`); if(!html.includes('window.ASCEND_DATA=')||!html.includes('