Skip to content

v6 prints errors during vite dev: [postcss] Unknown word xxx #1192

@echocrow

Description

@echocrow

Describe the bug

Originally reported here: #1186 (comment)

After upgrading to v6, running vite dev can cause excessive error logs in the terminal in the form of:

[vite] (ssr) Error when evaluating SSR module <file-path>: [postcss] <file-path:line:col>: Unknown word <word>
  Plugin: vite:css
  ...

(exact plugin being reported may vary)

This issue is present both under vite ^v6.3.5 and vite ^v7.0.0.

Downgrading @sveltejs/vite-plugin-svelte back to v5.0.3, this issue is not present.

Reproduction URL

https://stackblitz.com/edit/sveltejs-vite-plugin-svelte-vite-ssr-bug?file=src%2Froutes%2F%2Bpage.svelte

Reproduction

Some pieces that were required to replicate this:

  • a postcss config with at least one plugin
  • a browser-only lazy-imported component that uses postcss

Given the repro:

  1. Run pnpm dev
  2. Then click "reload" in the preview pane (or browser tab during local dev)

(in our production repo, hitting refresh is not needed for the error to be logged; unsure why this minimal repo does need the manual refresh)

Logs

vite:cache [memory] __sveltekit/paths +6s
  vite:resolve 0.04ms /src/routes/Foobar.svelte?inline&svelte&type=style&lang.css -> /home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/src/routes/Foobar.svelte?inline&svelte&type=style&lang.css +6s
  vite:load 3.42ms [fs] /src/routes/Foobar.svelte?inline&svelte&type=style&lang.css +6s
2:04:33 PM [vite] (ssr) Error when evaluating SSR module /src/routes/Foobar.svelte?inline&svelte&type=style&lang.css: [postcss] /home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/src/routes/Foobar.svelte?inline&svelte&type=style&lang.css:7:255: Unknown word '{'
  Plugin: vite:css
  File: /home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/src/routes/Foobar.svelte?inline&svelte&type=style&lang.css:7:254
  5  |  <p>Under <code>@sveltejs/[email protected].0</code>, terminal will print:</p>
  6  |  
  7  |  <pre>[vite] (ssr) Error when evaluating SSR module /src/routes/Foobar.svelte?inline&svelte&type=style&lang.css: [postcss] /home/projects/sveltejs-kit-template-default-lxddwbfe/src/routes/Foobar.svelte?inline&svelte&type=style&lang.css:9:1: Unknown word {'{'}some word{'}'}
     |                                                                                                                                                                                                                                                                ^
  8  |    Plugin: vite:css
  9  |    ...
      at CssSyntaxError (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/css-syntax-error.js:37:13)
      at error (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/input.js:135:16)
      at unknownWord (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/parser.js:595:22)
      at other (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/parser.js:437:12)
      at parse (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/parser.js:472:16)
      at parse (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/parse.js:11:12)
      at LazyResult (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/lazy-result.js:165:16)
      at process (/home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/postcss/lib/processor.js:53:14)
      at runPostCSS (file:///home/projects/sveltejs-vite-plugin-svelte-vite-ssr-bug/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:43887:52)

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 20.19.1 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 10.8.2 - /usr/local/bin/npm
  pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
  @sveltejs/kit: 2.27.0 => 2.27.0 
  @sveltejs/vite-plugin-svelte: 6.1.0 => 6.1.0 
  svelte: 5.37.3 => 5.37.3 
  vite: 6.3.5 => 6.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions