Skip to content

feat(swc_ecma_minifier, swc_config): add Hash/Eq for options and CachedRegex#11775

Merged
kdy1 merged 4 commits intoswc-project:mainfrom
yuzheng14:feat/put-minify-options-into-task-input
Apr 8, 2026
Merged

feat(swc_ecma_minifier, swc_config): add Hash/Eq for options and CachedRegex#11775
kdy1 merged 4 commits intoswc-project:mainfrom
yuzheng14:feat/put-minify-options-into-task-input

Conversation

@yuzheng14
Copy link
Copy Markdown
Contributor

Description:

I'm a member from utooland, a bundler based on turbopack. I'm working on expanding MinifyType::Minify { mangle: ... } to MinifyType::Minify(swc_ecma_minifier::option::MinifyOptions) for turbopack.

https://github.com/vercel/next.js/blob/38cffffeccbc68e0c256b4fb9aa17e23f3f308f4/turbopack/crates/turbopack-core/src/chunk/chunking_context.rs#L53-L60

image

But MinifyOptions doesn't implement PartialEq, Eq and Hash traits which are required by TaskInput trait.

https://github.com/vercel/next.js/blob/38cffffeccbc68e0c256b4fb9aa17e23f3f308f4/turbopack/crates/turbo-tasks/src/task/task_input.rs#L83-L85

image

So I implement required traits for MinifyOptions.

BREAKING CHANGE:

In order to implement Hash trait for CompressOptions::global_defs typed as FxHashMap, I added a newtype wrapper with From<FxHashMap<Box<Expr>, Box<Expr>>>, FromIterator<(Box<Expr>, Box<Expr>)>, Deref and DerefMut to ease migration, but this may still be a breaking change for code that depended on the field type being FxHashMap directly.

Related issue (if exists):

utooland/utoo#2741

…edRegex

- Wrap compress global_defs in GlobalDefs with order-independent Hash (XOR + len)
- Derive or implement PartialEq, Eq, Hash for MinifyOptions, CompressOptions, etc.
- Implement PartialEq, Eq, Hash for CachedRegex using regex pattern (as_str)
@yuzheng14 yuzheng14 requested review from a team as code owners April 8, 2026 04:24
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: ca53e01

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (29074376 bytes)

Commit: c98079e

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 8, 2026

Merging this PR will not alter performance

✅ 219 untouched benchmarks


Comparing yuzheng14:feat/put-minify-options-into-task-input (ca53e01) with main (fff1426)

Open in CodSpeed

@kdy1 kdy1 merged commit 86a4c38 into swc-project:main Apr 8, 2026
22 checks passed
@github-actions github-actions bot added this to the Planned milestone Apr 8, 2026
@yuzheng14 yuzheng14 deleted the feat/put-minify-options-into-task-input branch April 8, 2026 05:20
@kdy1
Copy link
Copy Markdown
Member

kdy1 commented Apr 8, 2026

Thank you! I'll publish crates right away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants