Skip to content
Source
Sign inSign up
TanStack/intent

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

MergedLadyBluenotes(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/323/headmerged by LadyBluenotes(GitHub profile, opens in a new tab)

🎯 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.
    1. 🦋 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
      NameType
      @tanstack/intentPatch

      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

    2. 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 9212c2d5487ae54d774d9b616208d3ef35b20114 and 1c2976a47bf35a24652d4fcc706e7f5ea75ff150.

      📒 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main change: importing only the semver functions used by intent stale to reduce the bundle.
      Description check✅ PassedThe description includes all required sections, explains the change and its impact, completes the checklist, and identifies the release impact and changeset.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck 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.
    3. View your CI Pipeline Execution ↗ for commit 1c2976a47bf35a24652d4fcc706e7f5ea75ff150

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded1mView ↗
      nx run-many --targets=build✅ Succeeded2sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-04 22:12:28 UTC

    4. Open in StackBlitz

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

      commit: 1c2976a

    5. Merging this PR will not alter performance

      ✅ 12 untouched benchmarks


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

Sign in to join this conversation.