Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: shorten react import regex pattern #250

Merged
merged 1 commit into from
Nov 4, 2023

Conversation

StyleShit
Copy link
Contributor

@StyleShit StyleShit commented Nov 3, 2023

I came to this repo to read how it works under the hood and noticed that this regex pattern can be shortened.
Well... it's nitpicking and probably doesn't really matter, I just thought it could be easier to read.
I also saw a slight improvement in performance on my machine (which might be negligible and considered a redundant micro-optimization, but still 馃槄).

Regex Test
Regex Benchmark

Thank you for maintaining it! 馃槃

@ArnaudBarre
Copy link
Member

Hi!
Thanks the use of \b seems legit here.
The perf gain will be only for people using the classic runtime which should be low I hope now.
@sapphi-red WDYT?

@sapphi-red
Copy link
Member

The new regex will match more cases (e.g. import foo from 'foo'; import React from 'react') and I guess it'd fix some edge cases, too.

@ArnaudBarre ArnaudBarre merged commit 9956fb5 into vitejs:main Nov 4, 2023
8 checks passed
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.

None yet

3 participants