Skip to content

fix(css): ignore css imports with URL query#806

Merged
sxzz merged 2 commits intomainfrom
ocavue/css-raw
Mar 7, 2026
Merged

fix(css): ignore css imports with URL query#806
sxzz merged 2 commits intomainfrom
ocavue/css-raw

Conversation

@ocavue
Copy link
Copy Markdown
Collaborator

@ocavue ocavue commented Mar 7, 2026

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

Description

Current, you cannot use import cssText from './foo.css?raw' with unplugin-raw because @tsdown/css handles this ID.

This PR makes tsdown @tsdown/css ignore any CSS files with URL queries (e.g. ?raw).

Linked Issues

See also #804

Additional context

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 7, 2026

Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit e3d952c
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/69ac1e126771dc0008dca347
😎 Deploy Preview https://deploy-preview-806--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
Copy Markdown

pkg-pr-new bot commented Mar 7, 2026

Open in StackBlitz

tsdown

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

create-tsdown

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

@tsdown/css

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

@tsdown/exe

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

tsdown-migrate

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

commit: 8e6389c

@ocavue ocavue marked this pull request as ready for review March 7, 2026 07:29
@ocavue ocavue requested review from Copilot and sxzz March 7, 2026 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates tsdown’s CSS handling so that module IDs with URL queries (e.g. foo.css?raw) are ignored by the built-in/advanced CSS plugins, allowing other plugins (like unplugin-raw) to process them.

Changes:

  • Updated CSS/preprocessor detection regexes to only match file extensions at end-of-string (no ?query).
  • Added a Vitest case + snapshot covering import './foo.css?raw' working via unplugin-raw.
  • Added unplugin-raw as a dev dependency (workspace catalog + lockfile updates).

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/css.test.ts Adds a regression test ensuring .css?raw can be handled by unplugin-raw.
tests/snapshots/css/handle-css-raw-with-unplugin-raw.snap.md Snapshot for the new .css?raw test output.
src/features/css/preprocessors.ts Stops treating *.css?query / *.scss?query etc as CSS/preprocessor inputs.
src/features/css/plugin.ts Makes the built-in CSS plugin ignore .css?query by tightening RE_CSS.
packages/css/src/preprocessors.ts Mirrors the CSS/preprocessor detection change for the @tsdown/css package.
package.json Adds unplugin-raw to devDependencies via the workspace catalog.
pnpm-workspace.yaml Adds unplugin-raw to the dev catalog.
pnpm-lock.yaml Locks unplugin-raw resolution.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sxzz sxzz changed the title fix: ignore css imports with URL query fix(css): ignore css imports with URL query Mar 7, 2026
@sxzz sxzz merged commit c1d23a9 into main Mar 7, 2026
15 checks passed
@sxzz sxzz deleted the ocavue/css-raw branch March 7, 2026 12: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.

3 participants