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

compability for vite 5 #1655

Open
d-koppenhagen opened this issue Jan 4, 2024 · 4 comments
Open

compability for vite 5 #1655

d-koppenhagen opened this issue Jan 4, 2024 · 4 comments

Comments

@d-koppenhagen
Copy link

An update of from vit4 to vite5 shows a type error in my vite.config.ts.
It seems the plugin is not completely compatible (at least the types aren't).

type 'Plugin<any>' is not assignable to type 'PluginOption'.
      Type 'import("/Users/my-user/dev/my-project/node_modules/rollup/dist/rollup").Plugin<any>' is not assignable to type 'import("/Users/my-user/dev/my-project/node_modules/vite/dist/node/index").Plugin<any>'.
        Types of property 'resolveId' are incompatible.
          Type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { assertions: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, {}> | undefined' is not assignable to type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>> | undefined'.
            Type '(this: PluginContext, source: string, importer: string | undefined, options: { assertions: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>' is not assignable to type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>> | undefined'.
              Type '(this: PluginContext, source: string, importer: string | undefined, options: { assertions: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>' is not assignable to type '(this: PluginContext, source: string, importer: string | undefined, options: { attributes: Record<string, string>; custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>'.
                The 'this' types of each signature are incompatible.
                  Property 'moduleIds' is missing in type 'import("/Users/my-user/dev/my-project/node_modules/vite/node_modules/rollup/dist/rollup").PluginContext' but required in type 'import("/Users/my-user/dev/my-project/node_modules/rollup/dist/rollup").PluginContext'.
@d-koppenhagen
Copy link
Author

it's possible to add as PluginOption but it's not the best solution imo

@mjeanroy
Copy link
Owner

Hi @d-koppenhagen,
Thanks for opening this issue!

I'd be happy to make it compatible, but I'm not using using vite 5 so I'm a bit blind on this (for now). I need to check the documentation to understand what would need to be changed.

In the meantime, I'd be happy to review any PR of course! :)

@mitar
Copy link

mitar commented Feb 29, 2024

Types and plugin works for me out of the box? vue-tsc --noEmit does not complain.

This is relevant config for me:

/// <reference types="vitest" />
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import license from "rollup-plugin-license"
import path from "path"

// https://vitejs.dev/config/
// https://vitest.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    license({
      sourcemap: true,
      thirdParty: {
        output: {
          file: path.join(__dirname, "dist", "NOTICE"),
        },
      },
    }),
  ],
  build: {
    target: ["esnext"],
  },
  esbuild: {
    legalComments: "none",
  },
})
  "devDependencies": {
    "@babel/types": "^7.23.6",
    "@headlessui/tailwindcss": "^0.2.0",
    "@simplewebauthn/typescript-types": "^8.3.4",
    "@tailwindcss/forms": "^0.5.7",
    "@tailwindcss/typography": "^0.5.10",
    "@types/lodash-es": "^4.17.12",
    "@types/node": "^20.10.5",
    "@typescript-eslint/eslint-plugin": "^6.15.0",
    "@typescript-eslint/parser": "^6.15.0",
    "@vitejs/plugin-vue": "^4.5.2",
    "@vitest/coverage-v8": "^1.0.4",
    "@vue/eslint-config-typescript": "^12.0.0",
    "autoprefixer": "^10.4.16",
    "eslint": "^8.56.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-vue": "^9.19.2",
    "postcss": "^8.4.32",
    "postcss-html": "^1.5.0",
    "prettier": "^3.1.1",
    "prettier-plugin-tailwindcss": "^0.5.9",
    "rollup-plugin-license": "^3.2.0",
    "stylelint": "^16.0.2",
    "stylelint-config-standard": "^35.0.0",
    "stylelint-config-standard-vue": "^1.0.0",
    "stylelint-config-tailwindcss": "^0.0.7",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.3.3",
    "vite": "^5.0.10",
    "vitest": "^1.0.4",
    "vue-tsc": "^1.8.25"
  }

@mewhhaha
Copy link

I had the same issue, but it was because rollup-plugin-license has rollup as a peer dependency and I hadn't installed it. I'm guessing it would diff with the rollup that Vite was using. After I installed it, it resolved the issue with Vite.

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

No branches or pull requests

4 participants