`@slidev/conditional-styles` virtual module is empty after upgrading to 52.15.0 — theme styles & user `style.css` no longer applied
pending triage
**Describe the bug**
After upgrading from `@slidev/cli@52.14.2` to `52.15.0`, the `/@slidev/conditional-styles` virtual module is generated empty:
```js
/* #__PURE__ */ Object.assign({})
/* #__PURE__ */ Object.assign({})
/* #__PURE__ */ Object.assign({})
import "/node_modules/.pnpm/katex@0.16.45/node_modules/katex/dist/katex.min.css"
```
Each of the three `Object.assign({})` corresponds to one of the `roots` (theme / addons / userRoot). The `import.meta.glob` calls produce zero matches across the board, which means:
- The user's project-root `style.css` (or `styles/index.css` / `styles.css`) is no longer loaded.
- A theme's `styles/index.css` is no longer loaded — for many themes the entire visual styling silently breaks.
Downgrading to `52.14.2` immediately restores the expected behavior.
**Suspected cause** (not fully verified)
Looking at the diff between 52.14.2 and 52.15.0, the relevant change appears to be the `makeAbsoluteImportGlob` helper, which is hinted at in the v52.15.0 release notes:
> *"Glob import should relative to self id"*
In 52.14.2:
```js
function makeAbsoluteImportGlob(userRoot, globs, options = {}) {
const relativeGlobs = globs.map((glob) => `./${slash(relative(userRoot, glob))}`);
const opts = { eager: true, exhaustive: true, base: "/", ...options };
return `import.meta.glob(${JSON.stringify(relativeGlobs)}, ${JSON.stringify(opts)})`;
}
```
In 52.15.0:
```js
function makeAbsoluteImportGlob(self, globs, options = {}) {
const relativeGlobs = globs.map((glob) => `${slash(relative(self, glob))}`);
const opts = { eager: true, exhaustive: true, ...options };
return `import.meta.glob(${JSON.stringify(relativeGlobs)}, ${JSON.stringify(opts)})`;
}
```
The new version is called from `templateConditionalStyles.getContent` with `self = "/@slidev/conditional-styles"` (the virtual module id). `relative(self, glob)` then produces patterns like:
```
"../../Users/Donald/Documents/.../slides/style.{ts,js,css}"
```
…and Vite's `transformGlobImport` rejects these for virtual modules:
```
Error: In virtual modules, all globs must start with '/'
```
I tried patching `makeAbsoluteImportGlob` to emit absolute-style globs (`/C:/Users/.../style.{ts,js,css}`) directly, hoping Vite would accept them — but Vite interprets a leading `/` as root-relative and joins it onto the project root again, producing nonsense paths like `<root>/C:/Users/.../style.{ts,js,css}` that match nothing. So a simple "just prepend `/`" fix does not work, and I did not investigate further.
I'm not 100% certain that the `makeAbsoluteImportGlob` change is the *only* cause — there may be additional pieces I missed — but the symptom and the diff line up cleanly with that change.
**Minimal reproduction**
My theme `slidev-theme-frankfurt` (https://github.com/MuTsunTsai/slidev-theme-frankfurt) becomes completely unstyled when upgraded to 52.15.0:
1. `git clone https://github.com/MuTsunTsai/slidev-theme-frankfurt`
2. Bump `@slidev/cli` and `@slidev/types` to `52.15.0` in `package.json`
3. `pnpm install && pnpm dev`
4. Observe that the theme's styles (defined in `styles/index.css`) are not applied to the slides.
5. Fetch `/@slidev/conditional-styles` from the dev server and observe that the resolved module body contains the empty `Object.assign({})` lines shown above instead of the expected list of style imports.
6. Downgrade to `52.14.2` and the visuals return to normal.
The path of the project does not seem to matter — I reproduced this on two different projects on Windows 11, one with a plain ASCII path (`C:\Users\XXX\Documents\Projects\Template\slidev-theme-frankfurt`) and another with spaces and non-ASCII characters in the path. Both behave the same way.
**Environment**
- Slidev version: `52.15.0` (regression) / `52.14.2` (working)
- Browser: Chrome 144 (also reproduced in Edge)
- OS: Windows 11
- Node: 22.15.1
- Package manager: pnpm
- Vite: `8.0.10`
0 条评论