Skip to content

fix: resolve aliases in import.meta.glob patterns - #15898

Merged
intellild merged 2 commits into
web-infra-dev:mainfrom
aryan1306:fix/import-meta-glob-resolve-alias
Oct 8, 2026
Merged

intellild merged 2 commits into
web-infra-dev:mainfrom
aryan1306:fix/import-meta-glob-resolve-alias

Conversation

@aryan1306

@aryan1306 aryan1306 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Fixes #15894. import.meta.glob("@/glob-imports/*.js") currently treats the alias as a relative directory and fails to resolve ./@/glob-imports/.

Changes

  • Resolve bare glob prefixes through the normal module resolver, including resolve.alias.
  • Match glob patterns against the resolved directory while preserving root-relative keys for files under the compiler context and honoring negative patterns.
  • Add a regression case for an aliased glob with an exclusion and document alias pattern behavior in English and Chinese.

Verified with the new config case in standard and runtime mode, the existing normalCases/context/import-meta-glob suite, and the repository pre-commit checks.

Generated by the Codex AI agent.

@intellild
intellild self-requested a review September 28, 2026 01:59
@intellild

Copy link
Copy Markdown
Contributor

@codex review

@codspeed

codspeed Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 54 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing aryan1306:fix/import-meta-glob-resolve-alias (4609bce) with main (91807e9)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@aryan1306

Copy link
Copy Markdown
Contributor Author

@intellild just a friendly nudge is anything else required or is anything blocking from my side for this PR?

@intellild

Copy link
Copy Markdown
Contributor

@intellild just a friendly nudge is anything else required or is anything blocking from my side for this PR?

Thanks for contributing. I am looking into some edge cases which may break existing users.

@aryan1306
aryan1306 force-pushed the fix/import-meta-glob-resolve-alias branch from e439933 to 4114242 Compare October 2, 2026 17:44
Comment thread crates/rspack_core/src/context_module_factory/glob.rs
Only drop the leading './' from a bare import.meta.glob request when its
prefix matches a resolve.alias key. Unaliased bare patterns (dir/*.js) and
query-only requests (*.mjs with ?raw) resolve relative to the importer as
before.
@intellild

Copy link
Copy Markdown
Contributor

@codex review

@aryan1306
aryan1306 requested a review from intellild October 8, 2026 09:41
@intellild
intellild merged commit a2c19bc into web-infra-dev:main Oct 8, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants