fix(dev): keep lazy handlers code-split in dev - #4459
Conversation
|
@jibin7jose is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Linked issue
Fixes #4435
Type of change
Description
This fixes a bug in the
nitro-devpreset where an import-time error in a single lazy route handler takes down the entire dev server and breaks unrelated routes with a misleadingCannot 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:
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.(Note: This PR is functionally equivalent to #4436 and #4458, but properly targets the
v2branch where this issue actually affects users.)