Skip to content

feat(nextjs-mf): App Router #3596

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

Draft
wants to merge 89 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5b107fa
feat(enhanced): support layers
ScriptedAlchemy Nov 17, 2024
062706f
feat(enhanced): support layers
ScriptedAlchemy Nov 17, 2024
cfd9d01
feat(enhanced): layers for consume shared module
ScriptedAlchemy Nov 21, 2024
3e59c55
Merge branch 'main' into layers-support
ScriptedAlchemy Nov 21, 2024
536b110
Merge branch 'main' into layers-support
ScriptedAlchemy Nov 21, 2024
aed08e9
feat(enhanced): add issuerLayer support to consume shared
ScriptedAlchemy Nov 22, 2024
9fb164b
chore(enhanced): update test
ScriptedAlchemy Nov 25, 2024
a9d899c
chore(enhanced): update test
ScriptedAlchemy Nov 25, 2024
33a36d1
feat(enhanced): ConsumeSharedPlugin issuerLayer support
ScriptedAlchemy Nov 25, 2024
f0c5c50
chore: update tests for layer combos
ScriptedAlchemy Nov 25, 2024
578adbb
chore: update tests for layer combos
ScriptedAlchemy Nov 25, 2024
31f08d0
chore: update tests for layer combos
ScriptedAlchemy Nov 25, 2024
066ffa6
feat(enhanced): support direct layer
ScriptedAlchemy Nov 25, 2024
b70eb8d
Merge branch 'main' into layers-support
ScriptedAlchemy Nov 25, 2024
358ba00
fix(enhanced): update share options of share plugin
ScriptedAlchemy Nov 25, 2024
94d72ed
fix(enhanced): update share options of share plugin
ScriptedAlchemy Nov 25, 2024
91dbb12
chore(enhanced): refactor layers tests
ScriptedAlchemy Nov 25, 2024
514cf03
chore(enhanced): remove layer options from provider
ScriptedAlchemy Nov 25, 2024
359b0ca
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Nov 25, 2024
24ef6d0
Delete .cursorrules
ScriptedAlchemy Nov 25, 2024
9d9bff2
feat(enhanced): support layers in consume share
ScriptedAlchemy Nov 26, 2024
40ae817
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Nov 26, 2024
d1c68b3
fix(enhanced): rename requiredLayer to layer
ScriptedAlchemy Dec 2, 2024
22964f8
Merge remote-tracking branch 'origin/consume-share-layers' into consu…
ScriptedAlchemy Dec 2, 2024
9884030
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 2, 2024
3d8fa21
refactor(enhanced): pr review of consume share layering
ScriptedAlchemy Dec 3, 2024
69a2a52
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 3, 2024
04b8ffd
chore: locks
ScriptedAlchemy Dec 3, 2024
7852878
feat(enhanced): add request to consume share (#3307)
ScriptedAlchemy Dec 5, 2024
f35b1b1
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 5, 2024
b8df73e
chore: remove tt
ScriptedAlchemy Dec 9, 2024
b4b5a7b
chore: remove unused share
ScriptedAlchemy Dec 9, 2024
6f8f45e
refactor(enhanced): refactor type locations
ScriptedAlchemy Dec 10, 2024
875f516
feat(enhanced): ProvideSharedPlugin loader layer support (#3334)
ScriptedAlchemy Dec 12, 2024
673f6ca
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 12, 2024
20bae5b
chore: locks
ScriptedAlchemy Dec 12, 2024
a5774c8
chore(enhanced): add share plugin test
ScriptedAlchemy Dec 13, 2024
d44acbd
chore(enhanced): add share plugin test
ScriptedAlchemy Dec 13, 2024
1a33ac7
chore(enhanced): add share plugin test
ScriptedAlchemy Dec 13, 2024
1fc2b05
thing
ScriptedAlchemy Dec 13, 2024
29f6d73
thing
ScriptedAlchemy Dec 13, 2024
22127ee
chore(node): lint
ScriptedAlchemy Dec 13, 2024
8f9fb99
chore(node): lint
ScriptedAlchemy Dec 13, 2024
243f1bc
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 13, 2024
0c665be
feat(enhanced): layers support in module code generation (#3371)
ScriptedAlchemy Dec 29, 2024
ffdaf0b
chore: changeset
ScriptedAlchemy Dec 31, 2024
687365f
feat(enhanced): Layer via composite shareKey (#3415)
ScriptedAlchemy Dec 31, 2024
4ef6efb
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Dec 31, 2024
81d2365
chore: locks
ScriptedAlchemy Dec 31, 2024
6f952fd
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Jan 1, 2025
5fce760
chore: locks
ScriptedAlchemy Jan 1, 2025
1fba24f
fix(enhanced): cache consume module layer
ScriptedAlchemy Jan 2, 2025
7af571f
fix(nextjs-mf): enable app router shares and disable hard fail
ScriptedAlchemy Jan 2, 2025
7a178c0
chore: add host remote app router
ScriptedAlchemy Jan 2, 2025
10f2b73
feat(nextjs-mf): update module share for rsc
ScriptedAlchemy Jan 3, 2025
e122bf4
feat(nextjs-mf): update module share for rsc
ScriptedAlchemy Jan 21, 2025
c3729a7
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Feb 18, 2025
e6a109d
chore: fix schema validation eror
ScriptedAlchemy Feb 18, 2025
ee0726d
chore: fix schema validation errors
ScriptedAlchemy Feb 18, 2025
2fc6497
fix(enhanced): schema validation
ScriptedAlchemy Feb 18, 2025
baaeb27
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Feb 19, 2025
55abb84
chore: locks
ScriptedAlchemy Feb 19, 2025
cfca731
chore: update schema
ScriptedAlchemy Feb 19, 2025
6e6ef06
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Feb 25, 2025
41e1a84
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Mar 12, 2025
aef1bb2
chore: locks
ScriptedAlchemy Mar 12, 2025
fb936d3
chore: fix json schema
ScriptedAlchemy Mar 12, 2025
0ff2e2c
chore: fix json schema
ScriptedAlchemy Mar 12, 2025
42bf94c
chore: fix json schema
ScriptedAlchemy Mar 12, 2025
2c52030
feat(enhanced): implement multiple share scope support (#3524)
ScriptedAlchemy Mar 14, 2025
83261cc
chore: add next with app router
ScriptedAlchemy Mar 14, 2025
fc201b9
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Mar 14, 2025
a3899fc
chore: add next with app router
ScriptedAlchemy Mar 14, 2025
25277fc
chore: update deps
ScriptedAlchemy Mar 14, 2025
b23bb46
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Mar 14, 2025
f0b2404
chore: update deps
ScriptedAlchemy Mar 14, 2025
01b6767
chore: update deps
ScriptedAlchemy Mar 14, 2025
cc658b9
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Mar 14, 2025
6835348
chore: update deps
ScriptedAlchemy Mar 14, 2025
a8b5055
fix: add next apps to workspace
ScriptedAlchemy Mar 14, 2025
4431551
feat(nextjs-mf): app router support
ScriptedAlchemy Mar 15, 2025
dc6d0c0
Merge branch 'main' into consume-share-layers
ScriptedAlchemy Mar 15, 2025
3fe3803
feat(nextjs-mf): app router support
ScriptedAlchemy Mar 16, 2025
d25ff57
Merge branch 'consume-share-layers' into app-router-support
ScriptedAlchemy Mar 18, 2025
df4a103
Merge branch 'main' into app-router-support
ScriptedAlchemy Apr 21, 2025
133a858
Merge branch 'refs/heads/main' into app-router-support
ScriptedAlchemy Apr 23, 2025
2e2b7cb
fix(nextjs-mf): layered module sharing in next
ScriptedAlchemy Apr 23, 2025
6afefd8
refactor: remove duplicate share groups from internal.ts
ScriptedAlchemy Apr 29, 2025
17e2d05
Merge branch 'main' into app-router-support
ScriptedAlchemy Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/ai-eager-wolf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@module-federation/runtime-core": minor
---

Added support for OR ranges in semantic version satisfaction logic with comprehensive unit tests.

- Implemented parsing for OR (||) conditions in version ranges.
- Split input ranges by || to evaluate alternatives individually.
- Ensured logical handling of wildcards '*' and 'x' within ranges.
- Refactored internal parsing to support more complex range constructs.
- Added comprehensive test cases to cover diverse scenarios for OR range support.
- Introduced error handling during range processing, with console logging for tracking issues.
12 changes: 12 additions & 0 deletions .changeset/ai-happy-fox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@module-federation/nextjs-mf": minor
---

Refactor and enhance module federation support for Next.js.

- Introduced `getShareScope` function to dynamically generate the default share scope based on the client or server environment, replacing static DEFAULT_SHARE_SCOPE declarations.
- Implemented `RscManifestInterceptPlugin` to intercept and modify client reference manifests, ensuring proper prefix handling.
- Refined server-side externals handling to ensure shared federation modules are bundled.
- Simplified and modularized sharing logic by creating distinct functions for React, React DOM, React JSX Runtime, and React JSX Dev Runtime package configurations.
- Captured the original webpack public path for potential use in plugins and adjustments.
- Enhanced logging for debug tracing of shared module resolution processes in runtimePlugin.
9 changes: 9 additions & 0 deletions .changeset/ai-hungry-bear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"@module-federation/enhanced": minor
---

Enhancements to layer handling in module federation tests and configuration.

- Improved handling of `shareKey` for layers within `ConsumeSharedPlugin` and `ProvideSharedPlugin`.
- Conditionally prepend the `shareKey` with the `layer` if applicable.
- Introduced new layer configurations to support more nuanced federation scenarios that consider multiple layers of dependency.
```
9 changes: 9 additions & 0 deletions .changeset/ai-sleepy-fox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@module-federation/enhanced": patch
---

Refactored module sharing configuration handling.

- Simplified plugin schema for better maintainability
- Improved layer-based module sharing test coverage
- Removed redundant plugin exports
6 changes: 6 additions & 0 deletions .changeset/ai-sleepy-tiger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@module-federation/runtime": minor
---

- Added a new property 'layer' of type string or null to SharedConfig.
```
5 changes: 5 additions & 0 deletions .changeset/brown-badgers-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/enhanced': minor
---

support request option on ConsumeSharePlugin. Allows matching requests like the object key of shared does
5 changes: 5 additions & 0 deletions .changeset/shy-snails-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/enhanced': minor
---

Layer support for Provide Share Plugin
2 changes: 1 addition & 1 deletion apps/next-app-router/next-app-router-4000/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AddressBar } from '#/ui/address-bar';
import Byline from '#/ui/byline';
// import { GlobalNav } from 'remote_4001/GlobalNav(rsc)';
import { Metadata } from 'next';

console.log(require('remote_4001/Button'));
export const metadata: Metadata = {
title: {
default: 'Next.js App Router',
Expand Down
3 changes: 2 additions & 1 deletion apps/next-app-router/next-app-router-4000/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { demos } from '#/lib/demos';
import Link from 'next/link';
import { lazy } from 'react';
import dynamic from 'next/dynamic';
const Button = dynamic(() => import('remote_4001/Button'), { ssr: true });
const Button = lazy(() => import('remote_4001/Button'));

export default function Page() {
return (
Expand Down
4 changes: 2 additions & 2 deletions apps/next-app-router/next-app-router-4000/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const nextConfig = {
filename: 'static/chunks/remoteEntry.js',
remotes: {
remote_4001: remotes.remote_4001,
shop: remotes.shop,
checkout: remotes.checkout,
// shop: remotes.shop,
// checkout: remotes.checkout,
},
shared: {
// 'react': {
Expand Down
4 changes: 2 additions & 2 deletions apps/next-app-router/next-app-router-4000/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"serve": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm dev",
"cwd": "apps/next-app-router-4000"
"command": "npm run dev",
"cwd": "apps/next-app-router/next-app-router-4000"
},
"dependsOn": [
{
Expand Down
12 changes: 5 additions & 7 deletions apps/next-app-router/next-app-router-4001/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import '#/styles/globals.css';
import { AddressBar } from '#/ui/address-bar';
import Byline from '#/ui/byline';
// import { AddressBar } from '#/ui/address-bar';
// import Byline from '#/ui/byline';
import { GlobalNav } from '#/ui/global-nav';
import { Metadata } from 'next';
// import { Metadata } from 'next';

export const metadata: Metadata = {
title: {
Expand Down Expand Up @@ -36,15 +36,13 @@ export default function RootLayout({
<div className="lg:pl-72">
<div className="mx-auto max-w-4xl space-y-8 px-2 pt-20 lg:px-8 lg:py-8">
<div className="rounded-lg bg-vc-border-gradient p-px shadow-lg shadow-black/20">
<div className="rounded-lg bg-black">
<AddressBar />
</div>
<div className="rounded-lg bg-black">{/*<AddressBar />*/}</div>
</div>

<div className="rounded-lg bg-vc-border-gradient p-px shadow-lg shadow-black/20">
<div className="rounded-lg bg-black p-3.5 lg:p-6">{children}</div>
</div>
<Byline />
{/*<Byline />*/}
</div>
</div>
</body>
Expand Down
3 changes: 2 additions & 1 deletion apps/next-app-router/next-app-router-4001/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { demos } from '#/lib/demos';
import Link from 'next/link';

import React from 'react';
console.log(React);
export default function Page() {
return (
<div className="space- y-8">
Expand Down
1 change: 1 addition & 0 deletions apps/next-app-router/next-app-router-4001/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
4 changes: 2 additions & 2 deletions apps/next-app-router/next-app-router-4001/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const nextConfig = {
// Core UI Components
'./Button': './ui/button',
// './Header': isServer ? './ui/header?rsc' : './ui/header?shared',
'./Footer': './ui/footer',
// './Footer': './ui/footer',
// './GlobalNav(rsc)': isServer ? './ui/global-nav?rsc' : './ui/global-nav',
// './GlobalNav(ssr)': isServer ? './ui/global-nav?ssr' : './ui/global-nav',
'./GlobalNav': './ui/global-nav',
// './GlobalNav': './ui/global-nav',
//
// // Product Related Components
// './ProductCard': './ui/product-card',
Expand Down
37 changes: 37 additions & 0 deletions apps/next-app-router/next-app-router-4001/pages/router-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import Link from 'next/link';

const RouterTestPage = () => {
return (
<div>
<h1>Router Test Page (in Pages Directory)</h1>
<p>
This page exists in the 'pages' directory of an app that primarily uses
the App Router ('app' directory).
</p>
<p>
Below are links demonstrating navigation potentially involving different
router types:
</p>
<ul>
<li>
{/* Link within the current app (likely handled by App Router if root exists there) */}
<Link href="/">Link to App Root</Link>
</li>
<li>
{/* Link to an external app known to use Pages Router */}
<a href="http://localhost:3000/">
Link to Home App (Pages Router via full URL)
</a>
</li>
<li>Placeholder for other routing/federation examples.</li>
</ul>
<p>
Note: The instruction "sets both routers" was interpreted as
demonstrating links to potentially different router contexts.
</p>
</div>
);
};

export default RouterTestPage;
6 changes: 3 additions & 3 deletions apps/next-app-router/next-app-router-4001/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "next-app-router-4001",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/next-app-router-4001",
"sourceRoot": "apps/next-app-router/next-app-router-4001",
"projectType": "application",
"tags": [],
"targets": {
Expand All @@ -27,8 +27,8 @@
"serve": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm dev",
"cwd": "apps/next-app-router-4001"
"command": "npm run dev",
"cwd": "apps/next-app-router/next-app-router-4001"
},
"dependsOn": [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"prepare": "husky install",
"changeset": "changeset",
"build:packages": "npx nx affected -t build --parallel=10 --exclude='*,!tag:type:pkg'",
"changegen": "./changeset-gen.js --path ./packages/enhanced --staged &&./changeset-gen.js --path ./packages/cli --staged && ./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged && ./changeset-gen.js --path ./packages/dts-plugin --staged",
"changegen": "node ./changeset-gen.js --path ./packages/runtime-core && ./changeset-gen.js --path ./packages/enhanced --staged &&./changeset-gen.js --path ./packages/cli --staged && ./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged && ./changeset-gen.js --path ./packages/dts-plugin --staged",
"commitgen:staged": "./commit-gen.js --path ./packages --staged",
"commitgen:main": "./commit-gen.js --path ./packages",
"changeset:status": "changeset status",
Expand Down
Loading
Loading