Skip to content

fix(minifier): preserve unsafe object spreads#11820

Draft
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/fix-minifier-object-spread
Draft

fix(minifier): preserve unsafe object spreads#11820
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/fix-minifier-object-spread

Conversation

@kdy1
Copy link
Copy Markdown
Member

@kdy1 kdy1 commented Apr 25, 2026

Summary

  • Prevent object spread folding from flattening spread sources that are not semantically plain data objects.
  • Treat __proto__, computed keys, accessors, impure values, and methods containing super as unsafe spread barriers.
  • Add a regression fixture that keeps the frozen "focal_tweet" source literal while preserving computed-property registration behavior.

Test Plan

  • git submodule update --init --recursive
  • UPDATE=1 cargo test -p swc_ecma_minifier --test compress custom_fixture_tests__fixture__issues__object_spread_frozen_key__input_js -- --ignored
  • cargo test -p swc_ecma_minifier --test compress custom_fixture_tests__fixture__issues__object_spread_frozen_key__input_js -- --ignored
  • (cd crates/swc_ecma_minifier && ./scripts/exec.sh)
  • cargo fmt --all
  • cargo clippy --all --all-targets -- -D warnings
  • cargo test -p swc_ecma_minifier
  • node crates/swc_ecma_minifier/tests/fixture/issues/object-spread-frozen-key/output.js

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 25, 2026

⚠️ No Changeset found

Latest commit: a010b5c

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

@github-actions
Copy link
Copy Markdown
Contributor

Binary Sizes

File Size
swc.linux-x64-gnu.node 27M (27783368 bytes)

Commit: 97452c7

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 25, 2026

Merging this PR will not alter performance

✅ 219 untouched benchmarks
⏩ 31 skipped benchmarks1


Comparing kdy1:kdy1/fix-minifier-object-spread (a010b5c) with main (be38316)

Open in CodSpeed

Footnotes

  1. 31 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant