Skip to content

feat: support JavaScript URL entries with factory type probes - #15666

Open
intellild wants to merge 12 commits into
mainfrom
codex/url-module-type-probe
Open

intellild wants to merge 12 commits into
mainfrom
codex/url-module-type-probe

Conversation

@intellild

@intellild intellild commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Motivation

Support new URL(..., import.meta.url) references to JavaScript modules through explicit module rules, while preserving the default asset behavior. CSS URL entries are handled separately in #15737 (draft, stacked on this PR).

The dependency layout must be decided during the issuer's build, before the module is shared and written to the module build cache. For example, new URL('./target', import.meta.url) may initially resolve to target.js, then resolve to target.txt after the JavaScript file is removed. An unchanged issuer must not retain an async entry for the former target type.

Changes

  • After the synchronous JavaScript scan, use the registered module factory to probe each URL target. Inspect its module type and discard the temporary module without building it.
  • Promote JavaScript targets into async entry blocks, including URLs inside nested parser-created async blocks. Keep each URL entry under its original parent block. Assets, externals, ignored targets, and other module types retain their existing dependency handling.
  • Share the registered factory map through Arc<BuildContext>, using the BuildContext refactor merged in refactor(core): share BuildContext across module graph tasks #15674.
  • Include the probe's file, context, and missing dependencies in the issuer's build information so target-type changes invalidate both watch rebuilds and ordinary module-cache builds.
  • Let normal factorization report probe failures with the usual diagnostics and bail behavior.
  • Generate JavaScript entry URLs for all URL parser modes while preserving ordinary asset URLs and tree shaking.
  • Add regression tests and English/Chinese documentation. No module defaultRules changes or URL promotion hook.

The probe is an additional factory call: normal factorization still runs afterward, so factory hooks run twice, but the probe does not run the target's build/loaders.

Usage example

module.exports = {
  module: {
    rules: [
      { test: /\.js$/, dependency: 'url', type: 'javascript/auto' },
    ],
  },
};
const scriptUrl = new URL('./script.js', import.meta.url);

Creating the URL does not execute the script, including when the URL is created inside nested require.ensure callbacks. It can be used later, for example with <script src>. Without an explicit matching URL rule, the target retains the default asset behavior.

Validation

  • Rebased onto main at 943350fa79, including nested async dependency block support from feat: support nested async dependency blocks #15741.
  • pnpm run build:cli:dev passed.
  • URL config cases passed in ordinary and runtime modes, including the new two-level require.ensure regression across all three URL parser modes. Assertions cover nested block ownership, emitted URLs, asset fallback, and non-execution of target scripts.
  • URL watch cases (ordinary and incremental), module-type probe cache invalidation, chunk cases, worker cases, and nested-block watch cases passed, excluding cases filtered by the existing harness.
  • cargo clippy -p rspack_core -p rspack_plugin_javascript --lib -- -D warnings passed.
  • Rust formatting, diff checks, and commit hooks passed.
  • Storage and native-watcher suites were not run.

by OpenAI Codex

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 8b1676b to feat: support nested async dependency blocks (#15741) by AsyncIter

🎉 Size decreased by 4.00KB from 68.97MB to 68.96MB (⬇️0.01%)

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

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.8 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 5.0 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 2.25%

❌ 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.5 ms 7.7 ms -2.25%

Tip

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


Comparing codex/url-module-type-probe (8b1676b) with main (943350f)

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 force-pushed the codex/url-module-type-probe branch from 3eed5e9 to ea596dc Compare September 14, 2026 14:50
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 14, 2026

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 865be7e
Status: ✅  Deploy successful!
Preview URL: https://9a4bad79.rspack-v2.pages.dev
Branch Preview URL: https://codex-url-module-type-probe.rspack-v2.pages.dev

View logs

@intellild
intellild changed the base branch from main to codex/reuse-build-context September 14, 2026 14:51
@intellild
intellild added this pull request to stack #15676 September 14, 2026 14:51
@intellild
intellild force-pushed the codex/url-module-type-probe branch from 661d6b4 to 3c8aaf0 Compare September 15, 2026 02:29
Base automatically changed from codex/reuse-build-context to main September 15, 2026 04:49
@intellild
intellild force-pushed the codex/url-module-type-probe branch from c23c075 to fff7f98 Compare September 15, 2026 04:49
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 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-09-18T10:41:20.155681Z 8b1676b Manual request
ℹ️ 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: fff7f981a1

ℹ️ 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_plugin_javascript/src/dependency/url/mod.rs Outdated
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 95a67edf81

ℹ️ 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_plugin_javascript/src/dependency/url/mod.rs Outdated
Comment thread crates/rspack_plugin_javascript/src/parser_and_generator/url.rs Outdated
@intellild
intellild marked this pull request as ready for review September 15, 2026 10:41
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@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: b7521d1b0c

ℹ️ 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_plugin_javascript/src/dependency/url/mod.rs Outdated
@intellild intellild changed the title feat: support JavaScript and CSS URL entries with factory type probes feat: support JavaScript URL entries with factory type probes Sep 17, 2026

@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: 4006dedda1

ℹ️ 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_plugin_javascript/src/parser_and_generator/url.rs
@intellild

Copy link
Copy Markdown
Contributor Author

blocked by #15741

@intellild
intellild force-pushed the codex/url-module-type-probe branch from 4006ded to 865be7e Compare September 18, 2026 09:13
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@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: e10638a52b

ℹ️ 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_plugin_javascript/src/dependency/url/mod.rs Outdated
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 8b1676b1da

ℹ️ 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".

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