diff --git a/CHANGELOG.md b/CHANGELOG.md index 77cf0d1f345..403afddfb20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,20 +2,21 @@ ## Unreleased -* Add support for some new CSS rules ([#2115](https://github.com/evanw/esbuild/issues/2115), [#2116](https://github.com/evanw/esbuild/issues/2116)) +* Add support for some new CSS rules ([#2115](https://github.com/evanw/esbuild/issues/2115), [#2116](https://github.com/evanw/esbuild/issues/2116), [#2117](https://github.com/evanw/esbuild/issues/2117)) - This release adds support for [`@font-palette-values`](https://drafts.csswg.org/css-fonts-4/#font-palette-values) and [`@counter-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style): + This release adds support for [`@font-palette-values`](https://drafts.csswg.org/css-fonts-4/#font-palette-values), [`@counter-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style), and [`@font-feature-values`](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-feature-values). This means esbuild will now pretty-print and minify these rules better since it now better understands the internal structure of these rules: ```css /* Original code */ @font-palette-values Foo { base-palette: 1; } @counter-style bar { symbols: b a r; } + @font-feature-values Bop { @styleset { test: 1; } } /* Old output (with --minify) */ - @font-palette-values Foo{base-palette: 1;}@counter-style bar{symbols: b a r;} + @font-palette-values Foo{base-palette: 1;}@counter-style bar{symbols: b a r;}@font-feature-values Bop{@styleset {test: 1;}} /* New output (with --minify) */ - @font-palette-values Foo{base-palette:1}@counter-style bar{symbols:b a r} + @font-palette-values Foo{base-palette:1}@counter-style bar{symbols:b a r}@font-feature-values Bop{@styleset{test:1}} ``` ## 0.14.27 diff --git a/internal/css_parser/css_parser.go b/internal/css_parser/css_parser.go index 5af12a1e7cf..0f8f75dc71a 100644 --- a/internal/css_parser/css_parser.go +++ b/internal/css_parser/css_parser.go @@ -689,6 +689,17 @@ var specialAtRules = map[string]atRuleKind{ // Documentation: https://developer.mozilla.org/en-US/docs/Web/CSS/@counter-style // Reference: https://drafts.csswg.org/css-counter-styles/#the-counter-style-rule "counter-style": atRuleDeclarations, + + // Documentation: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-feature-values + // Reference: https://drafts.csswg.org/css-fonts/#font-feature-values + "font-feature-values": atRuleDeclarations, + "annotation": atRuleDeclarations, + "character-variant": atRuleDeclarations, + "historical-forms": atRuleDeclarations, + "ornaments": atRuleDeclarations, + "styleset": atRuleDeclarations, + "stylistic": atRuleDeclarations, + "swash": atRuleDeclarations, } type atRuleValidity uint8 diff --git a/internal/css_parser/css_parser_test.go b/internal/css_parser/css_parser_test.go index 01d641e1c83..73298bb6431 100644 --- a/internal/css_parser/css_parser_test.go +++ b/internal/css_parser/css_parser_test.go @@ -882,6 +882,26 @@ func TestAtRule(t *testing.T) { symbols: ◰ ◳ ◲ ◱; suffix: ": "; } +`) + + // https://drafts.csswg.org/css-fonts/#font-feature-values + expectPrinted(t, ` + @font-feature-values Roboto { + font-display: swap; + } + `, `@font-feature-values Roboto { + font-display: swap; +} +`) + expectPrinted(t, ` + @font-feature-values Bongo { + @swash { ornate: 1 } + } + `, `@font-feature-values Bongo { + @swash { + ornate: 1; + } +} `) }