Skip to content

perf: bundle only the semver functions that stale uses - #323

Merged
LadyBluenotes merged 1 commit into
mainfrom
perf/semver-function-imports
Oct 4, 2026
Merged

LadyBluenotes merged 1 commit into
mainfrom
perf/semver-function-imports

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

  • intent stale is the only command that uses semver, and it uses six functions: coerce, diff, eq, gt, parse, and valid. 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 semver code goes from 45 modules to 13.
  • Speed does not get worse. The stale benchmarks are unchanged, and a cold intent stale process 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 (run pnpm build:all first).

🚀 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 stale without changing its behavior.

@changeset-bot

changeset-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c2976a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/intent Patch

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

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 9212c2d and 1c2976a.

📒 Files selected for processing (2)
  • .changeset/semver-function-imports.md
  • packages/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.md
The 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 1c297

The 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 1c297

The change affects 1 system.

Changed systems: packages/intent

Architecture 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 semver import with named imports for coercion, diffing, equality, comparison, parsing, and validation.
  • observed — Modified behavior in packages/intent/src/staleness/check.ts: classifyVersionDrift now calls the imported eq, gt, and parse functions instead of methods on the default semver import; its checks and outcomes are unchanged.
  • observed — Modified behavior in packages/intent/src/staleness/check.ts: Drift classification now calls the imported diff function instead of semver.diff; the resulting classification logic is unchanged.
  • observed — Modified behavior in packages/intent/src/staleness/check.ts: normalizeVersion now uses the imported valid and coerce functions 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 stale to 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.

❤️ Share

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

@nx-cloud

nx-cloud Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 1c2976a

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:28 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@323

commit: 1c2976a

@LadyBluenotes
LadyBluenotes merged commit 5a0ec60 into main Oct 4, 2026
9 checks passed
@LadyBluenotes
LadyBluenotes deleted the perf/semver-function-imports branch October 4, 2026 22:16
@codspeed

codspeed Bot commented Oct 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing perf/semver-function-imports (1c2976a) with main (9212c2d)

Open in CodSpeed

@github-actions github-actions Bot mentioned this pull request Oct 4, 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.

1 participant