Skip to content

fix(css): merge css in import order when splitting is disabled - #1089

Open
MFA-G wants to merge 1 commit into
rolldown:mainfrom
MFA-G:fix/css-merge-import-order
Open

MFA-G wants to merge 1 commit into
rolldown:mainfrom
MFA-G:fix/css-merge-import-order

Conversation

@MFA-G

@MFA-G MFA-G commented Sep 28, 2026

Copy link
Copy Markdown

AI usage

  • No AI was used in this PR.
  • AI was used: Claude Code + Claude Opus
    • I have carefully reviewed the AI-generated content myself.

Description

With css.splitting: false, CssPostPlugin pushed each chunk's CSS from renderChunk, so style.css followed render order. When a module that imports CSS is shared by several entries, it gets its own chunk, and that chunk's CSS was appended after the entry's own CSS even though the entry imports it first.

This PR stores each chunk's CSS under its preliminary file name in renderChunk, then merges in generateBundle by walking the entry chunks the way Vite does for cssCodeSplit: false: a chunk's static imports come first, then the chunk itself, and dynamically imported chunks are added last.

Two tests are added to tests/css.test.ts, the repro from the issue and a case with a dynamic import. Both fail on main and pass with this change. pnpm test run, pnpm lint and pnpm typecheck all pass.

Linked Issues

fixes #1086

Additional context

The splitting: true path is unchanged.

Copilot AI lite review requested due to automatic review settings September 28, 2026 01:25
@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit 52b59cc
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6ab9c1f3917b44000866c031
😎 Deploy Preview https://deploy-preview-1089--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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

tsdown

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

create-tsdown

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

@tsdown/css

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

@tsdown/exe

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

tsdown-migrate

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

commit: 52b59cc

This branch has not been deployed

No deployments
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.splitting: false puts a shared chunk's CSS after the entries that import it

2 participants