#!/usr/bin/env node
/**
* Post-build step for the static export.
*
* The API serves the console with `Content-Security-Policy: script-src 'self'` (no 'unsafe-inline').
* Next.js App Router emits the React Server Components payload as inline
* `` tags, which such a CSP blocks — hydration would never run.
*
* This script rewrites every `out/**\/*.html`: the inline scripts (all of them are `__next_f` pushes) are
* concatenated, in document order, into one external file `out/_next/static/flight/.js`, and a single
* blocking `` : ""));
writeFileSync(file, rewritten);
files++;
scripts += chunks.length;
bytes += js.length;
}
console.log(`externalize-inline-scripts: ${files} html files, ${scripts} inline scripts moved to _next/static/flight (${(bytes / 1024).toFixed(1)} kB)`);