feat: esbuild minification, bundler PRD, and CLAUDE.md symlink#61
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds esbuild-based minification to the JS and CSS build scripts, adds esbuild as a devDependency, introduces a combined Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
👁️ PR Preview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 233 233
Branches 107 107
=========================================
Hits 233 233
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
.lengthis UTF-16 code units. UseBuffer.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
.lengthis not byte size. UseBuffer.byteLengthfor 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
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (9)
AGENTS.mdCLAUDE.mddocs/prd/README.mddocs/prd/bundler.mdpackage.jsonscript.jsscripts/build-css.jsscripts/build-js.jsstyles.css
Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/795da0af-501b-4062-98ff-8a3762762d09 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Head branch was pushed to by a user without write access
package.jsonbuildscript chains exactly five steps; AGENTS.md line 178 said "six" — confirmed incorrectSummary by CodeRabbit
Documentation
Chores
npm run buildcommand to execute all build steps sequentially