Skip to content

refactor(parser): pass SourceType to ModuleRecordBuilder#17610

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_
Jan 5, 2026
Merged

refactor(parser): pass SourceType to ModuleRecordBuilder#17610
graphite-app[bot] merged 1 commit intomainfrom
01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Jan 3, 2026

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

@github-actions github-actions bot added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 3, 2026
Copy link
Member Author

Sysix commented Jan 3, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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-hq
Copy link

codspeed-hq bot commented Jan 3, 2026

CodSpeed Performance Report

Merging #17610 will not alter performance

Comparing 01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_ (9394582) with main (3a0c782)

Summary

✅ 42 untouched
⏩ 3 skipped1

Footnotes

  1. 3 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.

@Sysix Sysix force-pushed the 01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_ branch from db8c69a to 9394582 Compare January 3, 2026 18:11
@Sysix Sysix requested a review from Copilot January 3, 2026 18:14
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 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.rs into ModuleRecordBuilder::errors() method
  • Updated ModuleRecordBuilder::new() to accept a SourceType parameter
  • 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.

@Sysix Sysix marked this pull request as ready for review January 3, 2026 18:17
@camc314
Copy link
Contributor

camc314 commented Jan 3, 2026

nice 🙂

Screenshot 2026-01-03 at 21 38 29

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jan 5, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 5, 2026

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
@graphite-app graphite-app bot force-pushed the 01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_ branch from 9394582 to 1c07942 Compare January 5, 2026 08:58
@camc314 camc314 self-assigned this Jan 5, 2026
@graphite-app graphite-app bot merged commit 1c07942 into main Jan 5, 2026
21 checks passed
@graphite-app graphite-app bot deleted the 01-03-refactor_parser_pass_sourcetype_to_modulerecordbuilder_ branch January 5, 2026 09:04
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants