-
-
Notifications
You must be signed in to change notification settings - Fork 754
refactor: replace UsageCallback closure with InnerGraphUsageOperation enum #12619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this 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
InnerGraphUsageOperationenum with three variants representing different dependency operations - Updates
on_usageto accept an enum instead of a boxed closure - Refactors
infer_dependency_usageto 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.
Rsdoctor Bundle Diff Analysis
Found 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🎉 Size decreased by 3.63KB from 47.87MB to 47.87MB (⬇️0.01%) |
CodSpeed Performance ReportMerging #12619 will not alter performanceComparing Summary
Footnotes
|
|
@cursor fix the clippy and rename |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
95a1b0d to
d33a4c6
Compare
… 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
d33a4c6 to
6aad2c9
Compare
Summary
Replace the closure-based UsageCallback pattern in InnerGraphPlugin::on_usage with an InnerGraphUsageOperation enum for better performance and code clarity.
Changes:
Related links
Checklist