Describe the bug
In vite v8 import.meta.glob behaves differently in dev and build for directories that contain parenthesis (which is used in SvelteKit for example).
In dev mode parenthesis must be escaped, in build mode they must not be escaped.
In this example (from the reproduction repo)
const escaped = import.meta.glob("./\\(dir\\)/*.js", { eager: true })
const unescaped = import.meta.glob("./(dir)/*.js", { eager: true })
escaped will be populated only in dev mode
unescaped will be populated only in build mode
Reproduction
https://github.com/DominikRusso/vite-glob-paren-repro
Steps to reproduce
- run
pnpm install
- run
pnpm dev and visit http://localhost:5173
- only
escaped will be populated
- run
pnpm build followed by pnpm preview and visit http://localhost:4173
- only
unescaped will be populated
System Info
System:
OS: macOS 26.4
CPU: (10) arm64 Apple M4
Memory: 464.78 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 25.9.0 - /opt/homebrew/bin/node
npm: 11.12.1 - /opt/homebrew/bin/npm
pnpm: 10.33.0 - /opt/homebrew/bin/pnpm
Deno: 2.7.11 - /opt/homebrew/bin/deno
Browsers:
Chrome: 146.0.7680.178
Firefox: 148.0
Safari: 26.4
npmPackages:
vite: 8.0.5 => 8.0.5
Used Package Manager
pnpm
Logs
No response
Validations
Describe the bug
In vite v8
import.meta.globbehaves differently in dev and build for directories that contain parenthesis (which is used in SvelteKit for example).In dev mode parenthesis must be escaped, in build mode they must not be escaped.
In this example (from the reproduction repo)
escapedwill be populated only in dev modeunescapedwill be populated only in build modeReproduction
https://github.com/DominikRusso/vite-glob-paren-repro
Steps to reproduce
pnpm installpnpm devand visithttp://localhost:5173escapedwill be populatedpnpm buildfollowed bypnpm previewand visithttp://localhost:4173unescapedwill be populatedSystem Info
System: OS: macOS 26.4 CPU: (10) arm64 Apple M4 Memory: 464.78 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 25.9.0 - /opt/homebrew/bin/node npm: 11.12.1 - /opt/homebrew/bin/npm pnpm: 10.33.0 - /opt/homebrew/bin/pnpm Deno: 2.7.11 - /opt/homebrew/bin/deno Browsers: Chrome: 146.0.7680.178 Firefox: 148.0 Safari: 26.4 npmPackages: vite: 8.0.5 => 8.0.5Used Package Manager
pnpm
Logs
No response
Validations