Skip to content

Conversation

@JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Jan 4, 2026

Summary

Replace the closure-based UsageCallback pattern in InnerGraphPlugin::on_usage with an InnerGraphUsageOperation enum for better performance and code clarity.

Changes:

  • Add InnerGraphUsageOperation enum with three variants:
    • PureExpression(DependencyRange)
    • ESMImportSpecifier(usize)
    • URLDependency(usize)
  • Update on_usage to accept enum instead of closure
  • Update infer_dependency_usage to match on enum variants
  • Update 11 call sites across plugin.rs, esm_import_dependency_parser_plugin.rs, and url_plugin.rs

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 4, 2026 11:20
@netlify
Copy link

netlify bot commented Jan 4, 2026

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 6aad2c9
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/695b6b8c5d489b000804e2b3

@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Jan 4, 2026
@JSerFeng JSerFeng enabled auto-merge (squash) January 4, 2026 11:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the InnerGraphPlugin to replace a closure-based callback pattern with a more performant enum-based approach. The change improves code clarity and eliminates heap allocations for closures while maintaining the same functional behavior.

  • Introduces InnerGraphUsageOperation enum with three variants representing different dependency operations
  • Updates on_usage to accept an enum instead of a boxed closure
  • Refactors infer_dependency_usage to match on enum variants and execute the appropriate logic

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/rspack_plugin_javascript/src/parser_plugin/inner_graph/state.rs Defines new InnerGraphUsageOperation enum with variants for PureExpression, ESMImportSpecifier, and URLDependency operations; updates usage_callback_map type signature
crates/rspack_plugin_javascript/src/parser_plugin/inner_graph/plugin.rs Updates on_usage method to accept enum; refactors infer_dependency_usage to match on enum variants; converts 7 call sites from closures to enum variants
crates/rspack_plugin_javascript/src/parser_plugin/esm_import_dependency_parser_plugin.rs Converts 4 call sites from closure-based callbacks to ESMImportSpecifier enum variant
crates/rspack_plugin_javascript/src/parser_plugin/url_plugin.rs Converts 1 call site from closure-based callback to URLDependency enum variant

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (cd97e3bb37) does not have baseline artifacts. Using commit 6a1fbdd59c 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 Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

📦 Binary Size-limit

Comparing 6aad2c9 to chore: limit workers for loader parallel tests (#12620) by CPunisher

🎉 Size decreased by 3.63KB from 47.87MB to 47.87MB (⬇️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 4, 2026

CodSpeed Performance Report

Merging #12619 will not alter performance

Comparing refactor/used-by-exports (6aad2c9) with main (6a1fbdd)1

Summary

✅ 16 untouched
⏩ 1 skipped2

Footnotes

  1. No successful run was found on main (fc645a0) during the generation of this report, so 6a1fbdd was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@JSerFeng
Copy link
Contributor Author

JSerFeng commented Jan 5, 2026

@cursor fix the clippy and rename usage_callback_map to usage_op_map

@cursor
Copy link

cursor bot commented Jan 5, 2026

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@JSerFeng JSerFeng force-pushed the refactor/used-by-exports branch 2 times, most recently from 95a1b0d to d33a4c6 Compare January 5, 2026 06:56
… enum

Replace the closure-based UsageCallback pattern in InnerGraphPlugin::on_usage
with an InnerGraphUsageOperation enum for better performance and code clarity.

Changes:
- Add InnerGraphUsageOperation enum with three variants:
  - PureExpression(DependencyRange)
  - ESMImportSpecifier(usize)
  - URLDependency(usize)
- Update on_usage to accept enum instead of closure
- Update infer_dependency_usage to match on enum variants
- Update 11 call sites across plugin.rs, esm_import_dependency_parser_plugin.rs,
  and url_plugin.rs
@JSerFeng JSerFeng force-pushed the refactor/used-by-exports branch from d33a4c6 to 6aad2c9 Compare January 5, 2026 07:43
@JSerFeng JSerFeng merged commit 42c39a2 into main Jan 5, 2026
52 checks passed
@JSerFeng JSerFeng deleted the refactor/used-by-exports branch January 5, 2026 08:53
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants