fix(emotion): avoid css label injection in keyframes#613
Conversation
🦋 Changeset detectedLatest commit: d184998 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Code ReviewThis is a clean, well-targeted fix for issue #607. The root cause identification is correct: What's good
Minor notes1. Redundant fn create_runtime_label(&self, kind: ExprKind, terminate_before_sourcemap: bool) -> String {
let mut label = self.create_label(matches!(kind, ExprKind::Css));
if terminate_before_sourcemap
&& matches!(kind, ExprKind::Css) // ← checked twice
&& !label.is_empty()
&& self.options.sourcemap.unwrap_or(false)
&& !label.ends_with(';')
{
label.push(';');
}
label
}
fn create_runtime_label(&self, kind: ExprKind, terminate_before_sourcemap: bool) -> String {
let is_css = matches!(kind, ExprKind::Css);
let mut label = self.create_label(is_css);
if terminate_before_sourcemap
&& is_css
&& !label.is_empty()
&& self.options.sourcemap.unwrap_or(false)
&& !label.ends_with(';')
{
label.push(';');
}
label
}2. The name describes the mechanism (add 3. Missing test for All new wasm tests exercise the tagged-template form ( // keyframes-call-input.js
import { keyframes } from "@emotion/react";
export const pulse = keyframes("0%{opacity:1;}100%{opacity:1;}");would give confidence that the call-expression path also produces 4. The new tests use SummaryThe fix is correct, the refactoring is clean, and the added tests cover the primary regression scenario. The notes above are all minor — none of them affect correctness. Happy to see this merged once the team confirms CI passes. |
Summary
keyframesno longer shares thecsslabel pathcssauto-label behavior unchanged, including tagged-template semicolon handling before sourcemap comments@swc/plugin-emotionTesting
cargo test -p swc_emotion --test fixture -- --ignoredpnpm --filter @swc/plugin-emotion testCloses #607.