Skip to content

Cannot glob import from folders starting with dot #20788

@lassebomh

Description

@lassebomh

Describe the bug

In development mode, if you cannot glob import from a folder that starts with a dot and is a sibling to script that is importing.

Specifically, if this is the directory structure:

Image

And main.ts contains:

console.log(import.meta.glob("./foo/test.ts"));
console.log(import.meta.glob("./inner/.foo/test.ts"));
console.log(import.meta.glob("./.foo/test.ts"));

Then all of them will work, except for the last glob import:

Failed to resolve import ".foo/test.ts" from "src/main.ts". Does the file exist?

It isn't affected by writing it as an absolute path, and is specific to development mode.

The bug was introduced in 7.1.0-beta.1 and has been present in all releases after, presumably because of #20528.

Reproduction

https://github.com/lassebomh/vite-glob-bug

Steps to reproduce

pnpm install && pnpm run dev and you should see the error in the browser.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 9 6900HS with Radeon Graphics
    Memory: 14.32 GB / 31.25 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.3 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (140.0.3485.54)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    vite: 7.1.0-beta.1 => 7.1.0-beta.1

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

p2-edge-caseBug, but has workaround or limited in scope (priority)regressionThe issue only appears after a new release

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions