refactor(config): improve builder auto-detection logic#4058
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/config/resolvers/builder.ts (1)
64-78: Consider adding debug logging for file read failures.The empty
catchblock 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
consolafor 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).
Summary
vitebuilder by checking ifviteis installed and avite.config.{ts,mts,js,mjs}containsnitro(plugin usagerolldown(direct dependency of nitro) when no builder is explicitly set and vite is not detectedrolldownsince it's always available as a direct dependencyTest plan
builder: "vite"still prompts to install if vite is missingbuilder: "rolldown"skips install checkvitewhenvite.config.tswithnitro()existsrolldownwhen no vite config is found🤖 Generated with Claude Code