Skip to content

feat(mangler): skip mangling only in scopes affected by direct eval#17612

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval
Jan 4, 2026
Merged

feat(mangler): skip mangling only in scopes affected by direct eval#17612
graphite-app[bot] merged 1 commit intomainfrom
c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Jan 3, 2026

No description provided.

@github-actions github-actions bot added A-minifier Area - Minifier C-bug Category - Bug labels Jan 3, 2026
Copy link
Contributor Author

camc314 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.

@camc314 camc314 marked this pull request as ready for review January 3, 2026 21:21
Copilot AI review requested due to automatic review settings January 3, 2026 21:21
@camc314 camc314 force-pushed the c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval branch from 393e12e to 81d681d Compare January 3, 2026 21:21
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 fixes the mangler to only skip mangling in scopes that are actually affected by direct eval, rather than disabling all mangling globally when any direct eval is detected. The change improves code minification by allowing mangling in scopes that are isolated from eval's reach.

Key changes:

  • Removed the early return that globally disabled mangling when direct eval was found anywhere in the code
  • Added per-scope checks to skip mangling only in scopes that contain direct eval or have it in descendant scopes
  • Added comprehensive test coverage for various direct eval scenarios including nested scopes, sibling scopes, child function scopes, and indirect eval

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_mangler/src/lib.rs Removed global direct eval check and added per-scope checks during slot assignment and frequency tallying to selectively skip mangling
crates/oxc_minifier/tests/mangler/mod.rs Added comprehensive test cases validating correct behavior for direct eval in various scope configurations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 3, 2026

CodSpeed Performance Report

Merging #17612 will not alter performance

Comparing c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval (82fb107) with main (1044116)

Summary

✅ 38 untouched
⏩ 7 skipped1

Footnotes

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

@sapphi-red
Copy link
Member

It would be helpful if we have a comment here why we don't have to add var names in direct eval contained scopes.

if !oxc_syntax::keyword::is_reserved_keyword(n)

@camc314 camc314 force-pushed the c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval branch from 81d681d to 82fb107 Compare January 4, 2026 11:32
@sapphi-red sapphi-red changed the title fix(mangler): skip mangling only in scopes affected by direct eval feat(mangler): skip mangling only in scopes affected by direct eval Jan 4, 2026
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Jan 4, 2026
@sapphi-red sapphi-red removed the C-bug Category - Bug label Jan 4, 2026
@sapphi-red sapphi-red added the 0-merge Merge with Graphite Merge Queue label Jan 4, 2026
Copy link
Member

sapphi-red commented Jan 4, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval branch from 82fb107 to 23680a3 Compare January 4, 2026 15:36
@graphite-app graphite-app bot merged commit 23680a3 into main Jan 4, 2026
20 checks passed
@graphite-app graphite-app bot deleted the c/01-03-fix_mangler_skip_mangling_only_in_scopes_affected_by_direct_eval branch January 4, 2026 15:42
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 4, 2026
graphite-app bot pushed a commit that referenced this pull request Jan 5, 2026
### 🚀 Features

- 659c23e linter: Init note field boilerplate  (#17589) (Shrey Sudhir)
- 6870b64 parser: Add TS1363 error code (#17609) (Sysix)
- 23680a3 mangler: Skip mangling only in scopes affected by direct eval (#17612) (camc314)
- a7e1643 parser: Add TS2528 error code to duplicate_default_export diagnostic (#17558) (camc314)

### 🐛 Bug Fixes

- 1044116 ecmascript: Mark `new Symbol` as non side-effect free (#17568) (camc314)
- ab5e4ca isolated-declarations: Strip default values from rest parameter binding patterns (#17602) (camc314)
- 68b2e54 minifier: Prevent incorrect ??= transformation when member base is mutated (#17472) (copilot-swe-agent)

### ⚡ Performance

- 6067143 semantic: Remove hash when checking identifier (#17564) (camchenry)
- a28ab3d semantic: Avoid bounds check when checking string literal (#17545) (camc314)
- 04809d1 semantic: Use SIMD for finding backslashes in `check_string_literal` (#17534) (camchenry)
- 49ad2f0 semantic: Mark all diagnostic functions as `#[cold]` (#17487) (camc314)
- ea82b50 transformer: Mark all diagnostic functions as `#[cold]` (#17486) (camc314)
- d968e51 semantic: Mark `checker::check` as `inline(always)` (#17459) (camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants