43081j / 43081j/postcss-lit

Output not same as postcss-preset-env playground

オープン
#50 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
90
フォーク
9
平均マージ
1日 9分
マージ済み PR(30日)
3

説明

It appears the output of a postcss lit component is not as expected when using the postcss CLI. Replication available here:
https://github.com/adrianbruntonsagecom/postcss-lit-preset-env-issue

Clone repo:
`git clone https://github.com/adrianbruntonsagecom/postcss-lit-preset-env-issue.git`

Install dependencies:
`npm i`

Run postcss CLI in root directory on standard css file requiring browser prefixes & de-nesting.
`npx postcss input.css -o output.css`

This matches the expected output from [postcss-preset-env playground](https://preset-env.cssdb.org/playground/#JTdCJTIyc291cmNlJTIyJTNBJTIyLmJ1dHRvbiUyMCU3QiU1Q24lMjAlMjAlMjAlMjAlMjAlMjBjb2x1bW5zJTNBJTIwMyUzQiU1Q24lNUNuJTIwJTIwJTIwJTIwJTIwJTIwJTI2JTNBZm9jdXMlMkMlNUNuJTIwJTIwJTIwJTIwJTIwJTIwJTI2JTNBYWN0aXZlJTIwJTdCJTVDbiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dGxpbmUlM0ElMjBub25lJTNCJTVDbiUyMCUyMCUyMCUyMCUyMCUyMCU3RCU1Q24lMjAlMjAlMjAlMjAlN0QlMjIlMkMlMjJjb25maWclMjIlM0ElN0IlMjJicm93c2VycyUyMiUzQSU1QiUyMmxhc3QlMjAyJTIwdmVyc2lvbnMlMjIlMkMlMjIlMjBub3QlMjBkZWFkJTIyJTJDJTIyJTIwJTNFJTIwMC4yJTI1JTIyJTVEJTJDJTIybWluaW11bVZlbmRvckltcGxlbWVudGF0aW9ucyUyMiUzQTAlMkMlMjJzdGFnZSUyMiUzQTIlMkMlMjJsb2dpY2FsJTIyJTNBJTdCJTIyaW5saW5lRGlyZWN0aW9uJTIyJTNBJTIybGVmdC10by1yaWdodCUyMiUyQyUyMmJsb2NrRGlyZWN0aW9uJTIyJTNBJTIydG9wLXRvLWJvdHRvbSUyMiU3RCUyQyUyMmZlYXR1cmVzJTIyJTNBJTdCJTIybmVzdGluZy1ydWxlcyUyMiUzQSU3QiUyMm5vSXNQc2V1ZG9TZWxlY3RvciUyMiUzQWZhbHNlJTdEJTdEJTdEJTdE).

Now change directories to the components directory contaning a postcss file with the same settings as the one in the root, but additionally containing `postcss-lit` syntax:
`cd components`

Run postcss CLI on the example lit component
`npx postcss input.ts -o output.ts`

See below for what it outputs - the CSS nesting is incorrect:
```ts
static override styles = css`
.button {
-moz-columns: 3;
columns: 3;
}
&:focus,
&:active {
outline: none;
}
`;
```

Expected result:
```ts
static override styles = css`
.button {
-moz-columns: 3;
columns: 3;
}
.button:focus,
.button:active {
outline: none;
}
`;
```

Interestingly, it does work if the nested styles aren't compounded: This would work:
```css
.button {
&:focus {
outline: none;
}
}
```

But this doesn't:
```css
.button {
&:focus,
&:active {
outline: none;
}
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

The issue is about postcss-lit syntax not handling compounded nested selectors correctly. Start by examining the components/input.ts file in the provided reproduction repo to see the exact CSS-in-JS syntax. Look at the postcss-lit parser to understand how it processes template literals, especially nested rules with comma-separated selectors. Compare the output with the expected result to identify where the '&' replacement fails. Running the reproduction steps will show the bug in action.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
css, typescript
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。