Skip to content

feat: esbuild minification, bundler PRD, and CLAUDE.md symlink#61

Merged
nitrocode merged 2 commits into
mainfrom
copilot/choose-bundler-and-organize-scripts
Apr 24, 2026
Merged

feat: esbuild minification, bundler PRD, and CLAUDE.md symlink#61
nitrocode merged 2 commits into
mainfrom
copilot/choose-bundler-and-organize-scripts

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

  • Verify finding: package.json build script chains exactly five steps; AGENTS.md line 178 said "six" — confirmed incorrect
  • Fix AGENTS.md: change "all six build steps" → "all five build steps"

Summary by CodeRabbit

  • Documentation

    • Enhanced development guides with build system architecture and optimization details
    • Added product requirements document for bundler and build optimization strategy
  • Chores

    • Integrated minification into the build process, reducing JavaScript and CSS file sizes
    • Added consolidated npm run build command to execute all build steps sequentially

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d625d02-942a-4fa1-9d09-81b628771aff

📥 Commits

Reviewing files that changed from the base of the PR and between 412cc2d and fb1424b.

📒 Files selected for processing (1)
  • AGENTS.md
✅ Files skipped from review due to trivial changes (1)
  • AGENTS.md

📝 Walkthrough

Walkthrough

Adds esbuild-based minification to the JS and CSS build scripts, adds esbuild as a devDependency, introduces a combined npm run build script that sequences existing build subtasks, and updates documentation and a PRD to describe the bundler design and measured size reductions.

Changes

Cohort / File(s) Summary
Build System Configuration
package.json
Adds aggregated build script that sequences all existing build subtasks; adds esbuild to devDependencies.
Build Script Updates
scripts/build-js.js, scripts/build-css.js
Concatenate then minify outputs using esbuild.transformSync({ minify: true }); write minified outputs and update logging to report pre-minify metrics and minified byte sizes/percent reductions.
Documentation & PRDs
AGENTS.md, CLAUDE.md, docs/prd/README.md, docs/prd/bundler.md
Adds “Running a full build” and “Build System & Bundler” details to AGENTS.md, creates CLAUDE.md as a symlink/reference, adds PRD and index entry describing esbuild-based two-stage minification and recorded size savings.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as npm/CLI
    participant Scripts as build scripts
    participant ESBUILD as esbuild.transformSync
    participant FS as Filesystem
    CLI->>Scripts: run aggregated build (npm run build)
    Scripts->>Scripts: concatenate JS/CSS parts into unminified string
    Scripts->>ESBUILD: transformSync(unminified, {loader, minify:true})
    ESBUILD-->>Scripts: minified code
    Scripts->>FS: write minified `script.js` / `styles.css`
    Scripts->>CLI: log pre-minify metrics and minified sizes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • nitrocode
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main changes: esbuild minification integration, bundler PRD documentation, and CLAUDE.md symlink creation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/choose-bundler-and-organize-scripts

Comment @coderabbitai help to get the list of available commands and usage tips.

@nitrocode nitrocode marked this pull request as ready for review April 24, 2026 11:55
@nitrocode nitrocode self-requested a review as a code owner April 24, 2026 11:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

👁️ PR Preview

🚀 Open Preview

Deployed from commit fb1424b · Updates on every push to this PR
(Preview is removed automatically when the PR is closed.)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6c03ac8) to head (fb1424b).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #61   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          233       233           
  Branches       107       107           
=========================================
  Hits           233       233           
Flag Coverage Δ
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b70ac48...fb1424b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
scripts/build-js.js (1)

94-98: Use real byte counts in the size log.

Line 97 says “bytes,” but .length is UTF-16 code units. Use Buffer.byteLength(...) so the metric matches the label.

Proposed refactor
-const ratio = ((1 - result.code.length / unminified.length) * 100).toFixed(1);
+const unminifiedBytes = Buffer.byteLength(unminified, 'utf8');
+const minifiedBytes = Buffer.byteLength(result.code, 'utf8');
+const ratio = ((1 - minifiedBytes / unminifiedBytes) * 100).toFixed(1);
 console.log(
   `script.js rebuilt from ${PARTS.length} source files ` +
-  `(${unminified.split('\n').length - 1} lines → ${result.code.length} bytes, −${ratio}% via esbuild minification)`,
+  `(${unminified.split('\n').length - 1} lines → ${minifiedBytes} bytes, −${ratio}% via esbuild minification)`,
 );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/build-js.js` around lines 94 - 98, The log uses string lengths
(UTF-16 code units) but labels them "bytes"; change the computation to use byte
counts via Buffer.byteLength for both unminified and result.code (replace uses
of unminified.length and result.code.length), recompute ratio from the byte
counts, and update the console.log text accordingly (references: ratio variable,
result.code, unminified, PARTS).
scripts/build-css.js (1)

61-65: Make the CSS size metric byte-accurate.

Line 64 reports “bytes,” but .length is not byte size. Use Buffer.byteLength for exact logging.

Proposed refactor
-const ratio = ((1 - result.code.length / unminified.length) * 100).toFixed(1);
+const unminifiedBytes = Buffer.byteLength(unminified, 'utf8');
+const minifiedBytes = Buffer.byteLength(result.code, 'utf8');
+const ratio = ((1 - minifiedBytes / unminifiedBytes) * 100).toFixed(1);
 console.log(
   `styles.css rebuilt from ${PARTS.length} source files ` +
-  `(${unminified.split('\n').length - 1} lines → ${result.code.length} bytes, −${ratio}% via esbuild minification)`,
+  `(${unminified.split('\n').length - 1} lines → ${minifiedBytes} bytes, −${ratio}% via esbuild minification)`,
 );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/build-css.js` around lines 61 - 65, The size calculation uses .length
(characters) instead of byte length; update the computations that use
result.code.length and unminified.length (used in the ratio variable and the
console.log message that references PARTS and the lines/bytes text) to use
Buffer.byteLength(..., 'utf8') so the reported “bytes” and the percent reduction
are byte-accurate; ensure you compute the byte sizes once (e.g., unminifiedBytes
and minifiedBytes) and use those values in the ratio and the log string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@AGENTS.md`:
- Around line 177-182: The docs claim "all six build steps" but the `npm run
build` sequence and package.json define five steps (build:milestones,
build:changelog, build:project-stats, build:js, build:css); update AGENTS.md to
correct the count to "five build steps" (or add the missing step to package.json
if intended), and ensure the `npm run build` comment and the listed sub-commands
(build:milestones, build:changelog, build:project-stats, build:js, build:css)
are consistent with package.json.

---

Nitpick comments:
In `@scripts/build-css.js`:
- Around line 61-65: The size calculation uses .length (characters) instead of
byte length; update the computations that use result.code.length and
unminified.length (used in the ratio variable and the console.log message that
references PARTS and the lines/bytes text) to use Buffer.byteLength(..., 'utf8')
so the reported “bytes” and the percent reduction are byte-accurate; ensure you
compute the byte sizes once (e.g., unminifiedBytes and minifiedBytes) and use
those values in the ratio and the log string.

In `@scripts/build-js.js`:
- Around line 94-98: The log uses string lengths (UTF-16 code units) but labels
them "bytes"; change the computation to use byte counts via Buffer.byteLength
for both unminified and result.code (replace uses of unminified.length and
result.code.length), recompute ratio from the byte counts, and update the
console.log text accordingly (references: ratio variable, result.code,
unminified, PARTS).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 81ca62eb-0f34-4d2f-8bfa-f0d7a1efd382

📥 Commits

Reviewing files that changed from the base of the PR and between 0948ecb and 412cc2d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • AGENTS.md
  • CLAUDE.md
  • docs/prd/README.md
  • docs/prd/bundler.md
  • package.json
  • script.js
  • scripts/build-css.js
  • scripts/build-js.js
  • styles.css

Comment thread AGENTS.md
auto-merge was automatically disabled April 24, 2026 12:04

Head branch was pushed to by a user without write access

@nitrocode nitrocode merged commit ced79e7 into main Apr 24, 2026
10 checks passed
@nitrocode nitrocode deleted the copilot/choose-bundler-and-organize-scripts branch April 24, 2026 12:08
github-actions Bot added a commit that referenced this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants