Skip to content

fix(shims): import local navigation module in error boundary#837

Merged
james-elicx merged 1 commit intocloudflare:mainfrom
NathanDrake2406:chore/shim-error-boundary
Apr 14, 2026
Merged

fix(shims): import local navigation module in error boundary#837
james-elicx merged 1 commit intocloudflare:mainfrom
NathanDrake2406:chore/shim-error-boundary

Conversation

@NathanDrake2406
Copy link
Copy Markdown
Contributor

Summary

The built package can execute shims/error-boundary.tsx before the plugin's resolveId hook is active, so the public next/navigation alias is not yet registered. Import the local ./navigation.js module 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 check on the shim file
  • Manual verification in examples/ that the error boundary still renders when thrown

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.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@837

commit: 21894a0

@NathanDrake2406 NathanDrake2406 marked this pull request as ready for review April 14, 2026 11:05
Copilot AI review requested due to automatic review settings April 14, 2026 11:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/navigation import with a direct relative import from ./navigation.js in 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.

@james-elicx
Copy link
Copy Markdown
Collaborator

/bigbonk review

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 14, 2026

Approved the PR. The change is correct and consistent with the rest of the codebase:

  • error-boundary.tsx was the only shim still importing from the public next/navigation alias. All 7 other sibling shims already use the direct ./navigation.js relative import.
  • The fix eliminates a real race condition where the built package could execute the shim before the plugin's resolveId hook registers the next/navigation alias.
  • The oxlint-disable-next-line suppression is correctly removed since the direct import doesn't trigger that lint rule.

github run

@james-elicx james-elicx merged commit 17a99e2 into cloudflare:main Apr 14, 2026
26 of 27 checks passed
@NathanDrake2406 NathanDrake2406 deleted the chore/shim-error-boundary branch April 15, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants