fix(shims): import local navigation module in error boundary#837
Conversation
The built package may execute error-boundary.tsx before the plugin's resolveId hook is active, so the public next/navigation alias is not available. Import the local shim directly instead.
commit: |
There was a problem hiding this comment.
Pull request overview
This PR fixes early-execution failures in the built error-boundary shim by avoiding the next/navigation public alias (which may not be registered yet) and importing the local navigation shim directly.
Changes:
- Replace
next/navigationimport with a direct relative import from./navigation.jsin the error boundary shim. - Remove the lint suppression comment that was only relevant to the aliased import.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/bigbonk review |
There was a problem hiding this comment.
LGTM. This is a straightforward and correct fix.
error-boundary.tsx was the only shim file still importing from the public next/navigation alias — every other sibling (link.tsx, slot.tsx, form.tsx, layout-segment-context.tsx, navigation-state.ts, navigation.react-server.ts) already uses ./navigation.js. This aligns the outlier and eliminates the race where the built package executes the shim before the plugin's resolveId hook is active.
The removed oxlint-disable-next-line comment is no longer needed since the direct relative import is a standard ESM import, not a shimmed alias.
|
Approved the PR. The change is correct and consistent with the rest of the codebase:
|
Summary
The built package can execute
shims/error-boundary.tsxbefore the plugin'sresolveIdhook is active, so the publicnext/navigationalias is not yet registered. Import the local./navigation.jsmodule directly instead.Three-line change extracted from the PR #768 restack; landing independently because it's orthogonal to the layout-persistence feature work.
Stack context
This is the sibling of the PR #768 restack. Not part of the 6-PR stack; open on its own.
Test plan
vp checkon the shim fileexamples/that the error boundary still renders when thrown