fix(emotion): fix autoLabel not adding label to css tagged template class names#597
Conversation
…lass names The `autoLabel` option for `css\`...\`` tagged templates was not working because `create_label(false)` was used, which returns just the label name (e.g., `"testCls"`) without the `label:` CSS property prefix. Emotion's runtime recognizes labels in CSS via the `label:xxx` CSS property. Without the prefix, the bare string `"testCls"` gets appended to the CSS content without being recognized as a label, so the class name hash did not include the label suffix. Fix: use `create_label(true)` for `css\`\`` tagged template expressions, which produces `"label:testCls"` (matching how call expressions handle it). This fixes the issue where `autoLabel: 'always'` config option had no effect on class names generated from CSS tagged template literals. Fixes: #571 Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
|
|
PR Review: fix(emotion): fix autoLabel not adding label to css tagged template class namesOverall: Clean, focused bug fix. Looks good to merge. SummaryThe root cause is in — was called for tagged template literals, where the boolean controls whether the Strengths
Minor Observations
Neither of these is a blocker. The fix is correct, well-tested, and all relevant existing fixtures have been updated. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89f3371565
ℹ️ 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".
| args.push(self.create_label(true).as_arg()); | ||
| } | ||
| if let Some(cm) = self.create_sourcemap(tagged_tpl.span.lo()) { |
There was a problem hiding this comment.
Append a semicolon before the source-map comment
This still doesn’t fix the default development configuration. create_label(true) returns label:<name> without a trailing ;, and the next lines append the source-map comment, so the emitted call becomes css(..., "label:foo", "/*# sourceMappingURL... */"). Emotion’s runtime only extracts labels when they end with ; or end-of-string, which means tagged-template labels are still ignored whenever sourceMap is left at its documented default of true in dev. The new wasm coverage masks this by forcing sourceMap: false in packages/emotion/__tests__/wasm.test.ts.
Useful? React with 👍 / 👎.
## Summary - Addressed `chatgpt-codex-connector[bot]` review follow-ups across merged PRs: #585, #591, #592, #593, #594, #595, #597, #598, #599. - Applied the fixes as 9 separate commits (one commit per original PR) in a single follow-up branch. ## What Changed - #585 / #592 (`loadable-components`) - Fixed source-less default-import matching to honor the configured local name. - Updated `ssr: false` detection to respect final object-literal override order. - Added/updated fixtures for both behaviors. - #591 / #594 (`formatjs`) - Added JSX member-expression message component support (e.g. `ReactIntl.FormattedMessage`). - Updated #532 regression coverage to validate the `ast: true` path. - #593 / #595 (`graphql-codegen-client-preset`) - Extended `namingConvention` parsing to accept string/object forms. - Preserved names for `keep`/unknown conventions instead of forcing PascalCase. - Fixed Windows absolute `filename` path handling in WASM runtime path resolution. - Added unit coverage for the new config/path behaviors. - #597 / #599 (`emotion`) - Ensured tagged-template labels are terminated before sourcemap comments. - Added css-prop rewrite support for namespace imports (`emotionReact.css`). - Attached PURE comments to the generated call site span. - Updated emotion fixtures accordingly. - #598 (docs) - Corrected capability descriptions in `packages/jest/README.tmpl.md` and `packages/swc-sdk/README.tmpl.md`. ## Validation - `cargo test -p swc_plugin_loadable_components --test fixture -- --ignored` - `cargo test -p swc_plugin_graphql_codegen_client_preset` - `cargo test -p swc_emotion --test fixture -- --ignored` - `pnpm -C /Users/kdy1/.codex/worktrees/17e6/plugins/packages/formatjs test` All passed (formatjs has an existing non-blocking Vitest warning about an un-awaited rejects assertion).
…perty `keyframes` expects a plain name string (e.g. "pulse"), not a CSS label property (e.g. "label:pulse;"). Add `ExprKind::Keyframes` variant and map `keyframes` to it so label injection uses `create_label(false)` instead of `create_label(true)`, preventing the `animation-` prefix regression introduced in #597. Fixes #607 Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
Fix
autoLabeloption not working forcsstagged template literals.The label was added without the
label:CSS property prefix, so emotion's runtime did not recognize it and omitted it from the class name.Fixes #571
Generated with Claude Code