refactor(parser): pass SourceType to ModuleRecordBuilder#17610
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #17610 will not alter performanceComparing Summary
Footnotes
|
db8c69a to
9394582
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the parser to pass SourceType to ModuleRecordBuilder, enabling it to manage TypeScript-related error filtering internally rather than at the call site. This improves performance by skipping diagnostic generation for TypeScript files early in the process.
- Moved TypeScript checking logic from
lib.rsintoModuleRecordBuilder::errors()method - Updated
ModuleRecordBuilder::new()to accept aSourceTypeparameter - Simplified error collection logic in the parser by removing conditional TypeScript checks
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_parser/src/module_record.rs | Added source_type field to ModuleRecordBuilder and implemented early return in errors() method for TypeScript files |
| crates/oxc_parser/src/lib.rs | Updated constructor call to pass source_type and simplified error collection by removing TypeScript conditional checks |
| tasks/track_memory_allocations/allocs_parser.snap | Reflects performance improvement with ~51% reduction in system allocations for TypeScript files (cal.com.tsx) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Passing `SourceType` to `ModuleRecordBuilder`, so it can manage its errors itself. Before all errors were collected and later checked if this is a typescript file. Now it will skip the generation of the diagnostic (performance). This refactoring is needed for TS error 1363 (see downstream PR), where we WANT diagnostics for typescript files
9394582 to
1c07942
Compare


Passing
SourceTypetoModuleRecordBuilder, so it can manage its errors itself.Before all errors were collected and later checked if this is a typescript file.
Now it will skip the generation of the diagnostic (performance).
This refactoring is needed for TS error 1363 (see downstream PR), where we WANT diagnostics for typescript files