Skip to content

feat(kit): provide type support for module options in installModule#26744

Merged
danielroe merged 12 commits intonuxt:mainfrom
ineshbose:install-module-types
Jun 10, 2024
Merged

feat(kit): provide type support for module options in installModule#26744
danielroe merged 12 commits intonuxt:mainfrom
ineshbose:install-module-types

Conversation

@ineshbose
Copy link
Copy Markdown
Member

@ineshbose ineshbose commented Apr 11, 2024

🔗 Linked issue

📚 Description

These changes relies and builds on top of #18416 (my first PR on Nuxt 😄); it extracts the options from there after module authors run prepare.

Try this in the repo playground:

import { installModule } from "@nuxt/kit";

installModule('@nuxt/devtools', { customTabs: [] })

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe changed the title chore(kit): provide type support for module options in installModule feat(kit): provide type support for module options in installModule Apr 12, 2024
Comment thread test/fixtures/basic-types/nuxt.config.ts
Comment thread packages/kit/build.config.ts Outdated
],
externals: [
'@nuxt/schema',
'nuxt/schema',
Copy link
Copy Markdown
Member

@danielroe danielroe Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to use @nuxt/schema within Kit as there is no nuxt dependency. The end user is the only one who should use nuxt/schema as a type import/augmentation...

(We might need to generate an augmentation against @nuxt/schema as well.)

Copy link
Copy Markdown
Member Author

@ineshbose ineshbose Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but the updated NuxtConfig that has the new modules options would be based on the types Nuxt has written for their project right, so they get imported using nuxt/schema is what I've found

(typecheck CI has now failed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I understand. We need to find a different solution than using nuxt/schema with @nuxt/kit...

@danielroe
Copy link
Copy Markdown
Member

Nice work! And also debugging the type issue. This will be a nice DX improvement ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants