Skip to content

refactor(config): improve builder auto-detection logic#4058

Merged
pi0 merged 1 commit intomainfrom
feat/auto-builder
Feb 26, 2026
Merged

refactor(config): improve builder auto-detection logic#4058
pi0 merged 1 commit intomainfrom
feat/auto-builder

Conversation

@pi0
Copy link
Member

@pi0 pi0 commented Feb 26, 2026

Summary

  • Detect vite builder by checking if vite is installed and a vite.config.{ts,mts,js,mjs} contains nitro( plugin usage
  • Default to rolldown (direct dependency of nitro) when no builder is explicitly set and vite is not detected
  • Skip install check for rolldown since it's always available as a direct dependency
  • Remove interactive prompt to choose/install a builder (no longer needed with rolldown as default)

Test plan

  • Verify explicit builder: "vite" still prompts to install if vite is missing
  • Verify explicit builder: "rolldown" skips install check
  • Verify auto-detection picks vite when vite.config.ts with nitro() exists
  • Verify auto-detection defaults to rolldown when no vite config is found

🤖 Generated with Claude Code

Detect vite builder by checking for vite.config with `nitro()` plugin usage.
Default to rolldown (direct dependency) instead of prompting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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 Building Building Preview, Comment Feb 26, 2026 8:30am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The builder path resolution logic is refactored to auto-detect vite with nitro() plugins, treat rolldown as a special case requiring no installation checks, and default to rolldown when no builder is specified. A new helper function inspects vite.config files for nitro usage, and dependency checking is updated with principled require resolution.

Changes

Cohort / File(s) Summary
Builder Resolution Logic
src/config/resolvers/builder.ts
Refactored builder detection with new auto-detection for vite-nitro setups, special handling for rolldown, and rolldown as default fallback. Added helper function to inspect vite.config files for nitro() usage. Replaced direct require with createRequire-based resolution. Updated installation check logic to prompt only for non-rolldown builders.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Possibly related PRs

  • refactor: add rolldown as dependency #4002: Updates builder detection to treat rolldown specially while that PR adds rolldown as a runtime dependency and switches build plugins to use it, affecting the same dependency and runtime code paths.
🚥 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 PR title 'refactor(config): improve builder auto-detection logic' follows conventional commits format with type, scope, and clear description of the main change.
Description check ✅ Passed The PR description is directly related to the changeset, outlining the specific improvements to builder auto-detection logic with clear test plan items.

✏️ 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/auto-builder

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 merged commit 5ccf672 into main Feb 26, 2026
10 of 11 checks passed
@pi0 pi0 deleted the feat/auto-builder branch February 26, 2026 08:34
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/config/resolvers/builder.ts (1)

64-78: Consider adding debug logging for file read failures.

The empty catch block on line 74 silently swallows errors. While failing gracefully is appropriate for auto-detection, consider logging at debug level to aid troubleshooting when detection unexpectedly fails (e.g., permission issues).

💡 Optional: add debug logging
       try {
         const content = readFileSync(configPath, "utf8");
         if (content.includes("nitro(")) {
           return true;
         }
-      } catch {}
+      } catch (err) {
+        consola.debug(`Failed to read ${configPath}:`, err);
+      }

Based on learnings: "Use consola for logging in build/dev code."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/config/resolvers/builder.ts` around lines 64 - 78, The empty catch in
hasNitroViteConfig silently swallows read errors; update it to log debug-level
details using consola (imported or add import) so permission or read failures
are visible during troubleshooting—specifically, inside the catch block for
readFileSync in the hasNitroViteConfig function, call consola.debug with a
concise message including the configPath and the caught error (e.g., "failed to
read vite config {configPath}:" + error) while keeping behavior unchanged (still
continue detection).
🤖 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/config/resolvers/builder.ts`:
- Around line 64-78: The empty catch in hasNitroViteConfig silently swallows
read errors; update it to log debug-level details using consola (imported or add
import) so permission or read failures are visible during
troubleshooting—specifically, inside the catch block for readFileSync in the
hasNitroViteConfig function, call consola.debug with a concise message including
the configPath and the caught error (e.g., "failed to read vite config
{configPath}:" + error) while keeping behavior unchanged (still continue
detection).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b954d0a and 8604a56.

📒 Files selected for processing (1)
  • src/config/resolvers/builder.ts

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.

1 participant