perf: bundle only the semver functions that stale uses #323
main fromrefs/pull/323/head·merged by LadyBluenotes(GitHub profile, opens in a new tab) 🎯 Changes#
intent staleis the only command that usessemver, and it uses six functions:coerce,diff,eq,gt,parse, andvalid. The default import loaded the package index, which requires all 45 modules, so the whole library went into the staleness chunk.- Each function is now imported from its own module (
semver/functions/<name>.js), which is the same code that the index re-exports. - The built package goes from 810,204 to 775,164 bytes (35,040 fewer; 6,412 fewer gzipped), and the bundled
semvercode goes from 45 modules to 13. - Speed does not get worse. The
stalebenchmarks are unchanged, and a coldintent staleprocess is 1 to 2 ms faster because it loads fewer modules. - Behavior does not change.
- Adds a patch changeset.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr(runpnpm build:allfirst).
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Improvements
- Reduced the bundle size of
intent stalewithout changing its behavior.
- Reduced the bundle size of
- 1
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9c13d17a-9a07-49fa-ab6c-a503777f719e
📥 Commits
Reviewing files that changed from the base of the PR and between 9212c2d5487ae54d774d9b616208d3ef35b20114 and 1c2976a47bf35a24652d4fcc706e7f5ea75ff150.
📒 Files selected for processing (2)
.changeset/semver-function-imports.mdpackages/intent/src/staleness/check.ts
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
📝 Walkthrough
Walkthrough#
The staleness checks now import individual semver functions instead of using the default import. The classification and normalization behavior remains unchanged. A patch changeset records the import change and smaller bundle.
Changes#
Staleness semver imports
Layer / File(s) Summary Semver imports and staleness checks
packages/intent/src/staleness/check.ts,.changeset/semver-function-imports.mdThe staleness checks use named imports for semver operations. The patch changeset describes the smaller bundle and unchanged behavior. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Refactor
Merge Risk: ⚪ Minimal · up to
1c297The staleness check continues to use the same semver operations and behavior. The change is limited to imports and a release note, with no identified merge risk.
Architecture Summary#
Architecture risk: 🟡 Medium · up to
1c297The change affects 1 system.
Changed systems:
packages/intentArchitecture concerns No architecture-level concerns identified.
Review details
Systems and components
- observed — packages/intent (library) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in packages/intent/src/staleness/check.ts: Replace the default
semverimport with named imports for coercion, diffing, equality, comparison, parsing, and validation. - observed — Modified behavior in packages/intent/src/staleness/check.ts:
classifyVersionDriftnow calls the importedeq,gt, andparsefunctions instead of methods on the defaultsemverimport; its checks and outcomes are unchanged. - observed — Modified behavior in packages/intent/src/staleness/check.ts: Drift classification now calls the imported
difffunction instead ofsemver.diff; the resulting classification logic is unchanged. - observed — Modified behavior in packages/intent/src/staleness/check.ts:
normalizeVersionnow uses the importedvalidandcoercefunctions rather than the default import’s methods, preserving the validation-then-coercion behavior.
Reliability and maintainability
- inferred — Risk-relevant change factors for packages/intent: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly summarizes the main change: importing only the semver functions used by intent staleto reduce the bundle.Description check ✅ Passed The description includes all required sections, explains the change and its impact, completes the checklist, and identifies the release impact and changeset. 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. Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 unsupported.)
- Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands.View your CI Pipeline Execution ↗ for commit 1c2976a47bf35a24652d4fcc706e7f5ea75ff150
Command Status Duration Result nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded 1m View ↗ nx run-many --targets=build✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-04 22:12:28UTCMerging this PR will not alter performance#
✅ 12untouched benchmarks
Comparingperf/semver-function-imports(1c2976a) withmain(9212c2d)
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 1c2976a47bf35a24652d4fcc706e7f5ea75ff150
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR