Skip to content

[v8] import.meta.glob with resolve.alias does not produce files in production #22193

@imjasonmiller

Description

@imjasonmiller

Describe the bug

It might be a case of me holding it wrong (hopefully), but I've been using the experimental version of vite@7.x with Rolldown for quite some time, but when moving to vite@8.0.7 my icon imports failed to produce icon files in the production build.

From what I could tell it seems to no longer produce files when a custom resolve.alias is used, even though the documentation states this is fine:

The glob patterns are treated like import specifiers: they must be ... or an alias path (see resolve.alias option).

As shown in the reproduction, the below seems to work in dev mode and produces files with npm run build:

import.meta.glob([
     './../../assets/icons/*.svg',
])
Build 1. output
✓ 18 modules transformed.
computing gzip size...
dist/index.html                                    0.55 kB │ gzip:  0.34 kB
dist/assets/index-TZrNw7dA.css                     0.01 kB │ gzip:  0.03 kB
dist/assets/red-BepeEtnz.js                        0.29 kB │ gzip:  0.24 kB
dist/assets/blue-DWrjRoGJ.js                       0.29 kB │ gzip:  0.24 kB
dist/assets/green-DreAtH0R.js                      0.29 kB │ gzip:  0.24 kB
dist/assets/index-D7mQFbHq.js                      8.62 kB │ gzip:  3.87 kB
dist/assets/runtime-core.esm-bundler-BBKSmmss.js  54.22 kB │ gzip: 21.36 kB

✓ built in 526ms

While the following works in dev mode, but fails to produce files after running npm run build:

import.meta.glob([
    '@customIcons/*.svg',
])
Build 2. output
✓ 14 modules transformed.
computing gzip size...
dist/index.html                  0.45 kB │ gzip:  0.30 kB
dist/assets/index-TZrNw7dA.css   0.01 kB │ gzip:  0.03 kB
dist/assets/index-iHsm0tXg.js   60.94 kB │ gzip: 24.16 kB

✓ built in 449ms

Reproduction

https://stackblitz.com/edit/vitejs-vite-h33s9nrs?file=src%2Fcomponents%2Ficon%2FIcon.vue

Steps to reproduce

  1. npm install
  2. Uncomment (or comment) either 1. or 2. in Icon.vue in import.meta.glob and AsyncIconComponent
  3. Run npm run dev and npm run build to see the differences in build output.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^6.0.5 => 6.0.5 
    vite: ^8.0.7 => 8.0.7

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

bug: upstreamBug in a dependency of ViteinconsistencyInconsistency between dev & buildp3-minor-bugAn edge case that only affects very specific usage (priority)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions