Skip to content

fix: change Vite config type to work with Vitest options - #8871

Merged
Rich-Harris merged 1 commit into
sveltejs:masterfrom
teemingc:fix-vite-config-type-with-vitest
Feb 6, 2023
Merged

fix: change Vite config type to work with Vitest options#8871
Rich-Harris merged 1 commit into
sveltejs:masterfrom
teemingc:fix-vite-config-type-with-vitest

Conversation

@teemingc

@teemingc teemingc commented Feb 3, 2023

Copy link
Copy Markdown
Member

closes #8768

As suggested by Rich and Dominik, this changes all vite.config templates to:

  • use defineConfig instead of type annotations.
  • import defineConfig from vitest if the project includes vitest.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@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.

Is this a breaking change since it changes the shape of the vite config? If so, we should release it together with the other breaking change (and further breaking changes possibly coming out of the svelte package discussion)

@teemingc

teemingc commented Feb 3, 2023

Copy link
Copy Markdown
Member Author

Is this a breaking change since it changes the shape of the vite config?

As in how the config is exported? (changed from exporting the constant to directly exporting the method output).

I'm not sure if it's breaking. It still uses the vite UserConfig type, but gets the type inference from the defineConfig output instead. Only the vitest option has changed to correctly use the superset type from vitest instead of vite.

@dummdidumm

Copy link
Copy Markdown
Member

It's more along the lines of potential downstream projects like svelte-add modifying that code. @babichjacob is vite.config.js/ts something svelte-add touches/adders could touch?

@Rich-Harris

Copy link
Copy Markdown
Member

approved, but will hold off merging till we get clarity around svelte-add

@babichjacob

Copy link
Copy Markdown
Member

Svelte Add is fine with defineConfig - it doesn't even validate that it's from Vite (or even called defineConfig - just that it's a function) so using the one from Vitest is a-ok. Thanks for the heads up, and you can go ahead.

@Rich-Harris
Rich-Harris merged commit b02d795 into sveltejs:master Feb 6, 2023
@github-actions github-actions Bot mentioned this pull request Feb 6, 2023
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.

Configuration for vitest not assignable to type UserConfig

4 participants