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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tasks/track_memory_allocations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ doctest = false
oxc_allocator = { workspace = true, features = ["track_allocations"] }
oxc_minifier = { workspace = true }
oxc_parser = { workspace = true }
oxc_semantic = { workspace = true }
oxc_tasks_common = { workspace = true }
oxc_transformer = { workspace = true }

humansize = { workspace = true }
mimalloc-safe = { workspace = true }
Expand Down
8 changes: 7 additions & 1 deletion tasks/track_memory_allocations/allocs_minifier.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
File | File size || Sys allocs | Sys reallocs || Arena allocs | Arena reallocs | Arena bytes
-------------------------------------------------------------------------------------------------------------------------------------------
RadixUIAdoptionSection.jsx | 2.52 kB || 75 | 4 || 20 | 6 | 688 B
checker.ts | 2.92 MB || 84073 | 14190 || 153691 | 29463 | 5.625 MB

cal.com.tsx | 1.06 MB || 40525 | 3033 || 37074 | 4733 | 1.654 MB

RadixUIAdoptionSection.jsx | 2.52 kB || 82 | 8 || 30 | 6 | 992 B

pdf.mjs | 567.30 kB || 19577 | 2900 || 47405 | 7784 | 1.625 MB

antd.js | 6.69 MB || 99854 | 13518 || 331725 | 70117 | 17.407 MB

binder.ts | 193.08 kB || 4768 | 974 || 7059 | 834 | 201.192 kB

27 changes: 18 additions & 9 deletions tasks/track_memory_allocations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use mimalloc_safe::MiMalloc;
use oxc_allocator::Allocator;
use oxc_minifier::{CompressOptions, MangleOptions, Minifier, MinifierOptions};
use oxc_parser::{ParseOptions, Parser};
use oxc_semantic::SemanticBuilder;
use oxc_tasks_common::{TestFiles, project_root};
use oxc_transformer::{TransformOptions, Transformer};

use std::alloc::{GlobalAlloc, Layout};
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
Expand Down Expand Up @@ -145,10 +147,15 @@ pub fn run() -> Result<(), io::Error> {
let mut parsed = Parser::new(&allocator, &file.source_text, file.source_type)
.with_options(parse_options)
.parse();
// Minifier cannot process TypeScript
if file.source_type.is_javascript() {
Minifier::new(minifier_options.clone()).minify(&allocator, &mut parsed.program);
}

// Transform TypeScript to ESNext before minifying (minifier only works on esnext)
let scoping = SemanticBuilder::new().build(&parsed.program).semantic.into_scoping();
let transform_options = TransformOptions::from_target("esnext").unwrap();
let _ =
Transformer::new(&allocator, std::path::Path::new(&file.file_name), &transform_options)
.build_with_scoping(scoping, &mut parsed.program);

Minifier::new(minifier_options.clone()).minify(&allocator, &mut parsed.program);
}

for file in files.files() {
Expand All @@ -171,12 +178,14 @@ pub fn run() -> Result<(), io::Error> {
width,
));

let before_minify_stats = record_stats(&allocator);
// Transform TypeScript to ESNext before minifying (minifier only works on esnext)
let scoping = SemanticBuilder::new().build(&parsed.program).semantic.into_scoping();
let transform_options = TransformOptions::from_target("esnext").unwrap();
let _ =
Transformer::new(&allocator, std::path::Path::new(&file.file_name), &transform_options)
.build_with_scoping(scoping, &mut parsed.program);

// Minifier cannot process TypeScript
if !file.source_type.is_javascript() {
continue;
}
let before_minify_stats = record_stats(&allocator);

Minifier::new(minifier_options).minify(&allocator, &mut parsed.program);

Expand Down
Loading