Skip to content

fix(css): respect lightningcss cssModules.animation option - #1085

Closed
benjaminkincses wants to merge 1 commit into
rolldown:mainfrom
benjaminkincses:fix/cssmodules-animation-false
Closed

benjaminkincses wants to merge 1 commit into
rolldown:mainfrom
benjaminkincses:fix/cssmodules-animation-false

Conversation

@benjaminkincses

@benjaminkincses benjaminkincses commented Sep 22, 2026 •

Copy link
Copy Markdown

AI usage

  • No AI was used in this PR.
  • AI was used: Muse (Meta) agent, pair-programmed with the contributor
    • I have carefully reviewed the AI-generated content myself.

Description

css.lightningcss.cssModules (e.g. { animation: false }) was silently dropped whenever css.modules resolved to true (or was unset). In both transformWithLightningCSS and bundleWithLightningCSS (packages/css/src/lightningcss.ts), ...options.lightningcss was spread first and then cssModules: options.cssModules overwrote it, so keyframes were always renamed - desyncing them from CSS-variable animation references (lightningcss known limitation).

The fix merges instead of overwriting: object-form css.modules still wins over nested lightningcss options, and object-form lightningcss.cssModules is preserved when css.modules is just true (or unset).

Linked Issues

Closes #1083

Additional context

Regression tests added to packages/css/src/lightningcss.test.ts covering both transform and bundle paths: keyframes are kept global with animation: false, still renamed by default, and object-form configs merge.

In transformWithLightningCSS and bundleWithLightningCSS, the spread of
options.lightningcss was followed by cssModules: options.cssModules, so
cssModules: true (from css.modules: true) silently overwrote nested
lightningcss options such as cssModules: { animation: false }.

Merge the two configs instead: object-form css.modules wins over nested
lightningcss options, and object-form lightningcss.cssModules is preserved
when css.modules is just true (or unset).

Closes rolldown#1083
@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit b9be58c
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6ab2e7264f69e40008aa0ff9
😎 Deploy Preview https://deploy-preview-1085--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown@1085 -D
npm i https://pkg.pr.new/rolldown/tsdown@1085 -D
yarn add https://pkg.pr.new/rolldown/tsdown@1085.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1085 -D
npm i https://pkg.pr.new/rolldown/tsdown/create-tsdown@1085 -D
yarn add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1085.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1085 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1085 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1085.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1085 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1085 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1085.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1085 -D
npm i https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1085 -D
yarn add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1085.tgz -D

commit: b9be58c

sxzz commented Oct 23, 2026

Copy link
Copy Markdown
Member

Thanks for investigating this and adding regression tests. Closing in favor of #1103.

The merge here also applies lightningcss.cssModules when the internally resolved cssModules value is undefined or false. That can enable module scoping for ordinary CSS and during final minification, potentially renaming classes a second time and leaving the CSS out of sync with the JavaScript exports.

#1103 merges the options in resolveCssModulesConfig, after checking whether the file is a CSS module. This preserves tsdown's naming overrides and keeps module scoping out of ordinary CSS and final minification. It also adds regression coverage for CSS/SCSS, minification, naming precedence, and disabled CSS Modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

animation: false lightningcss option not working

2 participants