Skip to content

fix(es): Decode template raw values when cooked is missing - #12347

Merged
Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
fix/template-literal-missing-cooked
Sep 12, 2026
Merged

fix(es): Decode template raw values when cooked is missing#12347
Donny/강동윤 (kdy1) merged 3 commits into
mainfrom
fix/template-literal-missing-cooked

Conversation

@magic-akari

Copy link
Copy Markdown
Member

Description:

Use Str::from_tpl_raw when cooked is missing in template literal lowering and Fast DTS, preserving escape sequences' string values. This fixes doubled backslashes in CSS produced by the styled-components plugin.

Also correct line-ending normalization and Unicode escape handling in the decoder, with regression tests for lowering and declaration generation.

Related issue (if exists):

@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5a6b883

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

@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 1 regressed benchmark
✅ 202 untouched benchmarks
⏩ 61 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
es/large/minify/libraries/terser 449.3 ms 461.2 ms -2.59%
script[1024] 244.4 ns 215.3 ns +13.55%
script[16] 244.4 ns 215.3 ns +13.55%
module_noop[16] 817.2 ns 788.1 ns +3.7%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/template-literal-missing-cooked (5a6b883) with main (f37ce70)

Open in CodSpeed

Footnotes

  1. 61 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@magic-akari
magic-akari marked this pull request as ready for review September 11, 2026 07:40
@magic-akari
magic-akari requested review from a team as code owners September 11, 2026 07:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-11T11:49:13.379912Z 5a6b883 New commits
🔒 Security Review Completed 2026-09-11T11:50:24.605491Z 5a6b883 New commits
ℹ️ About Codex in GitHub

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

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kdy1 Donny/강동윤 (kdy1) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Full completed for base 32c9894cff0ce90cd757566b06d7f6e93c9640de and head a53eb7b42ebe567734d922a2583374f0b153f337.

Three independent baseline reviews completed successfully. Four follow-up passes retired all reviewers (13 worker attempts, 0 retries).

Findings:

  • [P1] Raw-only computed template property keys still panic in Fast DTS (inline comment below).
  • [P1] Enum template evaluation still requires cooked: transform_enum returns no value for a raw-only quasi at lines 101/107, so valid template enum initializers/interpolations emit an enum-initializer diagnostic and lose their initializer.
  • [P1] Raw-only template member keys cannot resolve enum members: static-name lookup returns None for a computed template key whose cooked value is absent, so a raw-only template member reference fails enum evaluation.

Verification: cargo test -p swc_ecma_ast --test lit passed (20 tests); cargo test -p swc_typescript --test typescript passed (66 tests); the new missing-cooked ES2015 fixtures passed. The full ES2015 template-literals target could not complete 13 unrelated exec tests because mocha was unavailable.

This review found reportable issues in the reviewed scope; it does not establish overall correctness or security.

Comment thread crates/swc_typescript/src/fast_dts/types.rs Outdated
@magic-akari
magic-akari force-pushed the fix/template-literal-missing-cooked branch from 5998769 to 5a6b883 Compare September 11, 2026 11:44
@kdy1

Copy link
Copy Markdown
Member

I'll remove the noise with #12350

@kdy1 Donny/강동윤 (kdy1) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Full

Reviewed base f37ce705d2dce729fe4448dded8ce9a1f700ad3c against head 5a6b883380b744324559b9d75ea3107fd030722f.

  • Three of three baseline reviews completed successfully.
  • Five follow-up passes completed; all three reviewers retired after the required three consecutive no-new passes.
  • Total worker attempts: 14; retry attempts: 0.
  • No reportable issues were found in the reviewed scope.

Verification limitations

Static review and targeted fixture/compile checks were completed. Full runtime validation was limited by the environment: some test/build attempts were blocked by read-only sccache/target creation, and broader compatibility execution tests could not run because mocha is unavailable. This review does not establish that the PR is otherwise correct or bug-free.

@kdy1 Donny/강동윤 (kdy1) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the late review. I was struggling to verify if it's not a major bump, because of the trait api changes. Changesets are good, so I'll review this soon

@kdy1
Donny/강동윤 (kdy1) merged commit 7898152 into main Sep 12, 2026
225 of 227 checks passed
@kdy1
Donny/강동윤 (kdy1) deleted the fix/template-literal-missing-cooked branch September 12, 2026 14:11
@github-actions github-actions Bot added this to the Planned milestone Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Template literal lowering changes the string value when cooked is absent

2 participants