Skip to content

feat(nextjs-mf): RSC Support #3736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 116 commits into
base: pr9-implementation
Choose a base branch
from
Open

Conversation

ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Apr 29, 2025

This pull request includes various changes across documentation, configuration, and code enhancements for the Module Federation plugin. The key updates include the addition of new experimental features, enhancements to shared module configurations, and improvements to testing and dependency management.

Documentation Updates:

  • Added a new section for the nodeModulesReconstructedLookup experiment in apps/website-new/docs/en/configure/experiments.mdx, explaining its purpose and usage for resolving relative imports in node_modules.
  • Documented new properties (packageName, shareKey, strictVersion, and version) for shared configurations in apps/website-new/docs/en/configure/shared.mdx. These properties enhance control over shared module behavior.

Experimental Features:

  • Introduced the nodeModulesReconstructedLookup experiment in apps/website-new/docs/en/configure/experiments.mdx and packages/enhanced/src/lib/container/ModuleFederationPlugin.ts to improve module resolution for shared dependencies. [1] [2]

Code Enhancements:

  • Added support for exclude and include options in the ProvideSharedPlugin to allow filtering shared modules by version or request. [1] [2]
  • Refactored ProvideSharedPlugin to encapsulate the logic for providing shared modules, improving maintainability. [1] [2]

Testing Improvements:

  • Expanded test coverage by including test/compiler-unit/**/*.test.ts in packages/enhanced/jest.config.ts and package.json. This ensures the new features and configurations are thoroughly tested. [1] [2]

Dependency Management:

  • Added @module-federation/cli as a dependency in packages/enhanced/package.json to support CLI operations for the enhanced package. [1] [2]

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Copy link

changeset-bot bot commented Apr 29, 2025

🦋 Changeset detected

Latest commit: f9ec75f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
@module-federation/runtime-core Major
@module-federation/nextjs-mf Minor
@module-federation/sdk Major
@module-federation/enhanced Major
@module-federation/runtime Major
@module-federation/bridge-react Major
@module-federation/devtools Major
@module-federation/cli Major
@module-federation/data-prefetch Major
@module-federation/dts-plugin Major
@module-federation/esbuild Patch
@module-federation/managers Major
@module-federation/manifest Major
@module-federation/modern-js Major
@module-federation/node Patch
@module-federation/retry-plugin Major
@module-federation/rsbuild-plugin Major
@module-federation/rspack Major
@module-federation/rspress-plugin Major
@module-federation/storybook-addon Major
@module-federation/utilities Patch
@module-federation/webpack-bundler-runtime Major
@module-federation/bridge-react-webpack-plugin Major
@module-federation/bridge-vue3 Major
@module-federation/modernjsapp Patch
@module-federation/runtime-tools Major
remote5 Patch
website-new Patch
@module-federation/inject-external-runtime-core-plugin Major
@module-federation/third-party-dts-extractor Major
@module-federation/bridge-shared Major
@module-federation/error-codes Major
create-module-federation Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Apr 29, 2025

Deploy Preview for module-federation-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 6fa3596
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6893ecc9cc6bb90008140e7e

@ScriptedAlchemy ScriptedAlchemy changed the title feat(enhanced): prefix share exclusion feat(enhanced): Shared module include / exclude May 11, 2025
@ScriptedAlchemy ScriptedAlchemy changed the title feat(enhanced): Shared module include / exclude feat(enhanced): Shared module include / exclude / nodeModulesReconstructedLookup May 12, 2025
@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review May 15, 2025 23:33
@ScriptedAlchemy ScriptedAlchemy force-pushed the share-filter branch 2 times, most recently from 94b858a to 4bd1354 Compare July 6, 2025 20:48
Comment on lines +135 to +141
needs: checkout-install
uses: ./.github/workflows/e2e-next-app-router.yml
secrets: inherit

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{}}

Copilot Autofix

AI 6 days ago

To fix the problem, add a permissions block at the top level of the workflow file (just after the name: and before on:), which will apply to all jobs unless overridden. The minimal safe default is contents: read, which allows jobs to read repository contents but not write to them. If any job requires additional permissions, those can be set at the job level. In this case, since there is no evidence that any job requires write permissions, setting permissions: contents: read at the workflow level is the best fix. This change should be made at the top of .github/workflows/build-and-test.yml, after the name: line and before the on: block.


Suggested changeset 1
.github/workflows/build-and-test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -1,2 +1,4 @@
 name: Build Affected Packages
+permissions:
+  contents: read
 
EOF
@@ -1,2 +1,4 @@
name: Build Affected Packages
permissions:
contents: read

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@ScriptedAlchemy ScriptedAlchemy changed the title feat(enhanced): Shared module include / exclude / nodeModulesReconstructedLookup feat(nextjs-mf): RSC Support Jul 24, 2025
@ScriptedAlchemy ScriptedAlchemy changed the base branch from main to pr9-implementation August 7, 2025 00:04
Copy link
Member Author

ScriptedAlchemy commented Aug 8, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

ScriptedAlchemy and others added 25 commits August 11, 2025 16:02
…App Router applications

- Update Next.js environment type definitions for improved compatibility
- Enhance context click counter component with better error boundaries
- Add comprehensive error handling pages for nested route structures
- Improve hooks demonstration page with additional Next.js navigation APIs
- Update main layout and page components with better remote component integration
- Add Cypress e2e test configurations for module federation validation
- All changes support enhanced nodeModulesReconstructedLookup functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…4001 remote application

- Update Next.js environment type definitions with navigation compatibility
- Enhance router context layout with improved hooks implementation
- Update ISR layout with better tab group integration
- Improve main layout with enhanced global navigation and error boundaries
- Update category layout with async parameter handling for React 19
- Enhance main page with Random component integration
- Update Next.js configuration with enhanced module federation settings
- Upgrade package dependencies to React 19 with proper type definitions
- Remove demo page that was added inadvertently
- All changes support enhanced nodeModulesReconstructedLookup functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
… node packages

- Enhance Node.js runtime plugin with improved filesystem loading capabilities
- Add comprehensive semver testing for complex version range scenarios including OR ranges
- Update runtime core constants for better default remote type handling
- Improve core federation host with enhanced plugin deduplication logic
- Enhance remote module loading with better module resolution and matching
- Remove unnecessary mock fsevents binary file from test suite
- All changes support enhanced nodeModulesReconstructedLookup functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…ignore

- Update Next.js 4000 app configuration with enhanced module federation settings
- Upgrade Next.js 4000 package dependencies to React 19 with proper script handling
- Enhance address bar component with improved remote button integration
- Update global navigation component with better layout and navigation handling
- Add .node binary files to .gitignore to prevent accidental commits
- Complete incremental merge of all enhanced nodeModulesReconstructedLookup features

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…mporary files

- Restore __mocks__/remotes/index.js for proper test mocking
- Restore missing pages/router-test.tsx files for both Next.js applications
- Restore missing button components (classic/button.tsx, rsc/button.tsx)
- Restore ui/random.tsx component
- Remove temporary pnpm-lock.yaml files and development artifacts
- Complete final synchronization between branches

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove __mocks__/remotes/index.js that was inadvertently restored
- Update pnpm-lock.yaml with latest dependency resolutions
- Final cleanup to ensure branches are properly synchronized

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed failing e2e-next tests by reverting nextjs-mf dependencies from
fixed version '0.0.0-next-20250701105507' back to 'workspace:*' in:
- apps/3001-shop/package.json
- apps/3002-checkout/package.json

This resolves module loading issues where the apps couldn't find
the nextjs-mf patches directory, allowing proper Next.js federation
to work correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed NextFederationPlugin to use correct path '../../loaders/next-flight-loader'
instead of '../../patches/next-flight-loader' since the patches directory
doesn't exist. This resolves module loading errors for Next.js 15+ apps.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
… commit

Restored missing e2e target configurations from the last working commit
9b7dff2:

- Added defaultConfiguration: "development" for both apps
- Added development configuration with devServerTarget
- Fixed production configuration for 3002-checkout to use devServerTarget

This matches the old CI infrastructure that was working properly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Reverted to the main branch pattern where each e2e test manages its own
server dependencies:

- Updated GitHub workflows to run individual test:e2e commands
- Restored project.json test:e2e configurations from main branch
- Each app now starts required federated dependencies before testing
- Removed centralized server management approach

Shop e2e tests are now working properly with automatic dependency management.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Co-authored-by: Hanric <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Wei Tang Lin <[email protected]>
Co-authored-by: Claude <[email protected]>
…ain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Created a detailed plan to split the massive changes in packages/enhanced
into 12 focused, incremental PRs:
- Runtime safety fixes (independent)
- Hook renaming refactor
- Container hoisting improvements
- Share filtering features (broken into 4 sub-features)
- Layer support enhancements
- API exports and test coverage

Each PR is self-contained with clear dependencies documented.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Created a detailed plan to split the massive changes in packages/enhanced
into 12 focused, incremental PRs:
- Runtime safety fixes (COMPLETED - PR #3900)
- Hook renaming refactor
- Container hoisting improvements
- Share filtering features (broken into 4 sub-features)
- Layer support enhancements
- API exports and test coverage

Each PR is self-contained with clear dependencies documented.

Also added worktrees/ to .gitignore

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Add missing module declarations for shop remote in remotes.d.ts to fix
TypeScript compilation errors that were causing the Next.js application
to fail with 500 Internal Server Error during Cypress E2E tests.

The missing declarations included:
- shop/menu
- shop/pages/shop/index
- shop/pages/shop/exposed-pages
- shop/pages/shop/test-webpack-png
- shop/pages/shop/test-webpack-svg
- shop/pages/shop/products/[...slug]

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Updated test expectations to match the new error message format
when loadShareSync is called incorrectly from the runtime.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Apply suggested changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants