-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix(scanner): catch all external files for glob imports #15286
Conversation
Run & review this pull request in StackBlitz Codeflow. |
I wonder if we should revert #15140 and just add the following code at the end? What do you think? // onResolve is not called for glob imports.
// we need to add that here as well until esbuild calls onResolve for glob imports.
// https://github.com/evanw/esbuild/issues/3317
build.onLoad({ filter: '.', namespace: 'file' }, () => {
const externalOnLoadResult: OnLoadResult = {
loader: 'js',
contents: 'export default {}',
}
return externalOnLoadResult
}) |
66e16c1
to
28a57cb
Compare
In the |
28a57cb
to
2f5271b
Compare
It seems that the test has returned to normal 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM
What else needs to be considered for the current changes? @patak-dev |
Thanks for all your work in Vite lately @XiSenao! |
Description
fixes #15281
fixes #15284
refs #15140
Starting from esbuild@0.19.0, it will attempt to bundle
glob imports
modules, and the special point in handlingglob import
modules is to skip calling theonResolve
hook and directly call theonLoad
hook. If the module cannot be captured by the existingonLoad
hook, then it will prompt "No loader is configured for ".xxx” files:", which is a common issue encountered invite@5.0.0
and later versions.Due to the inability of
esbuild
to callonResolve
plugin when parsingglob imports
,vite
relies onesbuild
during the initial pre-build phase to quickly scan the pre-built dependencies. The modification of #15140 only supports the suffixes supported by Vite. There is no additional processing for suffixes not supported by Vite, so import unsupported suffix types during the pre-build phase will result in an error when scanning dependencies. This change will handle all unconsidered suffixes as a fallback, preventingvite
from throwing errors when scanning new suffixes during the pre-build phase.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).