Skip to content

fix(css): strip .module from CSS output filenames#866

Merged
sxzz merged 1 commit intomainfrom
issue-864
Mar 25, 2026
Merged

fix(css): strip .module from CSS output filenames#866
sxzz merged 1 commit intomainfrom
issue-864

Conversation

@sxzz
Copy link
Member

@sxzz sxzz commented Mar 25, 2026

  • This PR contains AI-generated code, but I have carefully reviewed it myself. Otherwise, my PR may be closed.

Description

When tsdown processes CSS module files (e.g., Component.module.css), the output CSS retained the .module suffix. Downstream bundlers would then re-process it as a CSS module, causing styles to be lost. This adds a toCssFileName() utility that strips .module when converting JS chunk filenames to CSS filenames, applied at all 3 sites where this conversion happens.

Linked Issues

Fixes #864

Additional context

The fix uses a single regex (?:\.module)?(\.[cm]?js)$.css which handles both module and non-module filenames. All existing tests pass unchanged since they use JS entries that import .module.css files (so CSS filenames derive from the JS chunk name, not the CSS module filename).

When tsdown processes CSS module files (e.g., Component.module.css),
the output CSS retained the .module suffix. Downstream bundlers would
then re-process it as a CSS module, causing styles to be lost.

Fixes #864
@netlify
Copy link

netlify bot commented Mar 25, 2026

Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit dd21461
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/69c43b5b55cb930008969335
😎 Deploy Preview https://deploy-preview-866--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 25, 2026

Open in StackBlitz

tsdown

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

create-tsdown

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

@tsdown/css

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

@tsdown/exe

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

tsdown-migrate

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

commit: dd21461

@sxzz sxzz changed the title fix(css): strip .module from CSS output filenames fix(css): strip .module from CSS output filenames Mar 25, 2026
@sxzz sxzz merged commit 03ade19 into main Mar 25, 2026
15 checks passed
@sxzz sxzz deleted the issue-864 branch March 25, 2026 19:48
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.

CSS modules and css.inject: true maintain *.modules.css file names

1 participant