fix: Support both development and production builds in Electron#326
fix: Support both development and production builds in Electron#326upendra512 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
Add intelligent path detection to support running Electron app after development builds (npm run build) in addition to production packages (npm run dist). Changes: - Check for development path first: process.cwd()/.output/server/index.mjs - Fallback to production path: app.asar.unpacked/.output/server/index.mjs - Show clear error messages if neither path exists - Enable server logs (stdio: inherit) in development mode - Show terminal window in development for debugging - Preserve original production behavior (hidden logs/terminal) This eliminates the need to run 'npm run dist' for every small change during development, significantly improving developer experience and iteration speed. Before: Developers had to package the entire app for testing After: Developers can test with 'npm run build && npm run electron' Fixes AOSSIE-Org#284 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
Description
Fixes Issue #284 - npm run electron not working after development builds
Added intelligent path detection to support running the Electron app after both development builds (
npm run build) and production packages (npm run dist).Problem
Developers were forced to run
npm run dist(full packaging) to test even small changes becausenpm run electrononly worked with packaged builds. This made the development workflow extremely slow and painful:Before:
npm run build(✅ works)npm run electron(❌ fails - can't find server)npm run dist(😢 slow, packages entire app)This cycle took several minutes for each iteration, making rapid development nearly impossible.
Solution
Implemented smart path detection that checks for both development and production server locations:
Path Detection Logic
Development Path (checked first):
process.cwd()/.output/server/index.mjsnpm run buildProduction Path (fallback):
app.asar.unpacked/.output/server/index.mjsnpm run distError Handling:
npm run buildfirstDevelopment Mode Features
When development build is detected:
stdio: 'inherit'shows all server outputwindowsHide: falsefor debuggingWhen production build is detected:
Workflow Improvements
After this fix:
npm run build(builds in seconds)npm run electron(✅ works!)Development iteration time reduced from minutes to seconds.
Technical Details
File: electron/main.cjs
Changes made:
devPathvariable for development buildsprodPathvariable for production buildsisDevelopmentflag to track current modespawnoptions based on mode:stdio: 'inherit' (dev) vs 'ignore' (prod)windowsHide: false (dev) vs true (prod)Lines Changed: +27/-5
Testing Scenarios
Development Mode
npm run build npm run electron # ✅ Now works!Production Mode
npm run dist # Run the packaged executable # ✅ Still works!Error Handling
Impact
For Contributors
For Project
Backwards Compatibility
npm run distusage still worksRelated Issues
Closes #284
Notes
This change significantly improves the developer experience for anyone contributing to Rein. The ability to quickly test changes without full packaging is essential for productive development.