Skip to content

feat(vite): auto-detect client entry#4059

Merged
pi0 merged 4 commits intomainfrom
feat/client-entrypoint
Feb 27, 2026
Merged

feat(vite): auto-detect client entry#4059
pi0 merged 4 commits intomainfrom
feat/client-entrypoint

Conversation

@RihanArfan
Copy link
Member

@RihanArfan RihanArfan commented Feb 26, 2026

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Automatically use [src/app]/client-entry.[ts/js/mts/mjs/tsx/jsx] as the client entrypoint.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment Feb 27, 2026 6:15pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1623012 and 4e8ca1c.

📒 Files selected for processing (1)
  • src/build/vite/plugin.ts

📝 Walkthrough

Walkthrough

Removed explicit environments entry configurations from four Vite SSR example projects; Nitro's Vite plugin now auto-detects the client entry (with renderer-template fallback) and checks rolldownOptions.input when resolving client and SSR entries.

Changes

Cohort / File(s) Summary
Example Vite configurations
examples/vite-ssr-preact/vite.config.mjs, examples/vite-ssr-react/vite.config.mjs, examples/vite-ssr-solid/vite.config.mjs, examples/vite-ssr-vue-router/vite.config.mjs
Removed explicit environments blocks that specified client/SSR Rollup input overrides; configs now rely on plugin/autodetection.
Nitro Vite plugin
src/build/vite/plugin.ts
Introduced client-entry auto-detection (resolveModulePath + renderer template fallback), log messages for detected/template usage, conditional registration of environments.client and setting build.rollupOptions.input only when not preconfigured; SSR resolution now checks rolldownOptions.input in addition to rollupOptions.input.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'feat' type and clear scope/subject describing the main change of auto-detecting client entry.
Description check ✅ Passed The description clearly explains the change—automatically detecting client entrypoint files—and is directly related to the changeset modifications across vite configs and the plugin implementation.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/client-entrypoint

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 26, 2026

Open in StackBlitz

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

commit: edc708c

@pi0
Copy link
Member

pi0 commented Feb 26, 2026

Please revert unrelated changes

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/vite-ssr-tsr-react/README.md (1)

59-61: ⚠️ Potential issue | 🟡 Minor

Typo in tsconfig paths alias.

The path alias "sec/*" appears to be a typo and should be "src/*".

Proposed fix
     "paths": {
-      "@/*": ["sec/*"]
+      "@/*": ["src/*"]
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/vite-ssr-tsr-react/README.md` around lines 59 - 61, The tsconfig
"paths" mapping has a typo: the alias entry "@/*": ["sec/*"] should point to
"src/*"; update the paths object so the alias reads "@/*": ["src/*"] (i.e.,
replace "sec/*" with "src/*") to restore the correct source folder mapping used
by the build and imports.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/1.docs/4.renderer.md`:
- Around line 190-204: Two fenced code blocks (the directory listing block
starting with "app/" and the log output block starting with "ℹ Using
app/entry-server.ts") lack language specifiers; update both opening fences from
"```" to "```text" so the blocks explicitly declare plain-text for syntax
highlighting and to satisfy the markdown linter (edit the block that contains
"app/ entry-server.ts entry-client.ts routes/ api/hello.ts" and the adjacent tip
block that lists the "ℹ Using app/entry-server.ts..." lines).

---

Outside diff comments:
In `@examples/vite-ssr-tsr-react/README.md`:
- Around line 59-61: The tsconfig "paths" mapping has a typo: the alias entry
"@/*": ["sec/*"] should point to "src/*"; update the paths object so the alias
reads "@/*": ["src/*"] (i.e., replace "sec/*" with "src/*") to restore the
correct source folder mapping used by the build and imports.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ccf672 and d25b45e.

📒 Files selected for processing (17)
  • docs/1.docs/4.renderer.md
  • examples/vite-ssr-preact/GUIDE.md
  • examples/vite-ssr-preact/README.md
  • examples/vite-ssr-preact/vite.config.mjs
  • examples/vite-ssr-react/GUIDE.md
  • examples/vite-ssr-react/README.md
  • examples/vite-ssr-react/vite.config.mjs
  • examples/vite-ssr-solid/GUIDE.md
  • examples/vite-ssr-solid/README.md
  • examples/vite-ssr-solid/vite.config.mjs
  • examples/vite-ssr-tsr-react/README.md
  • examples/vite-ssr-tss-react/README.md
  • examples/vite-ssr-vue-router/GUIDE.md
  • examples/vite-ssr-vue-router/README.md
  • examples/vite-ssr-vue-router/vite.config.mjs
  • src/build/vite/plugin.ts
  • src/build/vite/types.ts
💤 Files with no reviewable changes (4)
  • examples/vite-ssr-preact/vite.config.mjs
  • examples/vite-ssr-solid/vite.config.mjs
  • examples/vite-ssr-vue-router/vite.config.mjs
  • examples/vite-ssr-react/vite.config.mjs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/build/vite/plugin.ts (1)

99-134: Client entry auto-detection logic looks good overall.

The fallback chain (user config → renderer template → auto-detect) is well-structured and preserves user configuration appropriately.

Regarding the static analysis hint on line 104: This is a false positive. useNitro is not a React hook—it's a simple helper function (defined at lines 359-364) that retrieves the Nitro instance from the plugin context. This is a Vite plugin, not a React component.

Minor simplification: On lines 126 and 129, the ternary check is redundant since you're already inside the if (clientEntry) block where clientEntry is guaranteed truthy.

🔧 Suggested simplification
       build: {
         rollupOptions: {
-          input: clientEntry ? { index: clientEntry } : undefined,
+          input: { index: clientEntry },
         },
         rolldownOptions: {
-          input: clientEntry ? { index: clientEntry } : undefined,
+          input: { index: clientEntry },
         },
       },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/build/vite/plugin.ts` around lines 99 - 134, The clientEntry truthiness
check inside the if (clientEntry) block makes the ternary expressions redundant;
update the environments.client.build.rollupOptions.input and
rolldownOptions.input to directly use { index: clientEntry } (no clientEntry ?
... : undefined) and remove the needless conditional; keep the rest of the
auto-detection (getEntry/useNitro) as-is—note that
useNitro(ctx).options.renderer?.template is a valid non-hook helper and can
remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/build/vite/plugin.ts`:
- Around line 99-134: The clientEntry truthiness check inside the if
(clientEntry) block makes the ternary expressions redundant; update the
environments.client.build.rollupOptions.input and rolldownOptions.input to
directly use { index: clientEntry } (no clientEntry ? ... : undefined) and
remove the needless conditional; keep the rest of the auto-detection
(getEntry/useNitro) as-is—note that useNitro(ctx).options.renderer?.template is
a valid non-hook helper and can remain unchanged.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d25b45e and 1623012.

📒 Files selected for processing (5)
  • examples/vite-ssr-preact/vite.config.mjs
  • examples/vite-ssr-react/vite.config.mjs
  • examples/vite-ssr-solid/vite.config.mjs
  • examples/vite-ssr-vue-router/vite.config.mjs
  • src/build/vite/plugin.ts
💤 Files with no reviewable changes (4)
  • examples/vite-ssr-solid/vite.config.mjs
  • examples/vite-ssr-vue-router/vite.config.mjs
  • examples/vite-ssr-react/vite.config.mjs
  • examples/vite-ssr-preact/vite.config.mjs

@pi0 pi0 merged commit bfbb207 into main Feb 27, 2026
8 checks passed
@pi0 pi0 deleted the feat/client-entrypoint branch February 27, 2026 18:15
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