Skip to content

Commit 86f9c6f

Browse files
authored
Simplify browserslist setup by relying on defaults (#11412)
* use `defaults` for `browserslist` + some features that we require for Tailwind to work. * simplify Lightning CSS features Always transpile `Nesting`, never transpile `LogicalProperties`. * bump caniuse-lite (`npx browserslist@latest --update-db`) * reflect changes in the tests * update changelog
1 parent 3be258c commit 86f9c6f

File tree

6 files changed

+18
-41
lines changed

6 files changed

+18
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Add `svh`, `lvh`, and `dvh` values to default `height`/`min-height`/`max-height` theme ([#11317](https://github.com/tailwindlabs/tailwindcss/pull/11317))
2929
- Add `has-*` variants for `:has(...)` pseudo-class ([#11318](https://github.com/tailwindlabs/tailwindcss/pull/11318))
3030
- Add `text-wrap` utilities including `text-balance` ([#11320](https://github.com/tailwindlabs/tailwindcss/pull/11320))
31-
- Explicitly configure Lightning CSS features, and prefer user browserslist over default browserslist ([#11402](https://github.com/tailwindlabs/tailwindcss/pull/11402))
31+
- Explicitly configure Lightning CSS features, and prefer user browserslist over default browserslist ([#11402](https://github.com/tailwindlabs/tailwindcss/pull/11402), [#11412](https://github.com/tailwindlabs/tailwindcss/pull/11412))
3232

3333
### Changed
3434

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@
8787
"sucrase": "^3.32.0"
8888
},
8989
"browserslist": [
90-
"chrome >= 103",
91-
"firefox >= 102",
90+
"defaults and supports css-variables and supports css-matches-pseudo",
9291
"safari >= 14"
9392
],
9493
"jest": {

src/cli/build/plugin.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,12 @@ import { flagEnabled } from '../../featureFlags'
2828

2929
async function lightningcss(result, { map = true, minify = true } = {}) {
3030
try {
31-
let includeFeatures = Features.Nesting
32-
let excludeFeatures = 0
33-
3431
let resolvedBrowsersListConfig = browserslist.findConfig(
3532
result.opts.from ?? process.cwd()
3633
)?.defaults
3734
let defaultBrowsersListConfig = pkg.browserslist
3835
let browsersListConfig = resolvedBrowsersListConfig ?? defaultBrowsersListConfig
3936

40-
if (browsersListConfig.join(',') === defaultBrowsersListConfig.join(',')) {
41-
includeFeatures |=
42-
Features.ColorFunction | Features.OklabColors | Features.LabColors | Features.P3Colors
43-
44-
excludeFeatures |=
45-
Features.HexAlphaColors | Features.LogicalProperties | Features.SpaceSeparatedColorNotation
46-
}
47-
4837
let transformed = lightning.transform({
4938
filename: result.opts.from || 'input.css',
5039
code: Buffer.from(result.css, 'utf-8'),
@@ -55,8 +44,8 @@ async function lightningcss(result, { map = true, minify = true } = {}) {
5544
drafts: {
5645
nesting: true,
5746
},
58-
include: includeFeatures,
59-
exclude: excludeFeatures,
47+
include: Features.Nesting,
48+
exclude: Features.LogicalProperties,
6049
})
6150

6251
return Object.assign(result, {

src/plugin.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,12 @@ module.exports = function tailwindcss(configOrPath) {
4949
let intermediateMap = intermediateResult.map?.toJSON?.() ?? map
5050

5151
try {
52-
let includeFeatures = Features.Nesting
53-
let excludeFeatures = 0
54-
5552
let resolvedBrowsersListConfig = browserslist.findConfig(
5653
result.opts.from ?? process.cwd()
5754
)?.defaults
5855
let defaultBrowsersListConfig = require('../package.json').browserslist
5956
let browsersListConfig = resolvedBrowsersListConfig ?? defaultBrowsersListConfig
6057

61-
if (browsersListConfig.join(',') === defaultBrowsersListConfig.join(',')) {
62-
includeFeatures |=
63-
Features.ColorFunction | Features.OklabColors | Features.LabColors | Features.P3Colors
64-
65-
excludeFeatures |=
66-
Features.HexAlphaColors |
67-
Features.LogicalProperties |
68-
Features.SpaceSeparatedColorNotation
69-
}
70-
7158
let transformed = lightningcss.transform({
7259
filename: result.opts.from,
7360
code: Buffer.from(intermediateResult.css),
@@ -81,8 +68,8 @@ module.exports = function tailwindcss(configOrPath) {
8168
nonStandard: {
8269
deepSelectorCombinator: true,
8370
},
84-
include: includeFeatures,
85-
exclude: excludeFeatures,
71+
include: Features.Nesting,
72+
exclude: Features.LogicalProperties,
8673
})
8774

8875
let code = transformed.code.toString()

tests/variants.test.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@
157157
.marker\:flex::marker {
158158
display: flex;
159159
}
160-
.selection\:flex ::selection,
160+
.selection\:flex ::selection {
161+
display: flex;
162+
}
161163
.selection\:flex::selection {
162164
display: flex;
163165
}

0 commit comments

Comments
 (0)