Files
hanzo.sh-native/scripts/gen-gui-css.mjs
zeekayandHanzo Dev 956531adc7 hanzo.sh to the estate standard: gui 8.0.0 graph, ui 8.0.38, TS 7.0.2, static gui.css
- @hanzo/gui + whole @hanzogui/* graph 7.3.0 -> 8.0.0, @hanzo/ui -> 8.0.38,
  @hanzo/design -> 0.3.3; [email protected].5 declared directly
  ([email protected] imports it but no longer declares the peer).
- Icons from the package root, not /icons/* subpaths: 8.0.0's per-icon exports
  entries carry no types condition, so subpaths typecheck as any. Root export
  is typed and sideEffects:false tree-shakes — JS bundle 647 kB -> 531 kB.
- gui base sheet as a REAL cacheable stylesheet: scripts/gen-gui-css.mjs
  (first step of pnpm build) writes config.getCSS() to src/gui.css, main.tsx
  imports it, GuiProvider renders disableInjectCSS. ~43 kB gzip, fingerprinted.
- TypeScript 7.0.2 for tsc; .pnpmfile.cjs gives @typescript-eslint/* their own
  [email protected] (side-by-side per typescript-eslint#10940) so lint runs.
- next-theme shim STAYS: 8.0.38 lazily code-splits ThemeToggleNext, but Rollup
  still follows the dynamic import and the optional peer breaks the build
  (measured). SiteNav still authors $sm as phone, so the sm override stays too.
- Measured: typecheck 0, lint 0, build 0, polyglot bash -n OK + --help prints
  usage, page verified at 1280px and 390px.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-31 14:39:37 -07:00

39 lines
1.7 KiB
JavaScript

// Regenerate src/gui.css — the @hanzo/gui base sheet, as a real static asset.
//
// Without this, GuiProvider builds the whole sheet in JS and injects a <style>
// tag on every page load: work the browser repeats per visit for bytes that
// never change. Generated here instead, Vite fingerprints the file into
// dist/assets and the browser caches it once. GuiProvider renders with
// disableInjectCSS so this file is the ONE source of the base gui styles —
// the same arrangement hanzo.ai and hanzo.app use, minus their Next specifics.
//
// First in `pnpm build`, so the sheet cannot drift from gui.config.ts. The
// generated file is committed so `pnpm dev` and `pnpm typecheck` work without
// a build step.
import { writeFileSync, rmSync } from 'node:fs'
import { buildSync } from 'esbuild'
const bundle = new URL('../.guicfg.gen.mjs', import.meta.url)
// gui.config.ts is TypeScript and pulls in the @hanzogui graph, so it has to
// be bundled before Node can import it. react-native is aliased to
// react-native-web for the same reason vite.config.ts does it: the bare
// specifier resolves to the native implementation, which has no business
// running here.
buildSync({
entryPoints: [new URL('../src/gui.config.ts', import.meta.url).pathname],
bundle: true,
format: 'esm',
platform: 'node',
external: ['react', 'react-dom', 'react-native'],
alias: { 'react-native': 'react-native-web' },
outfile: bundle.pathname,
logLevel: 'error',
})
const { default: config } = await import(bundle)
const css = config.getCSS()
writeFileSync(new URL('../src/gui.css', import.meta.url), css)
rmSync(bundle)
console.log(`src/gui.css regenerated — ${css.length.toLocaleString()} bytes`)