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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: extract vite:resolve internal functions #12522

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

patak-dev
Copy link
Member

Description

Extract two functions in vite:resolve resolveId that are being created for every call.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@stackblitz
Copy link

stackblitz bot commented Mar 21, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev added the performance Performance related enhancement label Mar 22, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Got one suggestion below that we can do in this PR, or separately if you prefer.

Comment on lines +465 to +467
const isNodeModule =
nodeModulesInPathRE.test(normalizePath(id)) ||
nodeModulesInPathRE.test(normalizePath(resolved))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can improve this part too. We're doing simple node_modules includes check everywhere, not sure why we special case a regex check here. We can simplify this to: id.includes('node_modules') || resolved.includes('node_modules')

Copy link
Member

@bluwy bluwy Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it looks like I asked the same thing last year too 🙈 #9848 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, and I'll say the same, but this time let's do it in another PR for real 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking node_modules alone has worked well so far for us, I don't think we need to be stricter though

@patak-dev patak-dev changed the title refactor: extract vite:resolve internal functions perf: extract vite:resolve internal functions Mar 23, 2023
@patak-dev patak-dev merged commit 6ea4be2 into main Mar 23, 2023
@patak-dev patak-dev deleted the refactor/resolve-id-internal-functions branch March 23, 2023 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance related enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants