Skip to content

feat: use --before to show old versions in package timeline - #3264

Open
nicolo-ribaudo wants to merge 1 commit into
npmx-dev:mainfrom
nicolo-ribaudo:fix/historical-install-size
Open

nicolo-ribaudo wants to merge 1 commit into
npmx-dev:mainfrom
nicolo-ribaudo:fix/historical-install-size

Conversation

@nicolo-ribaudo

@nicolo-ribaudo nicolo-ribaudo commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

None -- we briefly discussed this in Discord, I can create one if needed.

🧭 Context

Today we released a new version of Babel (8.0.6) that halved the package size. I went to npmx.dev's timeline view to get my daily dopamine dose, and unfortunately I saw that... Babel 8.0.6 was almost the same size as 8.0.5 :/

image

The reason is that @babel/core@8.0.5 depends on multiple other Babel packages; so it was now in the stats pulling the 8.0.6 version of them making it look like as if 8.0.5 was already small.

📚 Description

This PR introduces a behavior similar to pnpm's --before, making sure that a package's computed size reflects the latest state of the registry before that the next version was released. This is different from taking a snapshot when a given version is released, so that the shown size reflects what was the actual total size when that old version was still the current one.

A couple notes:

  • I also kept the old logic of not using --before and instead resolving to whatever are the latest dep versions in range. I think this is important for the "Install Size" information in a package's main page, this:
    image
    that's because even if I'm looking at an older version, that number is mostly useful to answer the question "how big would it be if I were to add this version now to my dependencies?". On hover it then also shows the --before-frozen size:
    image
  • Given that I was keeping that logic around anyway, I left a "frozen history" toggle in the timeline view (enabled by default). When it's disabled it restore the old behavior, showing how big an old version is if I were to install it today:
    image
    image
  • The "Package size reduced!" and "Package size increased!" banners use the historical size, since that's useful for people that are updating their dependency and thus are comparing the size at the time they installed the old one with the size they would get now by installing the updated one.

I used an LLM to help with this; all the production code has been cleaned up / rewritten by me, but the tests are in large part auto-generated.

@agentscanapp

agentscanapp Bot commented Sep 18, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉

We really appreciate you taking the time to contribute, @nicolo-ribaudo.

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description explains what changed and why
  • any related issues are linked
  • existing tests still pass

If anything needs adjusting we'll leave comments here. Thanks again!

@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs.npmx.dev Ready Ready Preview Sep 18, 2026 10:50pm UTC
npmx.dev Ready Ready Preview Sep 18, 2026 10:50pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
npmx-lunaria Ignored Ignored Sep 18, 2026 10:50pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: npmx-dev/npmx.dev/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6822582c-ea4a-4f70-ae11-824d44278ccd

📥 Commits

Reviewing files that changed from the base of the PR and between e8bcb58 and 9ba19cb.

📒 Files selected for processing (14)
  • app/components/Package/TimelineChart.vue
  • app/composables/useInstallSizeDiff.ts
  • app/composables/useTimelineFrozenHistory.ts
  • app/pages/package-timeline/[[org]]/[packageName].vue
  • app/pages/package/[[org]]/[name].vue
  • docs/content/2.guide/1.features.md
  • i18n/locales/en.json
  • i18n/schema.json
  • server/api/registry/install-size/[...pkg].get.ts
  • server/api/registry/timeline/sizes/[...pkg].get.ts
  • server/utils/dependency-resolver.ts
  • server/utils/install-size.ts
  • test/nuxt/composables/use-install-size-diff.spec.ts
  • test/unit/server/utils/dependency-resolver.spec.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added a “Frozen history” option to package timeline charts, enabled by default.
    • Timeline and install-size metrics can now reflect dependencies available when each version was released.
    • Non-latest package versions display frozen install-size information when it differs from the current total.
  • Documentation

    • Clarified install-size calculations and the frozen-history option in the user guide.
  • Bug Fixes

    • Ensured historical and current size comparisons use consistent dependency-resolution modes.

Walkthrough

The change adds frozen-history dependency resolution for install-size data. It adds server and client mode selection, separate caches, timeline controls, package-page display logic, localisation, documentation, and tests.

Changes

Frozen history support

Layer / File(s) Summary
Historical dependency resolution and sizing
server/utils/dependency-resolver.ts, server/utils/install-size.ts, test/unit/server/utils/dependency-resolver.spec.ts
Dependency resolution can use publish-time limits. Install-size calculation supports current and historical resolution caches. Tests cover time limits, aliases, prereleases, release batches, and dependency trees.
API mode selection and cache separation
server/api/registry/install-size/[...pkg].get.ts, server/api/registry/timeline/sizes/[...pkg].get.ts
The APIs parse frozen-history, pass historical resolution limits to install-size calculation, and separate current and frozen responses in their cache keys.
Client history selection and display
app/composables/useTimelineFrozenHistory.ts, app/components/Package/TimelineChart.vue, app/pages/package-timeline/[[org]]/[packageName].vue, app/composables/useInstallSizeDiff.ts, app/pages/package/[[org]]/[name].vue, i18n/locales/en.json, i18n/schema.json, docs/content/2.guide/1.features.md, test/nuxt/composables/use-install-size-diff.spec.ts
The timeline adds a frozen-history toggle and mode-specific size caches. Package comparisons fetch frozen values when required. The package page displays differing frozen sizes. Localisation, documentation, and fetch-behaviour tests describe and validate the mode.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TimelineChart
  participant TimelineEndpoint
  participant InstallSize
  participant DependencyResolver
  User->>TimelineChart: change frozen-history setting
  TimelineChart->>TimelineEndpoint: request sizes with frozen-history flag
  TimelineEndpoint->>InstallSize: calculate sizes with historical limit
  InstallSize->>DependencyResolver: resolve dependencies before cutoff
  DependencyResolver-->>InstallSize: resolved dependency tree
  InstallSize-->>TimelineEndpoint: size metrics
  TimelineEndpoint-->>TimelineChart: mode-specific metrics
Loading

Suggested reviewers: 43081j, flo0806

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 9ba19

The frozen-history flow retains its intended route-refresh and monorepo release-batch behavior, with no concrete unresolved merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarises the main change: using pnpm-like --before behaviour to show historical package sizes. It is concise and follows the conventional commit format.
Description check ✅ Passed The description is directly related to the changes. It explains the historical size problem, the frozen-history behaviour, the timeline toggle, retained current-resolution behaviour, and the affected …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@github-actions

Copy link
Copy Markdown

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@nicolo-ribaudo nicolo-ribaudo changed the title feat: Use --before to show old versions in package timeline feat: use --before to show old versions in package timeline Sep 18, 2026
@nicolo-ribaudo

Copy link
Copy Markdown
Contributor Author

It's working for me locally, but not in the PR preview. Any idea of what I might need to look at to figure out why?

This branch was successfully deployed

2 active deployments
Preview – npmx.dev 9ba19cba Deployed Sep 18, 2026 by vercel[bot]
Preview – docs.npmx.dev 9ba19cba Deployed Sep 18, 2026 by vercel[bot]
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