Skip to content

fix(transformer/styled-components): remove leading whitespace when literal starts with block comment containing interpolation in CSS minification#13391

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-29-fix_transformer_styled-components_remove_leading_whitespace_when_literal_starts_with_block_comment_containing_interpolation_in_css_minification
Aug 30, 2025
Merged

fix(transformer/styled-components): remove leading whitespace when literal starts with block comment containing interpolation in CSS minification#13391
graphite-app[bot] merged 1 commit intomainfrom
08-29-fix_transformer_styled-components_remove_leading_whitespace_when_literal_starts_with_block_comment_containing_interpolation_in_css_minification

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 29, 2025

Remove leading whitespace when template literal starts with a block comment which contains interpolations.

Previously we didn't remove it because we checked if we're at start of the template literal with quasi_index == 0, but that wasn't right because the 1st quasi gets merged into the 2nd. So the 2nd quasi is the 1st output quasi. Introduce is_first_output var to track this state.

Input:

styled.div` /* ${x} */ color: red; `;

Previous output post-minification:

styled.div` color:red;`;

After this PR:

styled.div`color:red;`;

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-bug Category - Bug labels Aug 29, 2025
Copy link
Member Author

overlookmotel commented Aug 29, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 29, 2025

CodSpeed Instrumentation Performance Report

Merging #13391 will improve performances by 3.1%

Comparing 08-29-fix_transformer_styled-components_remove_leading_whitespace_when_literal_starts_with_block_comment_containing_interpolation_in_css_minification (7ee19e2) with main (95d4311)1

Summary

⚡ 1 improvements
✅ 37 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[RadixUIAdoptionSection.jsx] 14.9 µs 14.5 µs +3.1%

Footnotes

  1. No successful run was found on main (7ee19e2) during the generation of this report, so 95d4311 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review August 29, 2025 12:23
@overlookmotel overlookmotel requested a review from Dunqing as a code owner August 29, 2025 12:23
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 30, 2025
Copy link
Member

Boshen commented Aug 30, 2025

Merge activity

…teral starts with block comment containing interpolation in CSS minification (#13391)

Remove leading whitespace when template literal starts with a block comment which contains interpolations.

Previously we didn't remove it because we checked if we're at start of the template literal with `quasi_index == 0`, but that wasn't right because the 1st quasi gets merged into the 2nd. So the 2nd quasi is the 1st *output* quasi. Introduce `is_first_output` var to track this state.

Input:

```js
styled.div` /* ${x} */ color: red; `;
```

Previous output post-minification:

```js
styled.div` color:red;`;
```

After this PR:

```js
styled.div`color:red;`;
```
@graphite-app graphite-app bot force-pushed the 08-29-fix_transformer_styled-components_remove_unnecessary_whitespace_when_removing_block_comments_in_css_minification branch from ac79d7a to cf5175c Compare August 30, 2025 04:24
@graphite-app graphite-app bot force-pushed the 08-29-fix_transformer_styled-components_remove_leading_whitespace_when_literal_starts_with_block_comment_containing_interpolation_in_css_minification branch from 905c7d3 to 7ee19e2 Compare August 30, 2025 04:24
Base automatically changed from 08-29-fix_transformer_styled-components_remove_unnecessary_whitespace_when_removing_block_comments_in_css_minification to main August 30, 2025 04:29
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 30, 2025
@graphite-app graphite-app bot merged commit 7ee19e2 into main Aug 30, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 08-29-fix_transformer_styled-components_remove_leading_whitespace_when_literal_starts_with_block_comment_containing_interpolation_in_css_minification branch August 30, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants