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

Plugin created from a template doesn't get registered into plugins.d.ts #22617

Closed
andriepu opened this issue Aug 13, 2023 · 2 comments · Fixed by #23943
Closed

Plugin created from a template doesn't get registered into plugins.d.ts #22617

andriepu opened this issue Aug 13, 2023 · 2 comments · Fixed by #23943

Comments

@andriepu
Copy link

andriepu commented Aug 13, 2023

Environment


  • Operating System: Linux
  • Node Version: v16.20.0
  • Nuxt Version: 3.6.5
  • Nitro Version: 2.5.2
  • Package Manager: npm@9.4.2
  • Builder: vite
  • User Config: modules
  • Runtime Modules: ./modules/hello.ts
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-avmg3e

Run: nuxi prepare

Describe the bug

Starting from nuxt 3.5.0, plugins created by template (addPluginTemplate / addTemplate -> addPlugin) don't get registered to .nuxt/types/plugins.d.ts when generated inside the .nuxt folder.

As we can see from the reproduction repo, the InjectionType<typeof import("../plugins/hello").default> is missing from the plugins.d.ts.

It causes the useNuxtApp().$hello type to be unknown.

Additional context

If we generate the template outside the .nuxt folder, it requires running nuxi prepare at least twice to make it registered to .nuxt/types/plugins.d.ts.

Reproduction: https://stackblitz.com/edit/nuxt-starter-9mc6yi

Logs

No response

@stackblitz
Copy link

stackblitz bot commented Aug 13, 2023

@danielroe
Copy link
Member

This is almost certainly because we do not include files that do not exist in the types:

.filter(p => !isAbsolute(p.src) || existsSync(p.src) || existsSync(p.src.replace(EXTENSION_RE, '.d.ts')))

But on first running nuxi prepare command, the file does not yet exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants