Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for vite@6 async plugins #7014

Closed
6 tasks done
manuel3108 opened this issue Dec 3, 2024 · 3 comments
Closed
6 tasks done

Support for vite@6 async plugins #7014

manuel3108 opened this issue Dec 3, 2024 · 3 comments

Comments

@manuel3108
Copy link

Describe the bug

Using @sveltejs/kit@2.9.0 and vitest@2.1.8 makes tsc fail with the following vite.config.ts

import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';

export default defineConfig({
    plugins: [sveltekit()],
});

Problem was first reported in sveltejs/cli#341. While a user is adding vitest to his project, we are switching out the imports inside vite.config.ts like this:

// without vitest
import { defineConfig } from 'vite';

// with vitest
import { defineConfig } from "vitest/config";

This is likely caused by vite@6 allowing plugins of type Promise<whatever>. Looks like this change was not backported to config used by vitest

Reproduction

https://stackblitz.com/edit/node-zjetgl?file=vite.config.ts

Wait for npm i to complete. Run npm run check. The issue will appear. IntelliSense also complains

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: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^6.0.0 => 6.0.2 
    vitest: ^2.1.8 => 2.1.8

Used Package Manager

npm

Validations

@manuel3108
Copy link
Author

I was just made aware of that this was reverted as part of https://github.com/vitest-dev/vitest/releases/tag/v2.1.7, but i would still keep this issue open, as i was unable to find any other issue that's referencing vite 6 support.

But please feel free to close.

@niemyjski
Copy link

2.1.7 broke npm run check for us:

import { sveltekit } from '@sveltejs/kit/vite';
import Icons from 'unplugin-icons/vite';
import { defineConfig } from 'vitest/config';

const aspNetConfig = getAspNetConfig();

export default defineConfig({
    build: {
        sourcemap: true,
        target: 'esnext'
    },
    plugins: [
        sveltekit(),
        Icons({
            compiler: 'svelte'
        })
    ],
Exceptionless\src\Exceptionless.Web\ClientApp\vite.config.ts:14:9
Error: No overload matches this call.
  The last overload gave the following error.
    Type 'Promise<Plugin<any>[]>' is not assignable to type 'PluginOption'.
      Type 'Promise<Plugin<any>[]>' is not assignable to type 'Promise<false | Plugin<any> | PluginOption[] | null | undefined>'.
        Type 'Plugin<any>[]' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.
          Type 'Plugin<any>[]' is not assignable to type 'PluginOption[]'.
            Type 'Plugin<any>' is not assignable to type 'PluginOption'.

niemyjski added a commit to exceptionless/Exceptionless that referenced this issue Dec 4, 2024
@sheremet-va
Copy link
Member

Vitest 2 doesn't support Vite 6 and will not support Vite 6 officially. You can use resolutions or pnpm.overrides to change the version range locally, Vite 6 API is the same and should work for Vitest 2.

If you migrated to Vite 6, use Vitest 3 (currently in beta), release is planned for January.

If you see any type errors in your config, check the lockfile to confirm that you have several Vite versions installed and resolve it with your package manager.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants