Skip to content

Replace lru-cache with flru - #18232

Merged
nicolo-ribaudo merged 1 commit into
babel:mainfrom
nicolo-ribaudo:use-flru
Sep 11, 2026
Merged

nicolo-ribaudo merged 1 commit into
babel:mainfrom
nicolo-ribaudo:use-flru

Conversation

@nicolo-ribaudo

Copy link
Copy Markdown
Member
Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I was looking at https://npmx.dev/package-timeline/@babel/core/v/8.0.1 and notice that the install size of @babel/core increased from 11MB to 12MB in Babel 8:

The reason seems to be lru-cache, which is a whole 2.7MB:
image

We have a very simple usage of it, and this PR replaces with with a much smaller and faster library that does the same thing, flru: https://github.com/lukeed/flru

This is the first dependency we have from that author and repository has not been touched in years (also, it probably doesn't need to, it's a 20 lines long file), so just in case I'm pinning its version to avoid potential problems.

Note that lru-cache is still pulled in as a transitive dependency of @babel/cli and @babel/register, but most users don't use those.

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Sep 10, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62099

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: bc23b9c

@nicolo-ribaudo nicolo-ribaudo added PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories and removed PR: Internal 🏠 A type of pull request used for our changelog categories labels Sep 10, 2026
@nicolo-ribaudo
nicolo-ribaudo merged commit 427f56c into babel:main Sep 11, 2026
58 checks passed
@nicolo-ribaudo
nicolo-ribaudo deleted the use-flru branch September 11, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants