fix(nextjs-mf): Refine Module Federation shares and correct request keys #3791
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit addresses feedback on the previous module federation sharing updates:
Corrects an issue where
$
was used at the end ofrequest
strings in shared module configurations (e.g.,unfetch$
). This suffix is not standard for Module Federation share keys and has been removed. Theimport
paths for these modules remain correct.Reinstates prefix-based shares in
share-internals-client.ts
fornext/dist/shared/
(withinclude: /shared-runtime/
) andnext/
(withexclude: /dist/
). This aligns with the preference for using broader shares where they suffice.Refines explicit shares in
share-internals-client.ts
:next/dist/shared/lib/shared-runtime.js
as it is now covered by the reinstated prefix share.next/link
) to specific internalnext/dist/...
paths.Reviewed explicit shares in
share-internals-server.ts
and confirmed their necessity due to specific internalimport
paths (for vendored React, Server Actions, aliased modules like@vercel/og
, and core server APIs likenext/headers
) and the absence of broad prefix shares on the server side. No shares were removed from this file.This approach ensures that module sharing is both comprehensive for critical Next.js internals and cleaner by preferring prefix shares where appropriate, while also correcting the format of request keys.
Description
Related Issue
Types of changes
Checklist