Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions crates/oxc_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl<'a> ParserImpl<'a> {
state: ParserState::new(),
ctx: Self::default_context(source_type, options),
ast: AstBuilder::new(allocator),
module_record_builder: ModuleRecordBuilder::new(allocator),
module_record_builder: ModuleRecordBuilder::new(allocator, source_type),
is_ts: source_type.is_typescript(),
}
}
Expand Down Expand Up @@ -466,13 +466,11 @@ impl<'a> ParserImpl<'a> {
}
let (module_record, module_record_errors) = self.module_record_builder.build();
if errors.len() != 1 {
errors.reserve(self.lexer.errors.len() + self.errors.len());
errors
.reserve(self.lexer.errors.len() + self.errors.len() + module_record_errors.len());
errors.extend(self.lexer.errors);
errors.extend(self.errors);
// Skip checking for exports in TypeScript {
if !self.source_type.is_typescript() {
errors.extend(module_record_errors);
}
errors.extend(module_record_errors);
}
let irregular_whitespaces =
self.lexer.trivia_builder.irregular_whitespaces.into_boxed_slice();
Expand Down
9 changes: 8 additions & 1 deletion crates/oxc_parser/src/module_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ use crate::diagnostics;

pub struct ModuleRecordBuilder<'a> {
allocator: &'a Allocator,
source_type: SourceType,
module_record: ModuleRecord<'a>,
export_entries: Vec<'a, ExportEntry<'a>>,
exported_bindings_duplicated: Vec<'a, NameSpan<'a>>,
}

impl<'a> ModuleRecordBuilder<'a> {
pub fn new(allocator: &'a Allocator) -> Self {
pub fn new(allocator: &'a Allocator, source_type: SourceType) -> Self {
Self {
allocator,
source_type,
module_record: ModuleRecord::new(allocator),
export_entries: Vec::new_in(allocator),
exported_bindings_duplicated: Vec::new_in(allocator),
Expand All @@ -35,6 +37,11 @@ impl<'a> ModuleRecordBuilder<'a> {
pub fn errors(&self) -> std::vec::Vec<OxcDiagnostic> {
let mut errors = vec![];

// Skip checking for exports in TypeScript
if self.source_type.is_typescript() {
return errors;
}

let module_record = &self.module_record;

// It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
Expand Down
2 changes: 1 addition & 1 deletion tasks/track_memory_allocations/allocs_parser.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ File | File size || Sys allocs | Sys reallocs |
-------------------------------------------------------------------------------------------------------------------------------------------
checker.ts | 2.92 MB || 9672 | 21 || 267681 | 22847

cal.com.tsx | 1.06 MB || 2211 | 62 || 138162 | 13699
cal.com.tsx | 1.06 MB || 1083 | 49 || 138162 | 13699

RadixUIAdoptionSection.jsx | 2.52 kB || 1 | 0 || 365 | 66

Expand Down
Loading