nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
54.28k stars 4.96k forks source link

Vite import types are not included with nuxt #28197

Open markbrockhoff opened 2 months ago

markbrockhoff commented 2 months ago

Environment

Reproduction

https://github.com/markbrockhoff/nuxt-vite-types-bug-repro

Describe the bug

Right now typescript will complain when trying to use raw or url imports (Docs):

image

For projects using vite as a bundler I'd expect that vites' types are included within the types generated by nuxt so that these kinds of imports work out of the box.

Additional context

If I understood it correctly, this should have been added by #19338 already. That's why I'm opening this as a bug and not a feature request. Please correct me if I'm mistaken. It also seems like there is an ongoing discussion regarding this, which didn't get that much attention so far: #19694

Logs

No response

cwaring commented 4 weeks ago

It looks like the nuxt cli bundler can't resolve the required vite/client (ref) dependency during nuxt prepare:types – if you are using pnpm without hoisting or installing vite as a project dep first.

A temporary workaround is to add the follow hoisting pattern to /.npmrc

public-hoist-pattern[]=vite

Then reinstall the project deps and rebuild the types:

pnpm i