Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Mar 18, 2025

Adds support for keepNames in mangler.
The current implementration does not reuse the name kept. For example, for this input,

function e() {}
function foo() {
  var bar = 1;
  console.log(bar)
}

the ideal output is

function e() {}
function foo() {
  var e = 1;
  console.log(e)
}

(because e is not used inside foo and can be reused)
but the current output is

function e() {}
function foo() {
  var t = 1;
  console.log(t)
}

. I guess this isn't a problem in most cases as you won't use many short names for functions / classes.

close #9711

@github-actions github-actions bot added the A-minifier Area - Minifier label Mar 18, 2025
Copy link
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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 Mar 18, 2025

CodSpeed Performance Report

Merging #9873 will create unknown performance changes

Comparing 03-18-feat_mangler_support_keepnames_option (421163f) with 03-18-feat_semantics_collect_symbols_used_for_function___class_names (af0a969)

Summary

🆕 33 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[checker.ts] N/A 22.6 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 65.7 ms N/A
🆕 isolated-declarations[vue-id.ts] N/A 57.8 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.1 µs N/A
🆕 lexer[antd.js] N/A 24.1 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.7 ms N/A
🆕 lexer[checker.ts] N/A 14.5 ms N/A
🆕 lexer[pdf.mjs] N/A 3.8 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3 s N/A
🆕 mangler[antd.js] N/A 16 ms N/A
🆕 mangler[react.development.js] N/A 294.2 µs N/A
🆕 mangler[typescript.js] N/A 39.5 ms N/A
🆕 minifier[antd.js] N/A 163.2 ms N/A
🆕 minifier[react.development.js] N/A 1.8 ms N/A
🆕 minifier[typescript.js] N/A 288.3 ms N/A
🆕 estree[checker.ts] N/A 87.5 ms N/A
🆕 parser[RadixUIAdoptionSection.jsx] N/A 91.2 µs N/A
🆕 parser[antd.js] N/A 112.6 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@sapphi-red sapphi-red marked this pull request as ready for review March 18, 2025 13:10
@sapphi-red sapphi-red marked this pull request as draft March 18, 2025 13:24
@sapphi-red sapphi-red changed the title feat(mangler): support keepNames option feat(mangler): support keep_names option Mar 19, 2025
@Boshen Boshen closed this Mar 23, 2025
graphite-app bot pushed a commit that referenced this pull request Mar 23, 2025
Same with #9873, but built on top of #9897.

close #9873
close #9711
@sapphi-red sapphi-red deleted the 03-18-feat_mangler_support_keepnames_option branch August 13, 2025 05:23
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