test(glob-import): cover absolute base resolving to files outside root#22298
Merged
sapphi-red merged 8 commits intoMay 21, 2026
Conversation
Member
|
How does it look like if we add |
6d042ed to
a655c54
Compare
Member
Author
done |
Member
|
I was thinking of changing the structure to put everything in |
Member
Author
This approach could work, but it’s relatively complex and has a broad impact. I think it might be better to make this change after this PR. |
Member
|
Can we first move everything in |
174b666 to
30ef10e
Compare
…esolving_to_files_outside_root
sapphi-red
reviewed
May 21, 2026
…esolving_to_files_outside_root
sapphi-red
approved these changes
May 21, 2026
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.
Summary
Adds an e2e regression test for
import.meta.globwithbase: '/'when the glob pattern matches files outside of Vite's project root.In this scenario the generated import path must be root-relative (
/<relative-to-root>), not importer-relative — otherwise the bundler resolves it against the importer and lands on a non-existent file.Mirrors the minimal reproduction from rolldown/rolldown#9144 (fixed by rolldown/rolldown#9145), where the rolldown-native
viteImportGlobPluginwas emitting an importer-relative path for files outside root.Context
At build time, Vite's
importGlobPlugindelegates to the rolldown-native plugin whenconfig.isBundledis true (seepackages/vite/src/node/plugins/importMetaGlob.ts:46), andisBundledis set wheneverisBuildis true (packages/vite/src/node/config.ts:936).So the new test case exercises the exact code path that caused the bug in the reproduction repo whenever
VITE_TEST_BUILD=1is set.Implementation
After #22466 moved all fixtures of
playground/glob-import/into aroot/subdirectory, the playground naturally has space outside Vite's root: any sibling ofroot/inside the copied playground tree is outside Vite's root but still inside the e2e temp dir. This matches the shape of the original reproduction repo (app/+ siblingexternal/).The new test reuses that structure — no new playground, vite config, or npm script is required: