Skip to content

fix(swc_ecma_minifier): fixed compatibility for wasm plugin (swc_ast_unknown)#11641

Merged
kdy1 merged 2 commits intoswc-project:mainfrom
vsn4ik:swc_ecma_minifier-with-swc_ast_unknown
Mar 11, 2026
Merged

fix(swc_ecma_minifier): fixed compatibility for wasm plugin (swc_ast_unknown)#11641
kdy1 merged 2 commits intoswc-project:mainfrom
vsn4ik:swc_ecma_minifier-with-swc_ast_unknown

Conversation

@vsn4ik
Copy link
Copy Markdown
Contributor

@vsn4ik vsn4ik commented Mar 10, 2026

@vsn4ik vsn4ik requested a review from a team as a code owner March 10, 2026 23:15
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 10, 2026

CLA assistant check
All committers have signed the CLA.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: 38f3cf5

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 Mar 10, 2026

Binary Sizes

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

Commit: 97c6e63

@vsn4ik vsn4ik force-pushed the swc_ecma_minifier-with-swc_ast_unknown branch from e40e350 to 0658bd0 Compare March 10, 2026 23:32
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 10, 2026

Merging this PR will not alter performance

✅ 218 untouched benchmarks


Comparing vsn4ik:swc_ecma_minifier-with-swc_ast_unknown (38f3cf5) with main (aa6727a)

Open in CodSpeed

@vsn4ik vsn4ik force-pushed the swc_ecma_minifier-with-swc_ast_unknown branch from 0658bd0 to 17fc61d Compare March 10, 2026 23:35
@kdy1 kdy1 requested a review from a team as a code owner March 11, 2026 05:06
@kdy1 kdy1 merged commit abd0e45 into swc-project:main Mar 11, 2026
22 checks passed
@github-actions github-actions Bot added this to the Planned milestone Mar 11, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38f3cf5447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle unknown import specifiers without aborting minification

In swc_ast_unknown builds this match arm will panic when the host sends a newer ImportSpecifier variant, which is exactly the cross-version case compatibility mode is supposed to tolerate. That turns otherwise valid modules into hard failures during postcompress_optimizer; instead of panicking, this path should conservatively skip merge logic for that declaration (or keep it unchanged) so unknown nodes can pass through.

Useful? React with 👍 / 👎.

.any(|arg| contains_update_or_assign(&arg.expr))
}
#[cfg(swc_ast_unknown)]
_ => false,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat unknown optional-chain bases as side-effectful

Returning false here means contains_update_or_assign claims an unknown OptChainBase has no mutation risk, which can enable optimize_bin_equal to rewrite === to == on expressions we cannot analyze in compatibility mode. For unknown AST variants from newer hosts, that optimistic assumption can change runtime results; this branch should conservatively block the rewrite (or bail) instead of permitting it.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot modified the milestones: Planned, 1.15.21 Mar 22, 2026
@swc-project swc-project locked as resolved and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants