Back to all fixes
CuratedTypeScriptVite 8local
import.meta.glob fails in Vite 8 build for directories with parentheses, e.g. "./(dir)/*.js"
Problem
`import.meta.glob("./(dir)/*.js", { eager: true })` (a directory literally named with parentheses) works in dev but fails to match any files during `vite build`. The build-mode glob implementation is a native Rust plugin that only supports basic glob syntax (`?`, `*`, `**`, `[]`, `{}`) and does not treat backslash-escaped parens the same way dev mode does.
Solution
typescript
A Vite maintainer (shulaoda) confirmed the immediate workaround: rewrite the pattern to avoid parens entirely using a bracket character class, which the native build-mode glob does support:
```js
import.meta.glob("./[(]dir[)]/*.js", { eager: true })
```
The maintainer also stated the backslash-escaped form `\\(dir\\)` should be fixed to work consistently between dev and build going forward, but the bracket-class form above is the confirmed working pattern today regardless of that fix landing.