#15894·rspack

[Bug]: import.meta.glob doesn’t resolve import alias

Author: futursoloCreated Sep 26, 2026Updated Sep 28, 2026

System Info

System: OS: Linux 7.2 cpe:/o:nixos:nixos:26.05 26.05 (Yarara) CPU: (128) x64 AMD EPYC 7C13 64-Core Processor Memory: 494.91 GB / 503.50 GB Container: Yes Shell: 5.9.1 - /run/current-system/sw/bin/zsh Binaries: Node: 26.7.0 - [REDACTED] npm: 11.19.0 - [REDACTED] pnpm: 10.33.2 - [REDACTED] npmPackages: @rspack/cli: ^2.2.7 => 2.2.7 @rspack/core: ^2.2.7 => 2.2.7 @rspack/dev-server: ^2.2.1 => 2.2.1

Details

import.meta.glob should support resolve.alias.

Vite resolves this correctly. Rsbuild needs to use import.meta.webpackContext if one needs globbing with alias.

Vite also supports globbing from other packages if the alias resolves to another package in a mono workspace.

Reproduce link

https://github.com/futursolo/rspack-import-meta-glob-repro

Reproduce Steps

  1. pnpm install
  2. pnpm run build:vite
  3. # Builds Successfully
  4. pnpm run build:rsbuild
  5. # The following error is produced
info    build started...
error   Build error: 
File: ./src/index.js:1:1
  × Module not found: Can't resolve './@/glob-imports/' in '[project dir]/rspack-import-meta-glob-repro/src'
   ╭─[2:0]
 2 │         exports.render();
 3 │     });
 4 │ ╭─▶ export const importedModules = import.meta.glob("@/glob-imports/*.js", {
 5 │ │       eager: true
 6 │ ╰─▶ });
   ╰────