Describe the bug
When using import.meta.glob with eager: true it appears that the imports it generates are prepended to the current module imports, this causes side-effects to be executed in a non-intuitive order. (As per mui/base-ui#4370).
Reproduction
https://github.com/Janpot/vite-glob-side-effects-repro
Steps to reproduce
// ./a.ts
console.log('hello from a');
export {}
// ./b.ts
console.log('hello from b');
export {}
// ./main.ts
import './a';
const mods = import.meta.glob('./b.ts', { eager: true })
prints
hello from b
hello from a
System Info
System:
OS: macOS 14.6.1
CPU: (8) arm64 Apple M1
Memory: 107.45 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.11.1 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/node
npm: 11.6.2 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/npm
pnpm: 10.13.1 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/pnpm
Browsers:
Safari: 17.6
npmPackages:
@vitejs/plugin-react: ^6.0.1 => 6.0.1
vite: ^8.0.0 => 8.0.0
Used Package Manager
pnpm
Logs
No response
Validations
Describe the bug
When using
import.meta.globwitheager: trueit appears that the imports it generates are prepended to the current module imports, this causes side-effects to be executed in a non-intuitive order. (As per mui/base-ui#4370).Reproduction
https://github.com/Janpot/vite-glob-side-effects-repro
Steps to reproduce
prints
System Info
System: OS: macOS 14.6.1 CPU: (8) arm64 Apple M1 Memory: 107.45 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.11.1 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/node npm: 11.6.2 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/npm pnpm: 10.13.1 - /Users/janpotoms/.nvm/versions/node/v24.11.1/bin/pnpm Browsers: Safari: 17.6 npmPackages: @vitejs/plugin-react: ^6.0.1 => 6.0.1 vite: ^8.0.0 => 8.0.0Used Package Manager
pnpm
Logs
No response
Validations