Skip to content

fix: don't log an error for vite configs without a Svelte plugin - #3091

Merged
dummdidumm merged 1 commit into
sveltejs:masterfrom
Socialpranker:fix/3080-no-error-for-vite-config-without-svelte
Aug 12, 2026
Merged

dummdidumm merged 1 commit into
sveltejs:masterfrom
Socialpranker:fix/3080-no-error-for-vite-config-without-svelte

Conversation

@Socialpranker

Copy link
Copy Markdown
Contributor

Partially addresses #3080.

What this fixes

Since 4.6.0 the config loader crawls for vite.config.* files. In a monorepo that means it also visits packages which don't use Svelte at all, and for each of those it logs an error:

Error while loading config at  .../packages/package-a/vite.config.ts
Error: No Svelte configuration found in vite config. Is @sveltejs/vite-plugin-svelte configured?

package-a not using Svelte isn't a problem, so reporting it as an error is misleading — the reporter in #3080 hit exactly this.

loadConfig already distinguishes the two cases, it just wasn't being used to: a config that genuinely fails to load comes back as { error, ... }, while a config that loads fine but has no Svelte plugin falls through and comes back as undefined. Only the first is an error. This checks result?.error and keeps Logger.error for that case, logging the other at the normal level.

Everything else is deliberately untouched. The fallback preprocessor and loadConfigError are still set exactly as before, so the retry logic in loadConfigs (!config || config.loadConfigError), addFallbackConfig, and the diagnostics path in getDiagnostics.ts all behave identically. This is only about the log level.

What this does not fix

#3080 raises a second, larger question: how svelte-check should work in a monorepo with several Svelte packages, each with its own vite.config.ts, when --config takes a single path. That's a design question about --config/ExplicitConfigScope rather than a bug, so I left it alone — happy to follow up if you decide on a direction.

Verification

Two tests added, both driven from the actual behaviour rather than written to match the patch:

  • no svelte plugin → no error logged. Fails on main (Logger.error is called with the "No Svelte configuration found in vite config" message), passes with the fix.
  • config genuinely fails to load → error still logged. Passes both before and after, i.e. it pins the behaviour the fix must not break.

The second test builds ConfigLoader directly rather than through the createConfigLoader helper, because that helper always wraps its result in { config } and so can't express a failed load. I found that out by tracing what the mock actually returned — my first attempt at the test passed for the wrong reason.

Checks run locally on Node 22:

  • configLoader.test.ts: 15 passing.
  • Full svelte-language-server suite: 819 passing, 21 pending, 3 failing — all three in SvelteCheckTSGoDiagnosticsProvider. Those also fail on a clean main (5 failing there, the set moves between runs), so they're pre-existing and unrelated to this change.
  • prettier --check clean on the touched files, tsc --noEmit exits 0.

Changeset included.

Written with Claude Code (Claude Opus 5); I reviewed and tested everything before submitting.

Since 4.6.0 the config loader crawls for `vite.config.*` files. In a monorepo
it also visits packages that don't use Svelte at all, and for those it logged

    Error while loading config at .../packages/package-a/vite.config.ts
    Error: No Svelte configuration found in vite config. Is @sveltejs/vite-plugin-svelte configured?

even though nothing was wrong. `loadConfig` already distinguishes the two
cases: a config that fails to load comes back with an `error`, while a config
that loads fine but has no Svelte plugin comes back as `undefined`. Only the
former is an actual error, so only that one is logged as such now. The latter
is logged at the normal level instead.

Behaviour is otherwise unchanged: the fallback preprocessor and
`loadConfigError` are still set exactly as before, so retry and diagnostics
logic keeps working.
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d49eefd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
svelte-language-server Patch
svelte-check Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm dummdidumm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you!

@dummdidumm
dummdidumm merged commit 32018fd into sveltejs:master Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
renovate Bot added a commit to gwennlbh/svelte-mathml that referenced this pull request Aug 20, 2026
##### [v4.7.6](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.6)

##### Patch Changes

- fix: don't log an error for vite configs without a Svelte plugin ([#3091](sveltejs/language-tools#3091))

- fix: handle SvelteKit 3 having its config merged at the top level ([#3104](sveltejs/language-tools#3104))
##### [v4.7.5](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.5)

##### Patch Changes

- fix: prevent silent error during start-up caused by unhandled promise ([#3096](sveltejs/language-tools#3096))

- Updated dependencies \[[`1df53d8`](sveltejs/language-tools@1df53d8)]:
  - [@sveltejs/load-config](https://github.com/sveltejs/load-config)@0.2.2
##### [v4.7.4](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.4)

##### Patch Changes

- fix: support TypeScript 7 Stable under npm alias ([#3073](sveltejs/language-tools#3073))
##### [v4.7.3](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.3)

##### Patch Changes

- feat: zero-config `+error.svelte` props ([#3076](sveltejs/language-tools#3076))
##### [v4.7.2](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.2)

##### Patch Changes

- fix: resolve tsgo bin path with package.json ([#3074](sveltejs/language-tools#3074))

- fix: report tsconfig errors in --tsgo-experimental-api ([#3070](sveltejs/language-tools#3070))
##### [v4.7.1](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.1)

##### Patch Changes

- fix: correctly parse --tsgo-experimental-api flag ([#3067](sveltejs/language-tools#3067))
##### [v4.7.0](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.0)

##### Minor Changes

- feat: add `--config` option ([#3066](sveltejs/language-tools#3066))

- feat: svelte-check tsgo support with experimental api ([#3036](sveltejs/language-tools#3036))

##### Patch Changes

- fix: load esm version of Vite ([#3065](sveltejs/language-tools#3065))

- fix: stop excluding workspaces under dot-prefixed ancestors ([#3037](sveltejs/language-tools#3037))

- Updated dependencies \[[`7a3464b`](sveltejs/language-tools@7a3464b), [`a2561fc`](sveltejs/language-tools@a2561fc)]:
  - [@sveltejs/load-config](https://github.com/sveltejs/load-config)@0.2.0
##### [v4.6.0](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.6.0)

##### Minor Changes

- feat: support reading Svelte config from `vite.config.js/ts` ([#3031](sveltejs/language-tools#3031))

##### Patch Changes

- Updated dependencies \[[`151cf45`](sveltejs/language-tools@151cf45)]:
  - [@sveltejs/load-config](https://github.com/sveltejs/load-config)@0.1.1
##### [v4.5.0](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.5.0)

##### Minor Changes

- feat: support Svelte 5 declaration tags ([#3033](sveltejs/language-tools#3033))

##### Patch Changes

- fix: properly handle props with the name `slot` inside Svelte 5 snippets ([#3030](sveltejs/language-tools#3030))

- feat: add support for svelte config ts/mts files ([#3009](sveltejs/language-tools#3009))
##### [v4.4.8](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.8)

##### Patch Changes

- feat: typescript 6.0 support ([#2985](sveltejs/language-tools#2985))
##### [v4.4.7](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.7)

##### Patch Changes

- fix: flush stdout/stderr before exit ([#3014](sveltejs/language-tools#3014))

- fix: report diagnostics in tsconfig.json ([#3005](sveltejs/language-tools#3005))
##### [v4.4.6](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.6)

##### Patch Changes

- fix: prevent config loading message in svelte-check --incremental ([#2974](sveltejs/language-tools#2974))

- fix: resolve svelte files with NodeNext in --incremental/tsgo ([#2990](sveltejs/language-tools#2990))

- perf: various optimization with ast walk ([#2969](sveltejs/language-tools#2969))

- fix: prevent error with escape sequence in attribute ([#2968](sveltejs/language-tools#2968))

- fix: typescript 6.0 compatibility ([#2988](sveltejs/language-tools#2988))
##### [v4.4.5](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.5)

##### Patch Changes

- fix: use Promise<Response> for async kit handler return types ([#2966](sveltejs/language-tools#2966))
##### [v4.4.4](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.4)

##### Patch Changes

- fix: more robust detection of `lang="ts"` attribute ([#2957](sveltejs/language-tools#2957))

- fix: pass filename to `warningFilter` ([#2959](sveltejs/language-tools#2959))

- fix: resolve svelte files under path alias in `--incremental/tsgo` mode ([#2955](sveltejs/language-tools#2955))
##### [v4.4.3](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.3)

##### Patch Changes

- fix: respect `@ts-ignore` etc comments within tags ([#2950](sveltejs/language-tools#2950))
##### [v4.4.2](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.2)

##### Patch Changes

- fix: resolve shims correctly in `--incremental/tsgo` mode ([`cd1ff2f`](sveltejs/language-tools@cd1ff2f))

- fix: include `references` in generated `tsconfig.json` in `--incremental/tsgo` mode ([`1990f74`](sveltejs/language-tools@1990f74))
##### [v4.4.1](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.1)

##### Patch Changes

- fix: handle relative imports reaching outside working directory when using `--incremental/--tsgo` flags ([#2942](sveltejs/language-tools#2942))

- fix: support SvelteKit zero types in svelte-check --incremental ([#2939](sveltejs/language-tools#2939))
##### [v4.4.0](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.4.0)

##### Minor Changes

- feat: provide `--incremental` and `--tsgo` flags ([#2932](sveltejs/language-tools#2932))

##### Patch Changes

- fix: ignore Unix domain sockets in file watcher to prevent crashes ([#2931](sveltejs/language-tools#2931))

- fix: properly use machine output by default for Claude Code ([`e9f58d2`](sveltejs/language-tools@e9f58d2))
##### [v4.3.6](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.3.6)

##### Patch Changes

- fix: don't hoist type/snippet referencing $store ([#2926](sveltejs/language-tools#2926))
gwennlbh pushed a commit to cigaleapp/cigale that referenced this pull request Aug 31, 2026
##### [v4.7.6](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.6)

##### Patch Changes

- fix: don't log an error for vite configs without a Svelte plugin ([#3091](sveltejs/language-tools#3091))

- fix: handle SvelteKit 3 having its config merged at the top level ([#3104](sveltejs/language-tools#3104))
##### [v4.7.5](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.5)

##### Patch Changes

- fix: prevent silent error during start-up caused by unhandled promise ([#3096](sveltejs/language-tools#3096))

- Updated dependencies \[[`1df53d8`](sveltejs/language-tools@1df53d8)]:
  - [@sveltejs/load-config](https://github.com/sveltejs/load-config)@0.2.2
##### [v4.7.4](https://github.com/sveltejs/language-tools/releases/tag/svelte-check%404.7.4)

##### Patch Changes

- fix: support TypeScript 7 Stable under npm alias ([#3073](sveltejs/language-tools#3073))

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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