Skip to content

[Bug]: import.meta.glob with absolute base resolves to wrong import path #9144

@kermanx

Description

@kermanx

Reproduction link or steps

  1. Clone https://github.com/kermanx/vite8-import-glob-repro
  2. cd app and pnpm install
  3. pnpm run dev --> Works fine, styles are applied
  4. pnpm run build or pnpm run build:rolldown --> Error:

What is expected?

Should build successfully.

What is actually happening?

[UNRESOLVED_IMPORT] Error: Could not resolve '../external/x.ts' in src/main.ts
  ╭─[ src/main.ts:1:38 ]
  │
1 │ import * as __import_glob__0_0_ from "../external/x.ts";/* #__PURE__ */ Object.assign({"../external/x.ts": __import_glob__0_0_
  │                                      ─────────┬────────  
  │                                               ╰────────── Module not found.
  │ 
  │ Help: 'src/main.ts' is imported by the following path:
  │         - src/main.ts
  │         - index.html
───╯

The path should be ../../external/x.ts

System Info

System:
    OS: Linux 6.17 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
    Memory: 11.02 GB / 31.06 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.4.0 - /run/user/1000/fnm_multishells/1639967_1776327306640/bin/node
    npm: 11.4.2 - /run/user/1000/fnm_multishells/1639967_1776327306640/bin/npm
    pnpm: 10.33.0 - /run/user/1000/fnm_multishells/1639967_1776327306640/bin/pnpm
    bun: 1.3.11 - /home/kerman/.bun/bin/bun
  Browsers:
    Firefox: 149.0.2
    Firefox Developer Edition: 149.0.2
  npmPackages:
    rolldown: 1.0.0-rc.15 => 1.0.0-rc.15 
    vite: ^8.0.8 => 8.0.8

Any additional comments?

This is an inconsistency with the Vite dev (and Vite7 build) behavior.

Related workaroud commits: slidevjs/slidev@055baa8 / slidevjs/slidev@29acd94

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Priority

None yet

Effort

None yet

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions