Skip to content

fix(tasks/allocations): before minification, transform to esnext and update minifier examples#13453

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-c4e04d0e-bb76-45e9-b375-320a6e369b6b
Closed

fix(tasks/allocations): before minification, transform to esnext and update minifier examples#13453
Copilot wants to merge 4 commits intomainfrom
copilot/fix-c4e04d0e-bb76-45e9-b375-320a6e369b6b

Conversation

Copy link
Contributor

Copilot AI commented Aug 30, 2025

This PR fixes the memory allocation tracking task by transforming TypeScript to ESNext before minification and updates the minifier examples to handle TypeScript files correctly.

Problem

The memory allocation tracking task in tasks/track_memory_allocations was skipping TypeScript files during minification because the minifier only works on ESNext JavaScript. Additionally, the minifier examples couldn't process TypeScript files, limiting their usefulness for testing and demonstration purposes.

Solution

Memory Allocation Tracking:

  • Added oxc_semantic and oxc_transformer dependencies to enable TypeScript transformation
  • Transform TypeScript to ESNext before minification in both warm-up and measurement loops
  • All test files now go through the full minification pipeline consistently

Minifier Examples Enhancement:

  • Updated minifier.rs and dce.rs examples to detect TypeScript files and transform them to ESNext before minification
  • Added oxc_transformer dependency to minifier examples
  • Maintains backward compatibility with JavaScript files

Testing

Create a TypeScript test file and run the examples:

interface User {
    name: string;
    age: number;
}

function greet(user: User): string {
    const unused = "this will be removed";
    return `Hello, ${user.name}!`;
}

const user: User = { name: "Alice", age: 30 };
console.log(greet(user));
# Now works with TypeScript files
cargo run -p oxc_minifier --example minifier test.ts --mangle --nospace
cargo run -p oxc_minifier --example dce test.ts --nospace

The changes ensure that:

  • Memory allocation measurements include the full minification pipeline for all file types
  • Minifier examples can process both JavaScript and TypeScript files
  • TypeScript files are properly transformed to ESNext before minification

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 30, 2025

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.

@camc314
Copy link
Contributor

camc314 commented Aug 30, 2025

@copilot #13445 is the pr

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Copilot AI changed the title [WIP] reciew this pr, and apply the same changes to the minifier examples Add --max-iterations parameter to DCE minifier example Aug 30, 2025
Copilot AI requested a review from camc314 August 30, 2025 21:08
@camc314
Copy link
Contributor

camc314 commented Aug 30, 2025

sorry @copilot i copeied the wrong PR link. rewrite the pr based on this one

#13445

- Add oxc_semantic and oxc_transformer dependencies to track_memory_allocations
- Transform TypeScript to ESNext before minification in both warm-up and measurement loops
- Update allocation snapshots to reflect TypeScript transformation overhead
- Enables minifier to work correctly on TypeScript files by transforming them first

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 30, 2025

sorry @copilot i copeied the wrong PR link. rewrite the pr based on this one

#13445

I've completely rewritten the PR based on PR #13445. The changes now fix the memory allocation tracking task by transforming TypeScript to ESNext before minification, rather than adding DCE parameters. This allows the minifier to work correctly on all TypeScript test files. See commit 5ccb855.

Copilot AI changed the title Add --max-iterations parameter to DCE minifier example fix(tasks/allocations): before minification, transform to esnext Aug 30, 2025
@camc314
Copy link
Contributor

camc314 commented Aug 30, 2025

@copilot update the code in the minifier example to run it through the transformer before minifyong

…ation

- Add oxc_transformer dependency to minifier examples
- Transform TypeScript to ESNext before minification in minifier.rs and dce.rs examples
- Enables minifier examples to work correctly on TypeScript files
- Maintains backward compatibility with JavaScript files

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 30, 2025

@copilot update the code in the minifier example to run it through the transformer before minifyong

I've updated the minifier examples to run TypeScript files through the transformer before minifying. The changes include:

  • Added oxc_transformer dependency to the minifier examples
  • Updated both minifier.rs and dce.rs examples to transform TypeScript to ESNext before minification
  • Maintains backward compatibility with JavaScript files

The examples now correctly handle TypeScript files by detecting the source type and applying transformation when needed. See commit bf9bbb3.

Copilot AI changed the title fix(tasks/allocations): before minification, transform to esnext fix(tasks/allocations): before minification, transform to esnext and update minifier examples Aug 30, 2025
@camc314 camc314 closed this Sep 16, 2025
@camc314 camc314 deleted the copilot/fix-c4e04d0e-bb76-45e9-b375-320a6e369b6b branch September 16, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants