Skip to content

fix: handle import.meta.glob alias edge cases - #16017

Draft
intellild wants to merge 3 commits into
mainfrom
codex/import-meta-glob-alias-fixes
Draft

intellild wants to merge 3 commits into
mainfrom
codex/import-meta-glob-alias-fixes

Conversation

@intellild

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #15898. Resolving aliases from the compiled scan request loses information needed by negative patterns, mixed patterns, and caseSensitive: false.

For example, with @ -> <root>/src:

import.meta.glob(
  ["@/pages/*.js", "!@/**/excluded.js"],
  { eager: true },
);

Previously, only the positive pattern was rewritten, so excluded.js was still imported. Alias targets such as src/[dir] were also interpreted as glob syntax, and alias: { dir: [] } incorrectly changed a local dir/*.js request into a module request.

Changes

  • Resolve aliases independently in each original positive and negative pattern, then recompute the common scan directory. This also supports mixed alias/relative patterns and case-insensitive directory matching.
  • Escape literal resolved directories while preserving the pattern suffix's glob syntax, and skip empty alias entries.
  • Reuse one dependency resolver for alias prefixes and the final scan directory, eliminating a duplicate resolver lookup and options clone. Cache each alias-prefix resolution within the glob so positive and negative patterns share it.
  • Extend the existing config case with regression coverage, including *.mjs with ?raw, ignored/exact aliases, and explicit ./@/... paths. Update English and Chinese docs.

Validation: binding and JS builds; context config suites in standard/runtime modes (62 passed); existing normal context suites (100 passed); cargo clippy -p rspack_core --all-targets -- --deny warnings; formatting and pre-commit checks.


by OpenAI Codex

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: edb990d
Status: ✅  Deploy successful!
Preview URL: https://47db4907.rspack-v2.pages.dev
Branch Preview URL: https://codex-import-meta-glob-alias.rspack-v2.pages.dev

View logs

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing f079885 to perf(sources): release generated value after static source map (#16022) by Cong-Cong Pan

❌ Size increased by 20.00KB from 67.19MB to 67.21MB (⬆️0.03%)

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (33500069122f5da1efbd76b9ba8410639d666eeb) does not have baseline artifacts. Using commit 84939462e581debce61c0820aba1f71dfe19d00a for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 529.6 KB 0 0
react-10k 5.4 MB 1.3 MB 0 0
react-1k 827.7 KB 226.6 KB 0 0
react-5k 2.6 MB 670.9 KB 0 0
ui-components 4.7 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 2.04%

❌ 1 regressed benchmark
✅ 53 untouched benchmarks
⏩ 47 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ rust@create_module_hashes 7 ms 7.2 ms -2.04%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/import-meta-glob-alias-fixes (f079885) with main (8493946)

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. ↩

@intellild
intellild marked this pull request as ready for review October 9, 2026 06:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T07:11:36.250566Z f079885 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: edb990d853

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_core/src/context_module_factory/glob.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6ed684b75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_core/src/context_module_factory.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f07988586f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +588 to +592
if *query != resource.query {
query.clear();
}
if *fragment != resource.fragment {
fragment.clear();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve suffixes for each aliased pattern

When positive patterns use aliases with different queries or fragments (for example, raw -> dirA?raw and url -> dirB?url), this merge clears the differing component and the context subsequently applies the final scan directory's suffix—usually empty—to every matched module. Although the new common-suffix handling fixes the single/common-alias case, this means loaders for both patterns lose their alias-specific resource suffixes; these patterns need separate suffix handling, such as separate contexts or per-match metadata.

Useful? React with 👍 / 👎.

@intellild
intellild marked this pull request as draft October 10, 2026 08:33
@intellild intellild changed the title fix: handle import.meta.glob alias edge cases refactor(glob): handle import.meta.glob alias edge cases Oct 13, 2026
@intellild intellild changed the title refactor(glob): handle import.meta.glob alias edge cases fix: handle import.meta.glob alias edge cases Oct 13, 2026

This branch has not been deployed

No deployments
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.

1 participant