fix(preset): keep lazy handlers code-split in dev#4436
Conversation
|
@jibin7jose is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe Nitro dev preset now keeps dynamic imports un-inlined and updates related preset configuration. Regression fixtures and a Vitest suite verify that an import-time error in one route does not prevent an unrelated route from responding. ChangesNitro dev import error handling
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
This PR fixes an issue where an import-time error in a single lazy route handler takes down the entire dev server and breaks unrelated routes with a misleading
Cannot access '<x>' before initializationerror.Cause:
The
nitro-devpreset was settinginlineDynamicImports: true. This caused Rollup to inline all lazy handler bodies into the singleindex.mjsstartup bundle. An error evaluating one route would abort the execution of the bundle, leaving subsequent routes permanently in the Temporal Dead Zone (TDZ).Fix:
We've set
inlineDynamicImports: falsein thenitro-devpreset. This ensures lazy handlers remain code-split during local development, so an import-time failure in one module will not disrupt the evaluation of the rest of the server or other routes. When a broken route is accessed, the dev server will now accurately report the original initialization error.Fixes #4435