Skip to content

import.meta.glob inconsistency between dev and build #22166

@DominikRusso

Description

@DominikRusso

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

  1. run pnpm install
  2. run pnpm dev and visit http://localhost:5173
  3. only escaped will be populated
  4. run pnpm build followed by pnpm preview and visit http://localhost:4173
  5. 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

Metadata

Metadata

Assignees

Labels

bug: upstreamBug in a dependency of ViteinconsistencyInconsistency between dev & build

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions