Skip to content

types(vite): make experimental.vite optional - #4225

Merged
pi0 merged 1 commit into
nitrojs:mainfrom
sotasan:fix-experimental-vite-optional
Apr 24, 2026
Merged

pi0 merged 1 commit into
nitrojs:mainfrom
sotasan:fix-experimental-vite-optional

Conversation

@sotasan

@sotasan sotasan commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

🔍 Linked Issue

None — trivial type fix.

📚 Description

NitroPluginConfig.experimental.vite is currently typed as required, even though every field inside it is optional and every call site in src/build/vite/plugin.ts already reads it via optional chaining (pluginConfig.experimental?.vite?.…).

This makes any experimental override that doesn't include vite fail to typecheck. For example:

nitro({
  experimental: {
    tasks: true,
  },
})

…produces:

Property 'vite' is missing in type '{ tasks: true; }' but required in type '{ vite: { assetsImport?: boolean; serverReload?: boolean; services?: Record<string, ServiceConfig>; }; }'.

The workaround is experimental: { tasks: true, vite: {} }, but the empty object is meaningless — all three vite sub-options have defaults.

Change

One-character fix: vite: → vite?: in src/build/vite/types.ts. Aligns the declared type with actual runtime behavior.

No behavior change; no call site updates needed (they already optional-chain).

Checks

  • pnpm typecheck — passes
  • pnpm lint — passes
  • pnpm test — passes except one pre-existing flake in test/vite/hmr.test.ts > editing SSR entry (no full-reload), which fails on clean main without this patch as well

@sotasan
sotasan requested a review from pi0 as a code owner April 23, 2026 19:08
@vercel

vercel Bot commented Apr 23, 2026

Copy link
Copy Markdown

@sotasan is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated the NitroPluginConfig type to make the experimental.vite property optional instead of required. The inner optional settings (assetsImport, serverReload, services) remain unchanged in their structure and optionality.

Changes

Cohort / File(s) Summary
Type Definition Updates
src/build/vite/types.ts
Made experimental.vite property optional in NitroPluginConfig interface, allowing configurations without specifying the vite key while preserving inner optional properties.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title uses 'types' instead of 'fix' as the conventional commit type, which is technically valid but doesn't match the PR's primary purpose of fixing a type contract issue. Consider updating the title to 'fix(vite): make experimental.vite optional' to better align with conventional commits for bug fixes, though 'types' is also acceptable for type-related changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively explains the type-related issue, provides clear examples of the problem, documents the one-character fix, and references the verification steps taken.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pi0 pi0 changed the title fix(vite): make experimental.vite optional types(vite): make experimental.vite optional Apr 23, 2026

@pi0 pi0 left a comment

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.

Thnx ❤️

@pkg-pr-new

pkg-pr-new Bot commented Apr 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4225

commit: 0c8bf9e

@pi0
pi0 merged commit d0d8d91 into nitrojs:main Apr 24, 2026
12 of 13 checks passed
@sotasan
sotasan deleted the fix-experimental-vite-optional branch April 24, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants