Skip to content

Commit

Permalink
Bump lightningcss dependency (#11388)
Browse files Browse the repository at this point in the history
* bump `lightningcss`

* allow for non-standard selector combinators such as `::deep`

* just use Prettier when comparing CSS results

We were using 2 different engines where the stable one was not using
Lightning CSS and the Oxide one was using Lightning CSS.

To ensure that we didn't have to rewrite every single test expectation,
the `toMatchFormattedCss` parsed both the actual and expected value
using Lightning CSS (to make the result similar), then it used Prettier
to make it... pretty.

Right now we _only_ use Lightning CSS, which means that we can drop the
additional lightningcss format step and just use Prettier on both the
actual and expected values.

Pretty also only prettifies the CSS, it doesn't rewrite it. E.g.:
`@media (min-width: 768px)` will not be optimized to `@media (width >=
768px)`, that's something that Lightning CSS does for us.

This will require some changes in our test output, but it will be
consistent afterwards because there won't be hidden transformation steps
anymore. Because up until now it could be that the actual result was
`color: black` but the tests showed `color: #000` (because it is
shorter).

This change will reflect reality.

* update tests based on previous commit

* only use `toMatchFormattedCss` instead of `toMatchCss`

They both do the exact same thing right now. While `toMatchCss` is
shorter, `toMatchFormattedCss` makes a bit more sense since we are
comparing the Prettier results.

* update integration tests
  • Loading branch information
RobinMalfait committed Jun 7, 2023
1 parent 571c27e commit e572dc6
Show file tree
Hide file tree
Showing 60 changed files with 908 additions and 936 deletions.
28 changes: 14 additions & 14 deletions integrations/content-resolution/tests/content.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ it('looks in the CWD by default', async () => {

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-static-positive\] {
--tw-content: real-static-positive;
content: var(--tw-content);
Expand All @@ -69,7 +69,7 @@ it('looks in the CWD by default', async () => {

result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)
})

it('looks in the CWD for non-config-relative paths', async () => {
Expand All @@ -88,7 +88,7 @@ it('looks in the CWD for non-config-relative paths', async () => {

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-static-positive\] {
--tw-content: real-static-positive;
content: var(--tw-content);
Expand All @@ -97,7 +97,7 @@ it('looks in the CWD for non-config-relative paths', async () => {

result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)
})

it('can look for content files relative to the config', async () => {
Expand All @@ -113,12 +113,12 @@ it('can look for content files relative to the config', async () => {
// Here `./real` doesn't exist next to the config in the root directory
let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(css``)
expect(result.css).toMatchFormattedCss(css``)

// But here it `./real` does exist next to the config in the `./src` directory!
result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-static-positive\] {
--tw-content: real-static-positive;
content: var(--tw-content);
Expand All @@ -143,7 +143,7 @@ it('it handles ignored globs correctly when not relative to the config', async (

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-dynamic-positive\] {
--tw-content: real-dynamic-positive;
content: var(--tw-content);
Expand All @@ -157,7 +157,7 @@ it('it handles ignored globs correctly when not relative to the config', async (
// But here it `./real` does exist next to the config in the `./src` directory!
result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)
})

it('it handles ignored globs correctly when relative to the config', async () => {
Expand All @@ -177,12 +177,12 @@ it('it handles ignored globs correctly when relative to the config', async () =>

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)

// But here it `./real` does exist next to the config in the `./src` directory!
result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-dynamic-positive\] {
--tw-content: real-dynamic-positive;
content: var(--tw-content);
Expand Down Expand Up @@ -215,7 +215,7 @@ it('it can resolve symlinks for files when not relative to the config', async ()

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-dynamic-positive\] {
--tw-content: real-dynamic-positive;
content: var(--tw-content);
Expand All @@ -237,7 +237,7 @@ it('it can resolve symlinks for files when not relative to the config', async ()
// But here it `./real` does exist next to the config in the `./src` directory!
result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)
})

it('it can resolve symlinks for files when relative to the config', async () => {
Expand All @@ -261,12 +261,12 @@ it('it can resolve symlinks for files when relative to the config', async () =>

let result = await build({ cwd: path.resolve(__dirname, '..') })

expect(result.css).toMatchCss(``)
expect(result.css).toMatchFormattedCss(``)

// But here it `./real` does exist next to the config in the `./src` directory!
result = await build({ cwd: path.resolve(__dirname, '../src') })

expect(result.css).toMatchCss(css`
expect(result.css).toMatchFormattedCss(css`
.content-\[real-dynamic-positive\] {
--tw-content: real-dynamic-positive;
content: var(--tw-content);
Expand Down
10 changes: 5 additions & 5 deletions integrations/parcel/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -352,11 +352,11 @@ describe('watcher', () => {

expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
/* prettier-ignore */
.btn {
border-radius: .25rem;
padding: .25rem .5rem;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
}
.font-bold {
font-weight: 700;
}
Expand Down
13 changes: 6 additions & 7 deletions integrations/postcss-cli/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -247,12 +247,11 @@ describe('watcher', () => {

expect(await readOutputFile('main.css')).toIncludeCss(
css`
/* prettier-ignore */
.btn {
border-radius: 0.25rem;
z-index: 0;
padding: 0.25rem 0.5rem;
}
z-index: 0;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
}
.font-bold {
font-weight: 700;
}
Expand Down
4 changes: 2 additions & 2 deletions integrations/rollup-sass/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down
6 changes: 3 additions & 3 deletions integrations/rollup/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -334,8 +334,8 @@ describe('watcher', () => {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.btn {
border-radius: 0.25rem;
z-index: 0;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
}
.font-bold {
Expand Down
16 changes: 5 additions & 11 deletions integrations/tailwindcss-cli/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Build command', () => {
theme: {
extend: {
fontWeight: {
bold: 'BOLD',
bold: 'bold',
},
},
},
Expand All @@ -171,7 +171,7 @@ describe('Build command', () => {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.font-bold {
font-weight: BOLD;
font-weight: bold;
}
`
)
Expand Down Expand Up @@ -231,11 +231,8 @@ describe('Build command', () => {
}
.btn-after {
padding: 0.25rem 0.5rem;
display: flex;
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
}
`
)
Expand Down Expand Up @@ -281,11 +278,8 @@ describe('Build command', () => {
}
.btn-after {
padding: 0.25rem 0.5rem;
display: flex;
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
}
`
)
Expand Down Expand Up @@ -437,7 +431,7 @@ describe('Build command', () => {
css`
@media (min-width: 768px) {
.md\:something-cool {
color: blue;
color: #00f;
}
}
`
Expand Down
6 changes: 0 additions & 6 deletions integrations/tailwindcss-cli/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ describe('watcher', () => {
expect(await readOutputFile('main.css')).not.toIncludeCss(
css`
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand All @@ -898,7 +897,6 @@ describe('watcher', () => {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand Down Expand Up @@ -938,7 +936,6 @@ describe('watcher', () => {
expect(await readOutputFile('main.css')).not.toIncludeCss(
css`
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand All @@ -952,7 +949,6 @@ describe('watcher', () => {
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand Down Expand Up @@ -1037,7 +1033,6 @@ describe('watcher', () => {
}
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand Down Expand Up @@ -1082,7 +1077,6 @@ describe('watcher', () => {
}
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
}
`
Expand Down
11 changes: 4 additions & 7 deletions integrations/vite/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -373,12 +373,9 @@ describe('watcher', () => {
expect(await fetchCSS()).toIncludeCss(
css`
.btn {
border-radius: 0.25rem;
z-index: 0;
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
border-radius: 0.25rem;
padding: 0.25rem 0.5rem;
}
.font-bold {
font-weight: 700;
Expand Down
4 changes: 2 additions & 2 deletions integrations/webpack-4/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('watcher', () => {
.font-bold {
font-weight: 700;
}
@media (min-width: 768px) {
@media (width >= 768px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('watcher', () => {
.font-bold {
font-weight: bold;
}
@media (min-width: 800px) {
@media (width >= 800px) {
.md\:font-medium {
font-weight: 500;
}
Expand Down

0 comments on commit e572dc6

Please sign in to comment.