From 412cc2d481a135497a3ac33d387a924fa75ab7d2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 04:25:07 +0000 Subject: [PATCH 1/2] feat: add esbuild minification, bundler PRD, and CLAUDE.md symlink Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/22b8db61-1a1f-4c84-bbaa-0cf266a093d1 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- AGENTS.md | 48 + CLAUDE.md | 1 + docs/prd/README.md | 6 + docs/prd/bundler.md | 146 ++ package-lock.json | 485 +++++ package.json | 4 +- script.js | 3587 +------------------------------------ scripts/build-css.js | 26 +- scripts/build-js.js | 30 +- styles.css | 3978 +----------------------------------------- 10 files changed, 829 insertions(+), 7482 deletions(-) create mode 120000 CLAUDE.md create mode 100644 docs/prd/bundler.md diff --git a/AGENTS.md b/AGENTS.md index 3088260..c387aa1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,6 +27,7 @@ a Chart.js growth chart with projections, and a prompt/PR quality scoring sectio ├── milestones-data.js ← AUTO-GENERATED from milestones.yaml — do not edit ├── project-stats-data.js ← AUTO-GENERATED from project-stats.yaml — do not edit ├── project-stats.yaml ← Edit this to update footer PR count + token total +├── CLAUDE.md ← symlink → AGENTS.md (read by Claude AI agents) ├── package.json ← version, Jest config & devDependencies (no runtime deps) ├── release-please-config.json ← release-please release automation config ├── .release-please-manifest.json ← release-please version manifest @@ -173,6 +174,15 @@ Edit the relevant file in `src/js/` (see the repository layout for which file co ### Changing the visual theme Edit `styles/variables.css` for colour tokens, or the relevant component file in `styles/` for layout. CSS custom properties for colours live in `:root[data-theme="dark"]` and `:root[data-theme="light"]` inside `styles/variables.css`. The theme toggle is managed by `applyTheme()` in `src/js/01-theme.js`. After any CSS change, run `npm run build:css` to regenerate `styles.css`. +### Running a full build +The `npm run build` convenience script runs all six build steps in sequence: + +```bash +npm run build # equivalent to: build:milestones + build:changelog + build:project-stats + build:js + build:css +``` + +This is useful when multiple YAML/source changes need to be batched in one step. + ### Deployment Merging to `main` triggers the `deploy.yml` workflow automatically. It pushes the static site to the `gh-pages` branch (root). @@ -207,6 +217,44 @@ Every pull request automatically gets a live preview URL: --- +## Build System & Bundler + +The build pipeline uses **esbuild** (`devDependency`) to minify the concatenated JS and +CSS output. The two-stage process is: + +1. **Concatenate** — `scripts/build-js.js` (or `build-css.js`) assembles source files + into a single string in memory. +2. **Minify** — esbuild's synchronous `transformSync()` API minifies the string and + writes the final file. + +Measured savings on the current codebase: + +| File | Before | After | Saving | +|------|--------|-------|--------| +| `script.js` | ~140 KB | ~74 KB | ~47% | +| `styles.css` | ~86 KB | ~66 KB | ~23% | + +**Why esbuild and not webpack/rollup/parcel/vite?** + +- The site uses an IIFE/globals architecture (no ES modules), so true tree-shaking does + not apply. +- esbuild handles both JS and CSS minification with a single devDependency. +- It requires zero configuration files. +- Build times are in the low-millisecond range. + +**Why the root-level JS files stay at root:** + +GitHub Pages publishes from `publish_dir: .` in the deploy workflow. Moving the +generated runtime files (`script.js`, `death-clock-core.js`, `*-data.js`, etc.) to a +`dist/` subdirectory would require updating all `