[Bug]: import.meta.glob doesn’t resolve import alias
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
pnpm installpnpm run build:vite# Builds Successfullypnpm run build:rsbuild# 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 │ ╰─▶ });
╰────
Source: web-infra-dev/rspack