Skip to content

Commit c0f2922

Browse files
committed
Always emit keyframes registered in addUtilities (#14747)
Fixes #14732 cc @philipp-spiess this look like an okay fix?
1 parent 338a780 commit c0f2922

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Ensure color opacity modifiers work with OKLCH colors ([#14741](https://github.com/tailwindlabs/tailwindcss/pull/14741))
2121
- Ensure changes to the input CSS file result in a full rebuild ([#14744](https://github.com/tailwindlabs/tailwindcss/pull/14744))
2222
- Add `postcss` as a dependency of `@tailwindcss/postcss` ([#14750](https://github.com/tailwindlabs/tailwindcss/pull/14750))
23+
- Always emit keyframes registered in `addUtilities` ([#14747](https://github.com/tailwindlabs/tailwindcss/pull/14747))
2324
- Ensure loading stylesheets via the `?raw` and `?url` static asset query works when using the Vite plugin ([#14716](https://github.com/tailwindlabs/tailwindcss/pull/14716))
2425
- _Upgrade (experimental)_: Migrate `flex-grow` to `grow` and `flex-shrink` to `shrink` ([#14721](https://github.com/tailwindlabs/tailwindcss/pull/14721))
2526
- _Upgrade (experimental)_: Minify arbitrary values when printing candidates ([#14720](https://github.com/tailwindlabs/tailwindcss/pull/14720))

integrations/cli/plugins.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ test(
154154
candidate`duration-350`,
155155
'transition-duration: 350ms',
156156
'animation-duration: 350ms',
157+
'@keyframes enter {',
157158
])
158159
},
159160
)

packages/tailwindcss/src/compat/plugin-api.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,39 @@ describe('theme', async () => {
7171
`)
7272
})
7373

74+
test('keyframes added via addUtilities are appended to the AST', async () => {
75+
let input = css`
76+
@tailwind utilities;
77+
@plugin "my-plugin";
78+
`
79+
80+
let compiler = await compile(input, {
81+
loadModule: async (id, base) => {
82+
return {
83+
base,
84+
module: plugin(function ({ addUtilities, theme }) {
85+
addUtilities({
86+
'@keyframes enter': {
87+
from: {
88+
opacity: 'var(--tw-enter-opacity, 1)',
89+
},
90+
},
91+
})
92+
}),
93+
}
94+
},
95+
})
96+
97+
expect(compiler.build([])).toMatchInlineSnapshot(`
98+
"@keyframes enter {
99+
from {
100+
opacity: var(--tw-enter-opacity, 1);
101+
}
102+
}
103+
"
104+
`)
105+
})
106+
74107
test('plugin theme can extend colors', async () => {
75108
let input = css`
76109
@theme reference {

packages/tailwindcss/src/compat/plugin-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export function buildPluginApi(
204204

205205
for (let [name, css] of Object.entries(utils)) {
206206
if (name.startsWith('@keyframes ')) {
207-
designSystem.theme.addKeyframes(rule(name, objectToAst(css)))
207+
ast.push(rule(name, objectToAst(css)))
208208
continue
209209
}
210210

0 commit comments

Comments
 (0)