fix(swc_ecma_minifier): fixed compatibility for wasm plugin (swc_ast_unknown)#11641
Conversation
🦋 Changeset detectedLatest 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 |
Binary Sizes
Commit: 97c6e63 |
e40e350 to
0658bd0
Compare
0658bd0 to
17fc61d
Compare
There was a problem hiding this comment.
💡 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"), |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 👍 / 👎.
Refs: