Skip to content

Comments

fix(mangler): mangle non top-level exports variable#14169

Merged
graphite-app[bot] merged 1 commit intomainfrom
09-27-fix_mangler_mangle_non_top-level_exports_variable
Sep 27, 2025
Merged

fix(mangler): mangle non top-level exports variable#14169
graphite-app[bot] merged 1 commit intomainfrom
09-27-fix_mangler_mangle_non_top-level_exports_variable

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Sep 26, 2025

var a = function(exports) {
  exports.foo = 'foo'
}
a(exports)

The exports parameter was not mangled. But it is fine to mangle this.
We need to keep the global exports variable as-is, but that is handled by keeping the global variable references.

refs #5965

@github-actions github-actions bot added the C-bug Category - Bug label Sep 26, 2025
Copy link
Member Author


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 Sep 26, 2025

CodSpeed Instrumentation Performance Report

Merging #14169 will not alter performance

Comparing 09-27-fix_mangler_mangle_non_top-level_exports_variable (d02d750) with main (af88e94)1

Summary

✅ 33 untouched
⏩ 4 skipped2

Footnotes

  1. No successful run was found on main (923d6e4) during the generation of this report, so af88e94 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 4 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 sapphi-red force-pushed the 09-27-fix_mangler_mangle_non_top-level_exports_variable branch from 33bde9d to 7a090ae Compare September 26, 2025 16:21
@github-actions github-actions bot added the A-minifier Area - Minifier label Sep 26, 2025
@sapphi-red sapphi-red marked this pull request as ready for review September 26, 2025 16:26
Copilot AI review requested due to automatic review settings September 26, 2025 16:26
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 allow mangling non top-level exports variables while preserving global exports references. The change removes the special case protection for exports parameters and local variables, allowing them to be minified for better compression.

  • Removes exports from the list of special names that should never be mangled
  • Adds test cases to verify that exports parameters can be mangled while global exports references remain unchanged
  • Updates minsize snapshots showing improved compression across multiple JavaScript libraries

Reviewed Changes

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

File Description
crates/oxc_mangler/src/lib.rs Removes "exports" from special names list to enable mangling of non-global exports variables
crates/oxc_minifier/tests/mangler/mod.rs Adds test cases for exports mangling scenarios
crates/oxc_minifier/tests/mangler/snapshots/mangler.snap Updates test snapshots showing mangled exports parameters
tasks/minsize/minsize.snap Updates minsize benchmarks showing improved compression ratios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sapphi-red sapphi-red requested a review from Boshen September 26, 2025 16:27
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Sep 27, 2025
Copy link
Member

Boshen commented Sep 27, 2025

Merge activity

```js
var a = function(exports) {
  exports.foo = 'foo'
}
a(exports)
```
The `exports` parameter was not mangled. But it is fine to mangle this.
We need to keep the global `exports` variable as-is, but that is handled by keeping the global variable references.

refs #5965
@graphite-app graphite-app bot force-pushed the 09-27-fix_mangler_mangle_non_top-level_exports_variable branch from 7a090ae to d02d750 Compare September 27, 2025 06:38
@graphite-app graphite-app bot merged commit d02d750 into main Sep 27, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 09-27-fix_mangler_mangle_non_top-level_exports_variable branch September 27, 2025 06:44
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants