-
-
Notifications
You must be signed in to change notification settings - Fork 757
refactor: replace SourceFile with &str and replace Arc<SourceMap> with Rope in rspack_plugin_javascript
#12404
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.
|
📦 Binary Size-limit
❌ Size increased by 6.50KB from 47.71MB to 47.72MB (⬆️0.01%) |
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
CodSpeed Performance ReportMerging #12404 will not alter performanceComparing Summary
|
684abaf to
b2658db
Compare
cf7bdbf to
8456e0d
Compare
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 JavaScript plugin to replace SourceFile with &str and Arc<SourceMap> with Rope for better performance in span-to-location conversions. It also converts column calculations from 0-based [start, end) to 1-based [start, end] format.
Key changes include:
- Replacing
Arc<SourceMap>withRopedata structure for efficient line/column lookups - Changing parser to accept
&strinstead ofSourceFile - Implementing
SourceLocationtrait forRopeto convert byte offsets to line/column positions - Updating all test snapshots to reflect the 1-based column numbering
Reviewed changes
Copilot reviewed 107 out of 108 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_core/src/dependency/dependency_location.rs |
Implements SourceLocation for Rope, converts SharedSourceMap to use Rope |
crates/rspack_plugin_javascript/src/visitors/dependency/parser/mod.rs |
Replaces source_file: &SourceFile with source: &str, adds lazy Rope initialization |
crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs |
Removes SourceMap creation, passes source string directly to parser |
crates/rspack_plugin_javascript/src/visitors/dependency/util.rs |
Updates error creation to accept String instead of &SourceFile |
crates/rspack_location/src/lib.rs |
Removes from_span methods that depended on SourceMap |
| Various parser plugin files | Updates all plugins to use source_rope() instead of source_map |
| Test snapshot files | Updates all location formats from 0-based to 1-based column numbering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
📝 Benchmark detail: Open
Threshold exceeded: ["large-dyn-imports_production-mode + exec"] |
Summary
SourceFilewith&str. From my observation, theSourceFileis used for diagnostic generation, and only its source string is used.Arc<SourceMap>withRope.Arc<SourceMap>is only used for transformation betweenSpans and line-column positions. I'd like to see if theRopeimplementation is more performant thanArc<SourceMap>[start, end)-> 1-based[start, end]If this pr is meaningful, I will also refactor other parts of
JavascriptCompiler.This pr is also a part of work to integrate
swc_experimentalChecklist