feat(core, vite): interoperability between nitro modules and vite plugins (poc)#3712
Merged
feat(core, vite): interoperability between nitro modules and vite plugins (poc)#3712
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
pi0
added a commit
that referenced
this pull request
Oct 31, 2025
productdevbook
added a commit
to productdevbook/nitro-graphql
that referenced
this pull request
Nov 4, 2025
This implements the new Nitro v3 pattern where Vite plugins can include
a `nitro:` key to automatically register Nitro modules, eliminating the
need for separate configuration.
**Changes:**
- Extract shared setup logic into `src/setup.ts` for reuse
- Update `src/vite.ts` to include `nitro: { setup() }` hook
- Accept `NitroGraphQLOptions` in the Vite plugin function
- Update `src/index.ts` to use the extracted setup function
- Update Vite playground to demonstrate the new single-import pattern
**Benefits:**
- Single import: users only need `graphql()` from `nitro-graphql/vite`
- Plugin order independence (as per Nitro v3 changes)
- Better DX and consistency with modern Nitro v3 patterns
- Full backward compatibility with existing `modules: ['nitro-graphql']` approach
**Usage:**
```typescript
// New pattern (recommended)
import { graphql } from 'nitro-graphql/vite'
import { nitro } from 'nitro/vite'
export default defineConfig({
plugins: [
graphql({ framework: 'graphql-yoga' }),
nitro()
]
})
```
**Related:**
- Nitro PR: nitrojs/nitro#3712
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
4 tasks
productdevbook
added a commit
to productdevbook/nitro-graphql
that referenced
this pull request
Nov 4, 2025
* feat: add Nitro v3 Vite plugin integration with nitro: hook
This implements the new Nitro v3 pattern where Vite plugins can include
a `nitro:` key to automatically register Nitro modules, eliminating the
need for separate configuration.
**Changes:**
- Extract shared setup logic into `src/setup.ts` for reuse
- Update `src/vite.ts` to include `nitro: { setup() }` hook
- Accept `NitroGraphQLOptions` in the Vite plugin function
- Update `src/index.ts` to use the extracted setup function
- Update Vite playground to demonstrate the new single-import pattern
**Benefits:**
- Single import: users only need `graphql()` from `nitro-graphql/vite`
- Plugin order independence (as per Nitro v3 changes)
- Better DX and consistency with modern Nitro v3 patterns
- Full backward compatibility with existing `modules: ['nitro-graphql']` approach
**Usage:**
```typescript
// New pattern (recommended)
import { graphql } from 'nitro-graphql/vite'
import { nitro } from 'nitro/vite'
export default defineConfig({
plugins: [
graphql({ framework: 'graphql-yoga' }),
nitro()
]
})
```
**Related:**
- Nitro PR: nitrojs/nitro#3712
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* chore: bump version to 2.0.0-beta.13
---------
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
There is still an ongoing discussion to decide on best namespace. This PR is initial step and we might extend it to support a new nested namespace for extension. In the meantime, it is a safe first step to try and adopt the idea. (RFC: #3680)
This PR adds a new module format to the core:
{ nitro: { setup } }.This allows developers to make vite plugins with an additional/optional
nitro: {}hook.When used together with
nitro/viteplugin, these plugins will be detected by Nitro and used as modules.Example: plugin:
Usage in
vite.config: (vite CLI)Usage in
nitro.config(nitro CLI)