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: move up external url check before fs path checks #13639

Conversation

suguanYang
Copy link
Contributor

@suguanYang suguanYang commented Jun 26, 2023

Description

The real problem:
I was developing a plugin that can distribute the optimizied dependencies, so the resolved id will like this: https://xxx/react@18.2.0/jsx-runtime, for vite perspective, the optimized dependencies should all local files, the resolved id will become something like this /@fs/https:/xxx/react@18.2.0/jsx-runtime?v=628f3470

I can not ask vite community to consider my use case, but I think we could optimize this code since there is no meaning that we put the external condition after some file related conditions.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jun 26, 2023

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

@suguanYang suguanYang marked this pull request as ready for review June 26, 2023 11:43
@suguanYang
Copy link
Contributor Author

@sapphi-red Hi, can you help tp review this?

@suguanYang suguanYang force-pushed the perf/move-up-external-condition-before-file-related-conditions branch from 1a815c4 to ef41e5b Compare June 26, 2023 16:39
@suguanYang
Copy link
Contributor Author

@yyx990803 Hi Evan, can you have a look at this?

packages/vite/src/node/plugins/importAnalysis.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/importAnalysis.ts Outdated Show resolved Hide resolved
@suguanYang
Copy link
Contributor Author

@bluwy Hi bluwy, thanks for your review and comments, I have made some changes that do not affect the url variable, and this has less impact than the previous one.

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@suguanYang suguanYang force-pushed the perf/move-up-external-condition-before-file-related-conditions branch from 4ab0f43 to 83d957e Compare October 9, 2023 07:36
@bluwy bluwy changed the title perf: move up external condition before path related conditions perf: move up external url check before fs path checks Oct 9, 2023
@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Oct 9, 2023
@bluwy bluwy merged commit c2ebea1 into vitejs:main Oct 9, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants