fix(es): Decode template raw values when cooked is missing - #12347
Conversation
🦋 Changeset detectedLatest 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 |
Merging this PR will regress 1 benchmark
|
| 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)
Footnotes
-
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. ↩
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
Donny/강동윤 (kdy1)
left a comment
There was a problem hiding this comment.
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_enumreturns 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
Nonefor a computed template key whosecookedvalue 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.
5998769 to
5a6b883
Compare
|
I'll remove the noise with #12350 |
Donny/강동윤 (kdy1)
left a comment
There was a problem hiding this comment.
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.
Donny/강동윤 (kdy1)
left a comment
There was a problem hiding this comment.
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
Description:
Use
Str::from_tpl_rawwhencookedis 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):