-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fix(glob): handle glob imports from folders starting with dot #20800
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
Merged
+21
−6
Conversation
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
Co-authored-by: sapphi-red <[email protected]>
Co-authored-by: sapphi-red <[email protected]>
Copilot finished work on behalf of
sapphi-red
September 19, 2025 05:43
sapphi-red
reviewed
Sep 19, 2025
packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.spec.ts.snap
Outdated
Show resolved
Hide resolved
Co-authored-by: sapphi-red <[email protected]>
Copilot finished work on behalf of
sapphi-red
September 19, 2025 06:10
sapphi-red
reviewed
Sep 19, 2025
Co-authored-by: sapphi-red <[email protected]>
Copilot stopped work on behalf of
sapphi-red due to an error
September 19, 2025 06:45
sapphi-red
reviewed
Sep 19, 2025
Co-authored-by: sapphi-red <[email protected]>
Copilot stopped work on behalf of
sapphi-red due to an error
September 19, 2025 09:13
sapphi-red
approved these changes
Sep 19, 2025
bluwy
approved these changes
Sep 19, 2025
renovate bot
added a commit
to andrei-picus-tink/auto-renovate
that referenced
this pull request
Sep 22, 2025
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.1.4 | 7.1.7 | ## [v7.1.7](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-717-2025-09-22-small) ##### Bug Fixes - **build:** fix ssr environment `emitAssets: true` when `sharedConfigBuild: true` ([#20787](vitejs/vite#20787)) ([4c4583c](vitejs/vite@4c4583c)) - **client:** use CSP nonce when rendering error overlay ([#20791](vitejs/vite#20791)) ([9bc9d12](vitejs/vite@9bc9d12)) - **deps:** update all non-major dependencies ([#20811](vitejs/vite#20811)) ([9f2247c](vitejs/vite@9f2247c)) - **glob:** handle glob imports from folders starting with dot ([#20800](vitejs/vite#20800)) ([105abe8](vitejs/vite@105abe8)) - **hmr:** trigger prune event when import is removed from non hmr module ([#20768](vitejs/vite#20768)) ([9f32b1d](vitejs/vite@9f32b1d)) - **hmr:** wait for `import.meta.hot.prune` callbacks to complete before running other HMRs ([#20698](vitejs/vite#20698)) ([98a3484](vitejs/vite@98a3484)) ## [v7.1.6](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-716-2025-09-18-small) ##### Bug Fixes - **deps:** update all non-major dependencies ([#20773](vitejs/vite#20773)) ([88af2ae](vitejs/vite@88af2ae)) - **esbuild:** inject esbuild helper functions with minified `$` variables correctly ([#20761](vitejs/vite#20761)) ([7e8e004](vitejs/vite@7e8e004)) - fallback terser to main thread when nameCache is provided ([#20750](vitejs/vite#20750)) ([a679a64](vitejs/vite@a679a64)) - **types:** strict env typings fail when `skipLibCheck` is `false` ([#20755](vitejs/vite#20755)) ([cc54e29](vitejs/vite@cc54e29)) ##### Miscellaneous Chores - **deps:** update rolldown-related dependencies ([#20675](vitejs/vite#20675)) ([a67bb5f](vitejs/vite@a67bb5f)) - **deps:** update rolldown-related dependencies ([#20772](vitejs/vite#20772)) ([d785e72](vitejs/vite@d785e72)) ## [v7.1.5](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-715-2025-09-08-small) ##### Bug Fixes - apply `fs.strict` check to HTML files ([#20736](vitejs/vite#20736)) ([14015d7](vitejs/vite@14015d7)) - **deps:** update all non-major dependencies ([#20732](vitejs/vite#20732)) ([122bfba](vitejs/vite@122bfba)) - upgrade sirv to 3.0.2 ([#20735](vitejs/vite#20735)) ([09f2b52](vitejs/vite@09f2b52))
renovate bot
added a commit
to andrei-picus-tink/auto-renovate
that referenced
this pull request
Sep 23, 2025
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.1.4 | 7.1.7 | ## [v7.1.7](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-717-2025-09-22-small) ##### Bug Fixes - **build:** fix ssr environment `emitAssets: true` when `sharedConfigBuild: true` ([#20787](vitejs/vite#20787)) ([4c4583c](vitejs/vite@4c4583c)) - **client:** use CSP nonce when rendering error overlay ([#20791](vitejs/vite#20791)) ([9bc9d12](vitejs/vite@9bc9d12)) - **deps:** update all non-major dependencies ([#20811](vitejs/vite#20811)) ([9f2247c](vitejs/vite@9f2247c)) - **glob:** handle glob imports from folders starting with dot ([#20800](vitejs/vite#20800)) ([105abe8](vitejs/vite@105abe8)) - **hmr:** trigger prune event when import is removed from non hmr module ([#20768](vitejs/vite#20768)) ([9f32b1d](vitejs/vite@9f32b1d)) - **hmr:** wait for `import.meta.hot.prune` callbacks to complete before running other HMRs ([#20698](vitejs/vite#20698)) ([98a3484](vitejs/vite@98a3484)) ## [v7.1.6](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-716-2025-09-18-small) ##### Bug Fixes - **deps:** update all non-major dependencies ([#20773](vitejs/vite#20773)) ([88af2ae](vitejs/vite@88af2ae)) - **esbuild:** inject esbuild helper functions with minified `$` variables correctly ([#20761](vitejs/vite#20761)) ([7e8e004](vitejs/vite@7e8e004)) - fallback terser to main thread when nameCache is provided ([#20750](vitejs/vite#20750)) ([a679a64](vitejs/vite@a679a64)) - **types:** strict env typings fail when `skipLibCheck` is `false` ([#20755](vitejs/vite#20755)) ([cc54e29](vitejs/vite@cc54e29)) ##### Miscellaneous Chores - **deps:** update rolldown-related dependencies ([#20675](vitejs/vite#20675)) ([a67bb5f](vitejs/vite@a67bb5f)) - **deps:** update rolldown-related dependencies ([#20772](vitejs/vite#20772)) ([d785e72](vitejs/vite@d785e72)) ## [v7.1.5](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-715-2025-09-08-small) ##### Bug Fixes - apply `fs.strict` check to HTML files ([#20736](vitejs/vite#20736)) ([14015d7](vitejs/vite@14015d7)) - **deps:** update all non-major dependencies ([#20732](vitejs/vite#20732)) ([122bfba](vitejs/vite@122bfba)) - upgrade sirv to 3.0.2 ([#20735](vitejs/vite#20735)) ([09f2b52](vitejs/vite@09f2b52))
renovate bot
added a commit
to andrei-picus-tink/auto-renovate
that referenced
this pull request
Sep 25, 2025
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.1.4 | 7.1.7 | ## [v7.1.7](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-717-2025-09-22-small) ##### Bug Fixes - **build:** fix ssr environment `emitAssets: true` when `sharedConfigBuild: true` ([#20787](vitejs/vite#20787)) ([4c4583c](vitejs/vite@4c4583c)) - **client:** use CSP nonce when rendering error overlay ([#20791](vitejs/vite#20791)) ([9bc9d12](vitejs/vite@9bc9d12)) - **deps:** update all non-major dependencies ([#20811](vitejs/vite#20811)) ([9f2247c](vitejs/vite@9f2247c)) - **glob:** handle glob imports from folders starting with dot ([#20800](vitejs/vite#20800)) ([105abe8](vitejs/vite@105abe8)) - **hmr:** trigger prune event when import is removed from non hmr module ([#20768](vitejs/vite#20768)) ([9f32b1d](vitejs/vite@9f32b1d)) - **hmr:** wait for `import.meta.hot.prune` callbacks to complete before running other HMRs ([#20698](vitejs/vite#20698)) ([98a3484](vitejs/vite@98a3484)) ## [v7.1.6](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-716-2025-09-18-small) ##### Bug Fixes - **deps:** update all non-major dependencies ([#20773](vitejs/vite#20773)) ([88af2ae](vitejs/vite@88af2ae)) - **esbuild:** inject esbuild helper functions with minified `$` variables correctly ([#20761](vitejs/vite#20761)) ([7e8e004](vitejs/vite@7e8e004)) - fallback terser to main thread when nameCache is provided ([#20750](vitejs/vite#20750)) ([a679a64](vitejs/vite@a679a64)) - **types:** strict env typings fail when `skipLibCheck` is `false` ([#20755](vitejs/vite#20755)) ([cc54e29](vitejs/vite@cc54e29)) ##### Miscellaneous Chores - **deps:** update rolldown-related dependencies ([#20675](vitejs/vite#20675)) ([a67bb5f](vitejs/vite@a67bb5f)) - **deps:** update rolldown-related dependencies ([#20772](vitejs/vite#20772)) ([d785e72](vitejs/vite@d785e72)) ## [v7.1.5](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-715-2025-09-08-small) ##### Bug Fixes - apply `fs.strict` check to HTML files ([#20736](vitejs/vite#20736)) ([14015d7](vitejs/vite@14015d7)) - **deps:** update all non-major dependencies ([#20732](vitejs/vite#20732)) ([122bfba](vitejs/vite@122bfba)) - upgrade sirv to 3.0.2 ([#20735](vitejs/vite#20735)) ([09f2b52](vitejs/vite@09f2b52))
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
p2-edge-case
Bug, but has workaround or limited in scope (priority)
regression
The issue only appears after a new release
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.
Glob imports from folders starting with a dot (e.g.,
./.foo/test.ts
) were failing in development mode with the error:The issue was in the
transformGlobImport
function where relative import and file paths were not being consistently formatted. When processing a glob pattern like./.foo/test.ts
, the relative path calculation would result in.foo/test.ts
. The existing logic only checked if the path started with.
to determine whether to add the./
prefix:Since
.foo/test.ts
already started with.
, it didn't receive the./
prefix, resulting in an invalid ES module import path that couldn't be resolved.Fixed by applying the refined condition to all affected patterns:
This ensures proper handling of all relative import patterns:
foo/bar.ts
get the./
prefix →./foo/bar.ts
./
remain unchanged →./foo/bar.ts
../
are preserved →../foo/bar.ts
(not./../foo/bar.ts
)./
prefix →.foo/bar.ts
→./.foo/bar.ts
Fixed Locations:
importPath
handling (original issue)/
)Testing:
packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/.foo/test.ts
)fixture-a/index.ts
:export const dotFolder = import.meta.glob('./.foo/*.ts', { eager: true })
(tests basic fix)export const dotFolderWithBase = import.meta.glob('./.foo/*.ts', { eager: true, base: './' })
(tests base option fix)import * as __vite_glob_XX_0 from "./.foo/test.ts"
The fix resolves the dot folder import issue across all code paths while preserving correct
../
path formatting and maintaining full backward compatibility.Fixes #20788.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.