Repository navigation
fix(importMetaGlob): throw early for relative glob patterns in virtual modules - #22358
Closed
DoriAlagem wants to merge 2 commits into
Closed
DoriAlagem wants to merge 2 commits into
DoriAlagem wants to merge 2 commits into
Conversation
Author
|
Hey @bluwy — just a gentle ping on this one! It's been about a week since opening. Happy to make any adjustments if needed. |
sapphi-red
requested changes
May 14, 2026
sapphi-red
left a comment
Member
There was a problem hiding this comment.
Would you fix the test failure?
Member
|
closing as #22497 is merged |
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.
Fixes #22345.
Problem
When a plugin produces a virtual module that calls
import.meta.globwith a relative pattern (e.g.'./*.js'), Vite silently returns{}instead of throwing the documented error:The existing check inside
resolvePathsis only reached when matched files are iterated. If the relative pattern matches no files (or matches files that are then filtered out),resolvePathsis never called — so the error is never thrown and the caller gets an empty object with no diagnostic.Minimal repro:
modulesis{}with no warning or error logged.Fix
Add an early guard immediately before the
glob()call. If the module is virtual (!dir), the pattern is relative (isRelative), and nobaseoption is set, throw the same error message that already exists further down inresolvePaths. This ensures the user gets a clear diagnostic regardless of whether any files happen to match the broken pattern.