swarm-ui: trim build.mjs's top comment under the 30-line convention
mara flagged (PR #4297) that the comment-block lint doesn't catch this file at all -- check-comment-blocks.sh (and check-issue-refs.sh) scope to a fixed git ls-files extension list that omits .mjs. That's a real gap (dashboard/build.mjs already has a 49-line block, pre-existing), tracked separately -- but the fix here is to just respect the 30-line convention regardless of whether the lint enforces it on this extension. Cut the redundant per-file output-layout table (the code below already names every output path) and kept only the genuinely non-obvious decisions -- no content lost, verified against a plain awk run of the lint's own line-counting logic.
This commit is contained in:
parent
6b3840b6ac
commit
1cc4e4625e
1 changed files with 25 additions and 58 deletions
|
|
@ -1,66 +1,33 @@
|
||||||
// esbuild build for @hive/swarm-ui (project-bootstrap scope). Output
|
// esbuild build for @hive/swarm-ui (project-bootstrap scope). Bundles
|
||||||
// layout (`dist/`):
|
// main.tsx + its companion CSS, theme.css, and swarm-ui.css into
|
||||||
|
// `dist/static/`, content-hashed (`[name]-[hash]`) so a redeploy's new
|
||||||
|
// bundle gets a new URL, then rewrites those real URLs into index.html
|
||||||
|
// and sw.js. See each output file's own name in the code below for what
|
||||||
|
// it's for — not repeated here to avoid this comment drifting out of
|
||||||
|
// sync with the actual build steps.
|
||||||
//
|
//
|
||||||
// dist/index.html served at GET / — its asset <link>/
|
// `colors.css` is the ONE static asset deliberately left UNHASHED, at a
|
||||||
// <script> URLs are rewritten below to the
|
// fixed `dist/static/colors.css`: nix/host-modules/swarm-ui.nix's stylix
|
||||||
// real hashed filenames esbuild picked
|
// theming swaps that exact path via an `= /static/colors.css` nginx
|
||||||
// dist/static/main-<hash>.js served at /static/main-<hash>.js (ESM
|
// location override, no npm/esbuild rebuild involved. Hashing it would
|
||||||
// bundle, Preact + wouter-preact)
|
// silently break that swap. See `colors.css`'s own top comment.
|
||||||
// dist/static/main-<hash>.js.map source map sibling
|
|
||||||
// dist/static/main-<hash>.css every component's own `import
|
|
||||||
// './Foo.css'` (Shell.css, Panel.css, …),
|
|
||||||
// folded by esbuild into one companion
|
|
||||||
// output alongside main-<hash>.js — no
|
|
||||||
// separate build step, this falls out of
|
|
||||||
// bundling main.tsx with `bundle: true`
|
|
||||||
// dist/static/colors.css served at /static/colors.css — the ONE
|
|
||||||
// static asset deliberately left UNHASHED:
|
|
||||||
// nix/host-modules/swarm-ui.nix's stylix
|
|
||||||
// theming swaps this exact fixed path via
|
|
||||||
// an `= /static/colors.css` nginx location
|
|
||||||
// override, with no npm/esbuild rebuild
|
|
||||||
// involved. Hashing it would silently break
|
|
||||||
// that swap (the override would stop
|
|
||||||
// matching anything, and a themed host
|
|
||||||
// would revert to the default palette). See
|
|
||||||
// `colors.css`'s own top comment.
|
|
||||||
// dist/static/theme-<hash>.css served at /static/theme-<hash>.css
|
|
||||||
// dist/static/swarm-ui-<hash>.css served at /static/swarm-ui-<hash>.css
|
|
||||||
// — just the shared base reset now (@import
|
|
||||||
// resolved from @hive/shared), NOT
|
|
||||||
// component styles
|
|
||||||
// dist/manifest.webmanifest served at /manifest.webmanifest (PWA)
|
|
||||||
// dist/sw.js served at /sw.js (PWA) — plain JS, no
|
|
||||||
// esbuild pass needed (see its own top
|
|
||||||
// comment for why); its `CACHE_VERSION`
|
|
||||||
// placeholder and shell-asset URLs are
|
|
||||||
// rewritten below, same as index.html.
|
|
||||||
// Filename itself stays fixed/unhashed —
|
|
||||||
// the browser polls this exact URL to
|
|
||||||
// detect a SW update, hashing it would
|
|
||||||
// make every deploy register as a brand
|
|
||||||
// new, unrelated worker.
|
|
||||||
//
|
//
|
||||||
// main/theme/swarm-ui's filenames are content-hashed so a redeploy's new
|
// `dist/sw.js` keeps its own fixed/unhashed filename too — the browser
|
||||||
// bundle gets a new URL — nginx's Cache-Control (a follow-up, host-side)
|
// polls this exact URL to detect a SW update, hashing it would make
|
||||||
// can then mark them `immutable, max-age=1y` for real, instead of caching
|
// every deploy register as a brand new worker. Its `CACHE_VERSION`
|
||||||
// a fixed URL that silently serves stale bytes after a deploy changes the
|
// placeholder and shell-asset URLs get rewritten below, same as
|
||||||
// nix store path underneath it.
|
// index.html's.
|
||||||
//
|
//
|
||||||
// PWA icons (icon-192.png/icon-512.png/icon-512-maskable.png) are NOT
|
// PWA icons are NOT produced here — like favicon.svg, they're
|
||||||
// produced here — like favicon.svg, they're rasterized from
|
// rasterized from branding/*.svg and copied in by
|
||||||
// branding/*.svg and copied in by nix/packages/swarm-ui.nix's
|
// nix/packages/swarm-ui.nix's installPhase, outside the npm tree this
|
||||||
// installPhase, outside the npm tree this script builds. A plain `npm
|
// script builds.
|
||||||
// run build` here has no `/icon-*.png`, same as it's always had no
|
|
||||||
// `/favicon.svg`.
|
|
||||||
//
|
//
|
||||||
// Not yet wired into any Rust binary's `ServeDir` — swarm-controller
|
// Not yet wired into any Rust binary's `ServeDir` — swarm-controller
|
||||||
// only serves `/health` today (see swarm-controller/README.md); this
|
// only serves `/health` today; this just makes `dist/` buildable so
|
||||||
// just makes `dist/` buildable so nix/packages/swarm-ui.nix has
|
// nix/packages/swarm-ui.nix has something to package. `.tsx` → JS:
|
||||||
// something to package. `.tsx` → JS: esbuild transpiles TypeScript
|
// esbuild transpiles TypeScript natively (types stripped, not checked)
|
||||||
// natively (types stripped, not checked) — run `npm run typecheck`
|
// — run `npm run typecheck` separately for real type errors.
|
||||||
// (plain `tsc --noEmit`) separately for real type errors; not yet
|
|
||||||
// wired into CI.
|
|
||||||
|
|
||||||
import { build } from "esbuild";
|
import { build } from "esbuild";
|
||||||
import { mkdirSync, rmSync, readFileSync, writeFileSync } from "node:fs";
|
import { mkdirSync, rmSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue