cpreston321 / nuxt-swiper

Swiper.js for Nuxt
https://www.npmjs.com/package/nuxt-swiper
MIT License
232 stars 10 forks source link

typecheck not working with pnpm #126

Open IlyaSemenov opened 4 months ago

IlyaSemenov commented 4 months ago

In a pnpm installation, nuxt typecheck fails with:

> nuxt typecheck

error TS2688: Cannot find type definition file for 'swiper/vue'.
  The file is in the program because:
    Entry point of type library 'swiper/vue' specified in compilerOptions

Found 1 error.

This is because nuxt-swiper pushes swiper/vue to types:

https://github.com/cpreston321/nuxt-swiper/blob/ab323dceea750146d9619f356f12d6f53b92ad4f/src/module.ts#L30-L32

but the Nuxt project itself doesn't have swiper as a dependency, so type checking fails.

Instead, nuxt-swiper should re-export swiper/vue (being swiper-nuxt dependency) as something like swiper-nuxt/types, and use it for the injected reference.

The current workaround is to manually install pnpm add swiper@^10.3.1 but this needs to be manually synced with swiper (the latest version of swiper which installs by default is already one major version ahead), and is thus error-prone.

avxkim commented 2 months ago

Just faced this issue, after switching to pnpm (used npm)

pmioni commented 2 months ago

Same issue here, problem started with a new pnpm version probably as we did not have it before.

avxkim commented 2 months ago

yeah, looks like it won't be fixed, so i chose npm over pnpm (slower, but more maintanable)

rocketiscool commented 1 month ago

Same issue with Nuxt3 and pnpm, any workarounds that can hide the type error?

Edit: Nevermind I just added swiper as a package also