fix(manifest): use resolved virtual module ID for CSS imports in Vite 8 - #2293
fix(manifest): use resolved virtual module ID for CSS imports in Vite 8#2293waterWang wants to merge 1 commit into
Conversation
Virtual CSS modules (e.g. UnoCSS /__uno.css) have dep.file === null and dep.id starting with \0. Using dep.url (e.g. "/__uno.css") in the generated import() fails in Vite 8 module runner with ERR_DENIED_ID because the URL looks like a nonexistent filesystem path. Fix: use dep.id (the resolved virtual module ID, e.g. \0virtual:uno.css) for virtual modules. wrapId() converts it to /@id/__x00__virtual:uno.css, a safe form that Vite's /@id/ resolution plugin can resolve through the plugin pipeline. Real CSS files (dep.file is set) keep using dep.url. Fixes solidjs#2292
|
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
|
@katywings thoughts on this? |
|
Upstream tracking is now available at unocss/unocss#5271. I tested the published package from this PR against the official SolidStart The actual UnoCSS module node is: {
id: "/__uno.css",
url: "/__uno.css",
file: "/__uno.css"
}Therefore |
Description
Virtual CSS modules (e.g. UnoCSS
/__uno.css) havedep.file === nullanddep.idstarting with\0. Usingdep.url(e.g./__uno.css) in the generatedimport()call fails in Vite 8 module runner withERR_DENIED_IDbecause the URL looks like a nonexistent filesystem path.Root Cause
In
findStylesInModuleGraph, the code storesstyles[dep.id] = dep.urlfor all CSS modules. For virtual modules:dep.url=/__uno.css(the URL form, not resolvable as a real file)dep.id=\0virtual:uno.css(the resolved virtual module ID)The generated code does
import("/__uno.css?inline")— Vite 8's module runner rejects this ID because it's neither a real file path nor a\0-prefixed virtual module.Fix
For virtual modules (
dep.file === null), usedep.id(the resolved ID) instead ofdep.url.wrapId()converts\0virtual:uno.cssto/@id/__x00__virtual:uno.css— a safe form that Vite's/@id/resolution plugin can resolve through the plugin pipeline.Real CSS files (
dep.fileis set) keep usingdep.urlas before.Related
Fixes #2292