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

fix(es/minifier): Avoid paren when compressing ternary #9920

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

Austaras
Copy link
Member

Description:

BREAKING CHANGE:

Related issue (if exists):

@Austaras Austaras requested a review from a team as a code owner January 22, 2025 11:54
Copy link

changeset-bot bot commented Jan 22, 2025

⚠️ No Changeset found

Latest commit: cf7c463

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@kdy1 kdy1 self-assigned this Jan 22, 2025
@kdy1 kdy1 added this to the Planned milestone Jan 22, 2025
@kdy1 kdy1 requested a review from a team as a code owner January 22, 2025 13:16
@kdy1
Copy link
Member

kdy1 commented Jan 22, 2025

Main:

    Finished `release` profile [optimized + debuginfo] target(s) in 0.15s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/antd.js`
File: ./benches/full/antd.js
  456868
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/d3.js`
File: ./benches/full/d3.js
   86866
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/echarts.js`
File: ./benches/full/echarts.js
  319497
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/jquery.js`
File: ./benches/full/jquery.js
   30875
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/lodash.js`
File: ./benches/full/lodash.js
   25030
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/moment.js`
File: ./benches/full/moment.js
   18572
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/react.js`
File: ./benches/full/react.js
    8185
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/terser.js`
File: ./benches/full/terser.js
  116687
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/three.js`
File: ./benches/full/three.js
  157550
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/typescript.js`
File: ./benches/full/typescript.js
  806012
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/victory.js`
File: ./benches/full/victory.js
  157110
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/master-swc/target/release/examples/minifier ./benches/full/vue.js`
File: ./benches/full/vue.js
   42412
~/projects/master-swc/crates/swc_ecma_minifier main 8s

This PR:

    Finished `release` profile [optimized + debuginfo] target(s) in 0.17s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/antd.js`
File: ./benches/full/antd.js
  456868
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/d3.js`
File: ./benches/full/d3.js
   86865
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/echarts.js`
File: ./benches/full/echarts.js
  319492
    Finished `release` profile [optimized + debuginfo] target(s) in 0.15s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/jquery.js`
File: ./benches/full/jquery.js
   30872
    Finished `release` profile [optimized + debuginfo] target(s) in 0.15s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/lodash.js`
File: ./benches/full/lodash.js
   25025
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/moment.js`
File: ./benches/full/moment.js
   18572
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/react.js`
File: ./benches/full/react.js
    8185
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/terser.js`
File: ./benches/full/terser.js
  116687
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/three.js`
File: ./benches/full/three.js
  157549
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/typescript.js`
File: ./benches/full/typescript.js
  806002
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/victory.js`
File: ./benches/full/victory.js
  157110
    Finished `release` profile [optimized + debuginfo] target(s) in 0.14s
     Running `/Users/kdy1/projects/s/pr/target/release/examples/minifier ./benches/full/vue.js`
File: ./benches/full/vue.js
   42412
~/projects/s/pr/crates/swc_ecma_minifier Austaras/main 8s

So this is a clear win for the bundle size. I'll try to understand logic after taking some sleep...

@kdy1
Copy link
Member

kdy1 commented Jan 23, 2025

Can you look at the CI failure?

kdy1
kdy1 previously approved these changes Jan 23, 2025
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.

The logic looks good to me

@kdy1 kdy1 changed the title fix(es/minifier): Avoid paren when compress tenary fix(es/minifier): Avoid paren when compressing ternary Jan 24, 2025
@kdy1 kdy1 merged commit 9d6fe37 into swc-project:main Jan 24, 2025
168 checks passed
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.

2 participants