Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(minifier): support keep_names option #9867

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

sapphi-red
Copy link
Member

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

Added support for keep_names: { function: true, class: true }.
Setting .name is makes it difficult to treeshake later on (evanw/esbuild#3965), so it is better to avoid if possible.

This PR only adds support for the compressor. I'll add support for the mangler later on (probably first add required information to the semantics).

refs #9711

Copy link
Member Author

sapphi-red commented Mar 18, 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Mar 18, 2025
@sapphi-red sapphi-red marked this pull request as ready for review March 18, 2025 10:33
Copy link

codspeed-hq bot commented Mar 18, 2025

CodSpeed Performance Report

Merging #9867 will not alter performance

Comparing 03-18-feat_minifier_support_keep_names_option (dcd356e) with main (b9cf61e)

Summary

✅ 33 untouched benchmarks

@sapphi-red sapphi-red marked this pull request as draft March 18, 2025 10:38
@sapphi-red sapphi-red force-pushed the 03-18-feat_minifier_support_keep_names_option branch from e12634d to d241a07 Compare March 18, 2025 10:44
@graphite-app graphite-app bot changed the base branch from 03-18-refactor_minifier_rename_compressoptions_all_true___all_false_to_smallest___safest_ to graphite-base/9867 March 18, 2025 10:45
@sapphi-red sapphi-red marked this pull request as ready for review March 18, 2025 10:54
@graphite-app graphite-app bot force-pushed the 03-18-feat_minifier_support_keep_names_option branch from d241a07 to de39a7a Compare March 18, 2025 10:57
@graphite-app graphite-app bot force-pushed the graphite-base/9867 branch from 4b9d79f to eef7eb6 Compare March 18, 2025 10:57
@graphite-app graphite-app bot changed the base branch from graphite-base/9867 to main March 18, 2025 10:58
@graphite-app graphite-app bot force-pushed the 03-18-feat_minifier_support_keep_names_option branch from de39a7a to 816fbe1 Compare March 18, 2025 10:58
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 18, 2025
Copy link
Member

Boshen commented Mar 18, 2025

Merge activity

  • Mar 18, 7:00 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 18, 7:14 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 18, 7:35 AM EDT: A user merged this pull request with the Graphite merge queue.

Added support for `keep_names: { function: true, class: true }`.
Setting `.name` is makes it difficult to treeshake later on (evanw/esbuild#3965), so it is better to avoid if possible.

This PR only adds support for the compressor. I'll add support for the mangler later on (probably first add required information to the semantics).

refs #9711
@graphite-app graphite-app bot force-pushed the 03-18-feat_minifier_support_keep_names_option branch from 816fbe1 to dcd356e Compare March 18, 2025 11:24
@graphite-app graphite-app bot merged commit dcd356e into main Mar 18, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 03-18-feat_minifier_support_keep_names_option branch March 18, 2025 11:35
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 18, 2025
Boshen added a commit that referenced this pull request Mar 20, 2025
## [0.61.0] - 2025-03-20

- c631291 parser: [**BREAKING**] Parse `TSImportAttributes` as
`ObjectExpression` (#9902) (Boshen)

- eef7eb6 minifier: [**BREAKING**] Rename
`CompressOptions::all_true`/`all_false` to `smallest`/`safest` (#9866)
(sapphi-red)

### Features

- 38ad787 data_structures: Add `assert_unchecked!` macro (#9885)
(overlookmotel)
- dcd356e minifier: Support `keep_names` option (#9867) (sapphi-red)
- 6565fc4 napi: Feature gate allocator (#9921) (Boshen)
- 2cedfe4 napi: Add codeframe to napi error (#9893) (Boshen)
- a9a47a6 parser: Add regex cargo feature to oxc_parser (#9879) (Toshit)
- d4a83ba parser: Report duplicate modifier `Accessibility modifier
already seen.` (#9890) (Boshen)
- 59c8f71 parser,codegen: Handle lone surrogate in string literal
(#9918) (Boshen)

### Bug Fixes

- 28a2ed3 estree/ast: Fix `IdentifierName` and `IdentifierReference`
(#9863) (hi-ogawa)
- 3d4c5f3 semantic: Correctly visit `IfStmt` `test` when building cfg
(#9864) (camc314)
- 1774225 transformer/using: Incorrect scope ids for bindings (#9871)
(camc314)- 68018e1 Ast changes (Boshen)

### Performance

- 5f97f28 ast/estree: Speed up raw deser for `JSXElement` (#9895)
(overlookmotel)
- b272893 mangler, minifier: Initialize a Vec with a specific value
using `Vec::from_iter_in` combined with `repeat_with` (#9908) (Dunqing)
- f7d078c semantic: Use `reserve_exact` instead of `reserve` to save
memory in pre-reserve (#9910) (Dunqing)

### Documentation

- 590a258 napi/parser: Add stackblitz link for wasm build (Boshen)

### Refactor

- 62e2859 ast/ast_builder: Use `self.vec_from_iter` instead of
`Vec::from_iter_in` for consistency (#9909) (Dunqing)
- b2f3d23 isolated_declarations: Remove unused `self` params (#9868)
(overlookmotel)
- 961b95d napi: Move common code to `oxc_napi` (#9875) (Boshen)
- 233c1fc napi/playground: Add JSON.parse wrapper (#9880) (Hiroshi
Ogawa)
- dbe61c5 transformer/module-runner-transform: Remove redundant
converison (#9912) (Dunqing)
- ecdfe2e transformer/using: Move work to `exit_static_block` (#9713)
(camc314)

### Testing

- 9314147 data_structures: Enable doc tests for `oxc_data_structures`
crate (#9884) (overlookmotel)
- 040e993 napi: Refactor NAPI parser benchmarks (#9911) (overlookmotel)
- e637e2e napi/parser: Tweak vitest config (#9878) (Hiroshi Ogawa)

Co-authored-by: Boshen <[email protected]>
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.

2 participants