Skip to content

Conversation

@rtsao
Copy link
Contributor

@rtsao rtsao commented Jun 3, 2025

Description:

The minifier currently produces invalid syntax for awaited arrow expressions, for example:

await (() => { console.log("foo") });

is minified into the following invalid syntax (missing wrapping parens):

await ()=>{ console.log("foo"); };

https://play.swc.rs/?version=1.11.29&code=H4sIAAAAAAAAA0ssT8wsUdDQ0FSwtVOoVkjOzyvOz0nVy8lP11BKy89X0lSo1bQGAMCbrPQlAAAA&config=H4sIAAAAAAAAA1VPOw6DMAzdc4rIc4cKVR16hx7CSg0Kyk9xkBoh7k6AhJbN7%2Bdnz0JKGFnBS85lLCBgZIonLgxnl%2FBbGCBlkVXUIcGtqSNvUo%2BGaaeWQ4GEcaC0p7i7d4%2BaAOM9U0tUzmqn%2B%2FzfqbwNkZivxs2KbjB0bRS1Faz%2FTLtYf0k50HHBE36mVnYuBs3vlkxxIrGsmdxHnRcBAAA%3D

BREAKING CHANGE:

N/A

Related issue (if exists):

@rtsao rtsao requested a review from a team as a code owner June 3, 2025 21:22
@changeset-bot
Copy link

changeset-bot bot commented Jun 3, 2025

🦋 Changeset detected

Latest commit: 132617f

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 3, 2025

CodSpeed Performance Report

Merging #10555 will not alter performance

Comparing rtsao:fix-await-arrow-minify-bug (132617f) with main (9dfdfa6)

Summary

✅ 138 untouched benchmarks
🆕 6 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 es/fixer/typescript N/A 205.4 ms N/A
🆕 es/hygiene/typescript N/A 459.7 ms N/A
🆕 es/resolver/typescript N/A 253.1 ms N/A
🆕 es/resolver_with_hygiene/typescript N/A 832.4 ms N/A
🆕 hygiene/typescript N/A 22.7 s N/A
🆕 resolver/typescript N/A 12.7 s N/A
@Austaras
Copy link
Member

Austaras commented Jun 4, 2025

It's better to handle this in fixer instead of codegen.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtsao rtsao force-pushed the fix-await-arrow-minify-bug branch from 4c58034 to c107233 Compare June 4, 2025 14:55
magic-akari
magic-akari previously approved these changes Jun 4, 2025
@kdy1 kdy1 added this to the Planned milestone Jun 4, 2025
@kdy1 kdy1 requested a review from a team as a code owner June 4, 2025 16:08
@kdy1 kdy1 changed the title Fix minifier bug with awaited arrow fn expression fix(es/fixer): Fix a bug with awaited arrow fn expression Jun 4, 2025
@kdy1 kdy1 merged commit 9dfdfa6 into swc-project:main Jun 4, 2025
32 checks passed
@kdy1
Copy link
Member

kdy1 commented Jun 4, 2025

Thank you!

@kdy1 kdy1 modified the milestones: Planned, Next version Jun 5, 2025
@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants