mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #852] [CLOSED] fix(shims): handle memo/forwardRef components in next/dynamic module resolution #899
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#899
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/852
Author: @467469274
Created: 4/16/2026
Status: ❌ Closed
Base:
main← Head:feat/cjs-transform-import-optimization-dynamic-w8📝 Commits (1)
33715d7fix(shims): handle memo/forwardRef in next/dynamic module resolution📊 Changes
1 file changed (+74 additions, -11 deletions)
View changed files
📝
packages/vinext/src/shims/dynamic.ts(+74 -11)📄 Description
Problem
React.lazy()requires{ default: Function }, butReact.memo()andReact.forwardRef()produce objects with a$$typeofSymbol instead of plain functions.When a library exports a memo-wrapped or forwardRef-wrapped component as its default export:
The current
"default" in modcheck indynamic.tspasses, but React.lazy fails at render time:This affects all 4 lazy paths: client SSR-false, async server, server lazy, and client lazy.
Solution
Added a
resolveModule()function with 4-tier fallback:mod.defaultis a function → use directly (most common, no behavior change)mod.defaultis a$$typeofobject (memo/forwardRef) → wrap in thin function component$$typeofexport → wrapThe wrapper creates a thin function component via
React.createElement(comp, props)soReact.lazy()can consume it. Display names are preserved for DevTools.Changes
wrapNonFunctionComponent()helperresolveModule()with 4-tier resolution"default" in modchecks withresolveModule()callTest plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.