Skip to content

perf: Improve performance by caching the isUsingTranspiler function#680

Open
igeligel wants to merge 1 commit intoamilajack:mainfrom
igeligel:memoize-isUsingTranspiler
Open

perf: Improve performance by caching the isUsingTranspiler function#680
igeligel wants to merge 1 commit intoamilajack:mainfrom
igeligel:memoize-isUsingTranspiler

Conversation

@igeligel
Copy link

What this PR is doing?

We are memoizing the isUsingTranspiler. File reads are not great in large mono repositories. Where I work this is a bottleneck. Specifically for directories with a large number of files this can blow up the time a lot.

This PR also fixes a minor bug. The function took the context and computed the directory like const dir = context.filename ?? context.getFilename();.

The problem is that this is passing the file name instead of the expected directory to findUp. This is also fixed in this PR. I have added tests as well.

Benchmarks

Gist: https://gist.github.com/igeligel/af1961949a79d91e4855fc017b1d75ef

Repo Before mean (s) After mean (s) Change
electron-react-boilerplate 0.0316 0.0238 ~25% faster
handlebars.js 0.462 0.319 ~31% faster
jquery 1.089 0.841 ~23% faster
pixi.js 2.284 1.451 ~36% faster
bootstrap 0.609 0.558 ~8% faster
preact 0.00689 0.00550 ~20% faster
aframe 8.070 7.562 ~6% faster
create-react-app 2.685 2.658 ~1% faster

Cache the isUsingTranspiler per directory
@igeligel igeligel changed the title [Performance] Improve performance by caching the isUsingTranspiler function perf: Improve performance by caching the isUsingTranspiler function Feb 15, 2026
@amilajack
Copy link
Owner

amilajack commented Feb 18, 2026

thanks for this, happy to merge after fixing merge conflicts

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.

2 participants

Comments