build: Update swc_core to v77.0.0 - #654
Conversation
Releases: @swc/plugin-react-remove-properties@13.0.0 @swc/plugin-styled-components@13.0.0 @swc/plugin-transform-imports@13.0.0 @swc/plugin-swc-confidential@12.0.0 @swc-contrib/mut-cjs-exports@15.0.0 @swc/plugin-remove-console@13.0.0 @swc/plugin-styled-jsx@14.0.0 @swc/plugin-swc-magic@13.0.0 @swc/plugin-formatjs@10.0.0 @swc/plugin-prefresh@13.0.0 @swc/plugin-emotion@15.0.0 @swc/plugin-swc-sdk@13.0.0 @swc/plugin-relay@13.0.0 @swc/plugin-jest@13.0.0 @swc/plugin-loadable-components@12.0.0 @swc/plugin-noop@13.0.0 @swc/plugin-experimental-feature-flags@0.19.0 @swc-contrib/plugin-graphql-codegen-client-preset@0.32.0 [skip ci]
|
|
Claude (@claude) Fix CI failures |
|
Claude finished Donny/강동윤 (@kdy1)'s task in 15m 10s —— View job Fixed the Rust compile failures; one remaining failure is blocked upstream
What was brokenTwo 1.
For the four pub(crate) fn expect_fn_body(stmt: Stmt) -> FunctionBody {
let block = stmt.expect_block();
FunctionBody {
span: block.span,
stmts: block.stmts,
}
}2.
if let Some(value) = txt.value.as_atom() {
if value.chars().all(char::is_whitespace) {
return false;
}
}Still failing:
|
swc_core |
swc_ecma_ast |
Function::body |
|
|---|---|---|---|
| plugins in this PR | 77.0.0 | 29.0.0 | Option<FunctionBody> |
@swc/core@1.15.43 (lockfile) |
71.0.3 | 25.0.0 | Option<BlockStmt> |
@swc/core@1.15.47 (latest published) |
75.0.0 | 27.0.0 | Option<BlockStmt> |
Because Function is encoded field-wise across the plugin ABI, the host's BlockStmt body (span, ctxt, stmts) no longer decodes into the plugin's FunctionBody (span, stmts). That is exactly why only the fixtures containing functions/JSX fail while the rest pass — e.g. emotion is 1 failed | 7 passed.
Bumping the @swc/core devDependency does not help: 1.15.47 is the newest published version (and 1.15.47-nightly-20260729.1 the newest nightly), and both still use swc_ecma_ast 27 with Option<BlockStmt>. This job should go green once an @swc/core built on swc_core v77 is published and the lockfile is bumped to it. I did not touch the tests, since skipping them would hide a real incompatibility.
Notes
packages/formatjs/transformdoes not compile under--cfg swc_ast_unknown(two non-exhaustivematchonJSXAttrName/PropName). This is pre-existing —swc_plugin_formatjs,swc_formatjs_transform,swc_plugin_styled_jsxandstyled_jsxare excluded from that CI job — so I left it alone.packages/loadable-components/tests/fixture.rs:66has pre-existingcargo fmtdrift. I reverted rustfmt's change there to keep this commit scoped to the CI fix.
• branchkdy1/core77
Review —
|
| file | lines |
|---|---|
contrib/mut-cjs-exports/src/utils.rs |
38 (let body = BlockStmt {) → used at 49 |
contrib/mut-cjs-exports/src/lib.rs |
202 |
packages/loadable-components/src/lib.rs |
387, plus 427 / 465 / 497 / 530 (quote!(… as Stmt).expect_block() yields a BlockStmt) |
For the two struct-literal sites the field sets are identical, so it's a one-word swap (BlockStmt { → FunctionBody {; FunctionBody also derives Default). For the four quote! sites a tiny local helper keeps them readable:
trait IntoFunctionBody {
fn into_function_body(self) -> FunctionBody;
}
impl IntoFunctionBody for BlockStmt {
fn into_function_body(self) -> FunctionBody {
FunctionBody {
span: self.span, // keep the real span, not DUMMY_SP,
stmts: self.stmts, // so codegen/source maps don't shift
}
}
}…then .expect_block().into_function_body().
2. JSXText::value changed from Atom to Wtf8Atom, which has no chars() — packages/styled-jsx/transform/src/visitor.rs:827:
-if txt.value.chars().all(char::is_whitespace) {
+if txt.value.as_atom().is_some_and(|s| s.chars().all(char::is_whitespace)) {as_atom() (already the idiom used in contrib/mut-cjs-exports/src/utils.rs:130) returns None only for non-UTF-8 text, and a lone surrogate is never whitespace, so is_some_and preserves the old behaviour exactly.
Worth noting for triage: styled_jsx and swc_formatjs_transform are excluded from the Check (swc_ast_unknown) job, so this second breakage never appears in that job's log — it only surfaces under cargo test --all. Might be worth revisiting those exclusions.
Verified: with just those four files patched as above, cargo check --workspace --all-targets is clean (0 errors) and cargo test -p swc_plugin_loadable_components -p swc_mut_cjs_exports -p styled_jsx passes 234/234 with no snapshot churn — so the AST migration is output-preserving.
🔴 Blocking — host/plugin ABI: @swc/core also needs bumping
Both Integration Test jobs fail with:
failed to invoke
…/swc_plugin_emotion.wasmas js transform plugin … Please ensure the version ofswc_coreused by the plugin is compatible with the host runtime
That's not a code bug: the tests rebuild each plugin from source (now on swc_core 77) and run it through the root @swc/core dev dependency, which pnpm-lock.yaml pins at 1.15.43 (published 2026-06-22, i.e. the v76-era host). Neither the root package.json nor pnpm-lock.yaml is touched in this PR.
This matters beyond CI: publishing plugins built on swc_core v77 while no compatible @swc/core release exists would leave every published .wasm unloadable for users until they upgrade the host. Please bump @swc/core (latest is 1.15.47) to whichever release embeds swc_core v77, refresh the lockfile, and confirm the integration tests go green before publishing — or hold the PR until such a release is out.
🟡 Non-blocking — new warnings introduced by the bump
- 6 ×
use of deprecated type alias BlockStmtOrExpr→ArrowFunctionBody(block variant is nowArrowFunctionBody::FunctionBody):packages/styled-components/transform/src/visitors/transpile_css_prop/transpile.rs:232,273andpackages/swc-sdk/transform/src/lib.rs:6,161,187,240. All are::Expr(...)uses, so this is a mechanical rename — and since this release is already breaking, it's a cheap moment to do it. - 2 ×
unreachable_patternsincrates/swc_feature_flags/src/stats.rs:114,164—LitandCalleeare now fully covered by the explicit arms in default builds.⚠️ Please don't just delete the_arms: they are reachable under--cfg swc_ast_unknown(that job emits no such warning), so an#[allow(unreachable_patterns)]or a cfg-gated arm is the safe fix.
✅ Release metadata — checked, all good
Cargo.lockis in sync with every bumped member (swc_core77.0.0,swc_ecma_ast29.0.0, all 16 bumped workspace crates) — a--lockedbuild won't trip.- All
{ path = …, version = … }requirements match the bumped crate versions (34 crates scanned, 0 mismatches), including the two-level ones likeswc_icu_messageformat_parser36.0.0 inpackages/formatjs/transform. - Changeset severity is right per package:
majorfor ≥1.0 packages,minorfor the 0.x ones (@swc-contrib/plugin-graphql-codegen-client-preset0.31→0.32,@swc/plugin-experimental-feature-flags0.18→0.19). - CHANGELOG→README merge is consistent with each package's existing convention; the three packages without a README section (
swc-confidential,mut-cjs-exports,graphql-codegen-client-preset) have never carried one, so nothing missing there. - Unpublished
cdylibwrapper crate versions (0.19.4etc.) correctly left untouched.
Test coverage
No new tests are needed for the bump itself, and existing fixtures already cover both migration sites (they caught nothing only because the code doesn't compile yet). The one thing to watch is span fidelity: when converting BlockStmt → FunctionBody, carry block.span through rather than DUMMY_SP — with the span preserved, all 234 tests in the affected crates pass unchanged.
Summary: metadata and versioning are solid; this needs (a) the ~10-line AST migration in 4 files, and (b) an @swc/core host bump before the plugins can be published.
- `Function::body` is now `Option<FunctionBody>` instead of `Option<BlockStmt>` - `JSXText::value` is now `Wtf8Atom` instead of `Atom` Co-authored-by: Donny/강동윤 <29931815+kdy1@users.noreply.github.com>
|
|
Review:
|
No description provided.