perf: avoid babel in dev by using magic string for hook names injection#183
Merged
JoviDeCroock merged 1 commit intopreactjs:mainfrom Feb 18, 2026
Conversation
| ] | ||
| : []), | ||
| jsxPlugin, | ||
| ...(!useBabel |
Member
There was a problem hiding this comment.
Prefresh of line 300 will still be using Babel though 😅
Contributor
Author
There was a problem hiding this comment.
Yes, it is. I meant the babel transform written directly in this plugin. The prefresh plugin currently runs a separate babel transform (parse + transform + codegen) pass, so this PR will remove half of the babel tranform pass.
In Vite 8, the react refresh transform can be handled by Oxc. So if we use that feature and port https://github.com/swc-project/plugins/tree/main/packages/prefresh and use magic-string for it similarly, we can remove babel completely.
Member
There was a problem hiding this comment.
If you need any help with prefresh LMK, I'm actively working on the babel plugin for signals support atm
JoviDeCroock
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds transformHookNamesPlugin which is a port of babel-plugin-transform-hook-names and uses magic-string to update the code instead of babel. With this change, babel no longer has to be run unless it's specified by the option. This improves performance by up to 31%.
Benchmark
I tested this change with a benchmark script at sapphi-red@2ff89c2.
2000 Components without any hook calls
npm run benchmark:load -- --files 2000 --children 5 --runs 5 --warmups 12000 Components with
useStatecallsnpm run benchmark:load -- --files 2000 --children 5 --runs 5 --warmups 1 --use-state