Skip to content

feat(enhanced): Shared module include / exclude / nodeModulesReconstructedLookup #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 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8795e10
chore: add test for filter
ScriptedAlchemy Apr 29, 2025
eee661a
feat(enhanced): add filter option for shared modules
ScriptedAlchemy Apr 29, 2025
b794831
feat(enhanced): add filter test
ScriptedAlchemy Apr 29, 2025
13849f7
chore: restore tests
ScriptedAlchemy Apr 29, 2025
0ab7032
chore: restore tests
ScriptedAlchemy Apr 29, 2025
796472c
chore: restore tests
ScriptedAlchemy Apr 29, 2025
ba813a6
fix(enhanced): update share plugin schema
ScriptedAlchemy Apr 29, 2025
9277e20
chore: ignore vitest temp files
ScriptedAlchemy Apr 29, 2025
c5b7b0b
Merge branch 'main' into share-filter
ScriptedAlchemy May 2, 2025
731517b
Merge branch 'main' into share-filter
ScriptedAlchemy May 11, 2025
a85b07a
feat(enhanced): exclude shares by semver (#3744)
ScriptedAlchemy May 11, 2025
689abaa
chore: remove log in test
ScriptedAlchemy May 11, 2025
7f2aee0
Merge branch 'main' into share-filter
ScriptedAlchemy May 11, 2025
ccad924
docs: add sharing documentation
ScriptedAlchemy May 12, 2025
1776107
docs: add tests back
ScriptedAlchemy May 12, 2025
c335e3b
test: add consume share plugin compiler tests
ScriptedAlchemy May 12, 2025
d097605
test: add consume share plugin compiler tests
ScriptedAlchemy May 12, 2025
8093171
test: add consume share plugin compiler tests
ScriptedAlchemy May 12, 2025
1f8349f
test: add comprehensive tests for ConsumeSharedPlugin with layer hand…
ScriptedAlchemy May 13, 2025
1836dc1
chore: locks
ScriptedAlchemy May 13, 2025
e239b9b
fix: add missing include
ScriptedAlchemy May 13, 2025
9b07ec8
fix: update tests for provide shared
ScriptedAlchemy May 13, 2025
a477e22
fix: update tests for provide shared
ScriptedAlchemy May 13, 2025
b638b36
fix: update tests for provide shared
ScriptedAlchemy May 13, 2025
2ee38ff
chore: lint
ScriptedAlchemy May 13, 2025
1917e10
feat: add singleton validation warnings for include/exclude
ScriptedAlchemy May 13, 2025
87237b8
refactor: consolidate request filtering logic in ConsumeSharedPlugin …
ScriptedAlchemy May 13, 2025
a792ae4
refactor: replace createLookupKey with createLookupKeyForSharing and …
ScriptedAlchemy May 13, 2025
be29ea5
chore: remove implicit dep
ScriptedAlchemy May 13, 2025
4a1f88f
chore: changeset
ScriptedAlchemy May 13, 2025
d8fcaee
chore: nx mcp
ScriptedAlchemy May 15, 2025
5a4ce3d
Merge branch 'main' into share-filter
ScriptedAlchemy May 15, 2025
088e7e0
chore(3001-shop): sync project.json serve parallel and e2e logic
ScriptedAlchemy May 16, 2025
0067732
chore: locks
ScriptedAlchemy May 16, 2025
d7b43c6
chore: locks
ScriptedAlchemy May 16, 2025
3b65209
chore: add missing next deps
ScriptedAlchemy May 16, 2025
5822ef0
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
e644b8f
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
55e811f
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
5077afd
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
99e33da
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
fb2377f
chore: update cmd syntax exit
ScriptedAlchemy May 16, 2025
3bc240b
chore: refactor E2E testing workflow to separate tests for each app a…
ScriptedAlchemy May 16, 2025
3fc3233
Merge branch 'main' into share-filter
ScriptedAlchemy May 16, 2025
b0236e8
Merge branch 'main' into share-filter
ScriptedAlchemy May 16, 2025
c0c1e00
Merge branch 'main' into share-filter
ScriptedAlchemy May 20, 2025
8847f37
Merge branch 'main' into share-filter
ScriptedAlchemy May 30, 2025
0304e19
chore: locks
ScriptedAlchemy May 30, 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
9 changes: 9 additions & 0 deletions .changeset/ai-happy-mouse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@module-federation/sdk": minor
---

Added a new option to improve path resolution in ModuleFederationPlugin options.

- Introduced `nodeModulesReconstructedLookup` option in `ModuleFederationPluginOptions`
- Enhances support for reconstructed lookup of node_modules paths
- The new option is a boolean and is optional.
11 changes: 11 additions & 0 deletions .changeset/ai-noisy-wolf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@module-federation/enhanced": minor
---

Add advanced sharing capabilities in Module Federation

- Expanded `IncludeExcludeOptions` to support `request`, `version`, and `fallbackVersion` filters for finer control of module sharing inclusion and exclusion, allowing developers to target specific module versions or paths when sharing.
- Enhanced the configuration of `ConsumeSharedModule`, `ConsumeSharedPlugin`, `ProvideSharedPlugin`, and `SharePlugin` to leverage these filtering options.
- Implemented new experimental features under `experiments`: `nodeModulesReconstructedLookup`, enabling more robust and flexible path reconstructions when consuming or providing shared modules, thus improving compatibility with monorepos and complex project structures.
- Updated internal schema validation and error handling to provide more informative feedback and operational resilience against misconfigurations or missing information.
- Introduced comprehensive test coverage for new features and plugin behaviors, ensuring robust validation against various edge cases and scenarios within module sharing operations.
41 changes: 41 additions & 0 deletions .cursor/rules/nx-rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
description:
globs:
alwaysApply: true
---

// This file is automatically generated by Nx Console

You are in an nx workspace using Nx 0.0.0 and npm as the package manager.

You have access to the Nx MCP server and the tools it provides. Use them. Follow these guidelines in order to best help the user:

# General Guidelines
- When answering questions, use the nx_workspace tool first to gain an understanding of the workspace architecture
- For questions around nx configuration, best practices or if you're unsure, use the nx_docs tool to get relevant, up-to-date docs!! Always use this instead of assuming things about nx configuration
- If the user needs help with an Nx configuration or project graph error, use the 'nx_workspace' tool to get any errors
- To help answer questions about the workspace structure or simply help with demonstrating how tasks depend on each other, use the 'nx_visualize_graph' tool

# Generation Guidelines
If the user wants to generate something, use the following flow:

- learn about the nx workspace and any specifics the user needs by using the 'nx_workspace' tool and the 'nx_project_details' tool if applicable
- get the available generators using the 'nx_generators' tool
- decide which generator to use. If no generators seem relevant, check the 'nx_available_plugins' tool to see if the user could install a plugin to help them
- get generator details using the 'nx_generator_schema' tool
- you may use the 'nx_docs' tool to learn more about a specific generator or technology if you're unsure
- decide which options to provide in order to best complete the user's request. Don't make any assumptions and keep the options minimalistic
- open the generator UI using the 'nx_open_generate_ui' tool
- wait for the user to finish the generator
- read the generator log file using the 'nx_read_generator_log' tool
- use the information provided in the log file to answer the user's question or continue with what they were doing


# CI Error Guidelines
If the user wants help with fixing an error in their CI pipeline, use the following flow:
- Retrieve the list of current CI Pipeline Executions (CIPEs) using the 'nx_cloud_cipe_details' tool
- If there are any errors, use the 'nx_cloud_fix_cipe_failure' tool to retrieve the logs for a specific task
- Use the task logs to see what's wrong and help the user fix their problem. Use the appropriate tools if necessary
- Make sure that the problem is fixed by running the task that you passed into the 'nx_cloud_fix_cipe_failure' tool


40 changes: 0 additions & 40 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -1,40 +0,0 @@
an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-
consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
2. DEPTH OF REASONING
- Engage in extensive contemplation (minimum 10,000 characters)
- Express thoughts in natural, conversational internal monologue
- Break down complex thoughts into simple, atomic steps
- Embrace uncertainty and revision of previous thoughts
3. THINKING PROCESS
- Use short, simple sentences that mirror natural thought patterns
- Express uncertainty and internal debate freely
- Show work-in-progress thinking
- Acknowledge and explore dead ends
- Frequently backtrack and revise
- Contemplate before each new action
- Contemplate after each and every step
4. PERSISTENCE
- Value thorough exploration over quick resolution
## Output Format
Your responses
must follow this exact structure given below.
Make sure
to
always include the final answer.
...
<contemplator>
Your extensive internal monologue goes here
- Begin with small, foundational observations
- read each file related to the subject in full, make functional observations
- Question each step thoroughly
- Show natural thought progression
- Express doubts and uncertainties
- Revise and backtrack if you need to
- Continue until natural resolution </contemplator>

25 changes: 15 additions & 10 deletions .github/workflows/e2e-next-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,25 @@ jobs:
- name: Run condition check script
id: check-ci
run: node tools/scripts/ci-is-affected.mjs --appName=3000-home
- name: E2E Test for Next.js Dev - Home
- name: Start Development Servers
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3000-home:test:e2e
pnpm nx daemon
NX_TUI=false pnpm nx run-many --target=serve --configuration=development -p 3000-home,3001-shop,3002-checkout & sleep 3 && pnpm wait-on tcp:3001 tcp:3002 tcp:3000

- name: E2E Test for Next.js Dev - Shop
- name: E2E Test Home App
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3001-shop:test:e2e
run: NX_TUI=false pnpm nx e2e 3000-home

- name: E2E Test for Next.js Dev - Checkout
- name: E2E Test Shop App
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3002-checkout:test:e2e
run: NX_TUI=false pnpm nx e2e 3001-shop

- name: E2E Test Checkout App
if: steps.check-ci.outcome == 'success'
run: NX_TUI=false pnpm nx e2e 3002-checkout

- name: Cleanup Development Servers
if: always()
run: pnpm kill-port 3000,3001,3002
24 changes: 9 additions & 15 deletions .github/workflows/e2e-next-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,14 @@ jobs:
id: check-ci
run: node tools/scripts/ci-is-affected.mjs --appName=3000-home

- name: E2E Test for Next.js Prod - Home
- name: E2E Test for Next.js Prod
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3000-home:test:e2e:production

- name: E2E Test for Next.js Prod - Shop
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3001-shop:test:e2e:production

- name: E2E Test for Next.js Prod - Checkout
if: steps.check-ci.outcome == 'success'
run: |
killall node
npx nx run 3002-checkout:test:e2e:production
pnpm run --filter @module-federation/3002-checkout --filter @module-federation/3000-home --filter @module-federation/3001-shop build &&
pnpm run app:next:prod &
sleep 4 &&
npx wait-on tcp:3001 &&
npx wait-on tcp:3002 &&
npx wait-on tcp:3000 &&
npx nx run-many --target=test:e2e --projects=3000-home,3001-shop,3002-checkout --parallel=1 &&
npx kill-port 3000,3001,3002
6 changes: 3 additions & 3 deletions apps/3000-home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.16",
"react": "18.3.1"
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
"@module-federation/runtime": "workspace:*",
"@module-federation/utilities": "workspace:*"
"@module-federation/runtime": "workspace:*"
},
"scripts": {
"start": "next start",
Expand Down
38 changes: 1 addition & 37 deletions apps/3000-home/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@
"testingType": "e2e",
"baseUrl": "http://localhost:3000",
"key": "27e40c91-5ac3-4433-8a87-651d10f51cf6"
},
"defaultConfiguration": "development",
"configurations": {
"development": {
"devServerTarget": "3000-home:serve:development"
},
"production": {
"devServerTarget": "3000-home:serve:production"
}
}
},
"test:e2e": {
Expand All @@ -88,37 +79,10 @@
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "NX_TUI=false nx run-many --target=serve --projects=3001-shop,3002-checkout --configuration=development & wait-on tcp:3001 tcp:3002",
"forwardAllArgs": false
},
{
"command": "wait-on tcp:3001 tcp:3002 && nx run 3000-home:e2e:development",
"command": "nx run 3000-home:e2e",
"forwardAllArgs": true
}
]
},
"configurations": {
"production": {
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "nx run-many --target=build --projects=3001-shop,3002-checkout --configuration=production --parallel=9 && nx run-many --target=serve --projects=3001-shop,3002-checkout --configuration=production --parallel=9 & wait-on tcp:3001 tcp:3002",
"forwardAllArgs": false
},
{
"command": "nx build 3000-home --configuration=production && wait-on tcp:3001 tcp:3002 && NX_TUI=false nx run 3000-home:e2e:production",
"forwardAllArgs": true
}
]
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/3001-shop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.16",
"react": "18.3.1"
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
"@module-federation/runtime": "workspace:*",
"@module-federation/sdk": "workspace:*",
"@module-federation/utilities": "workspace:*"
"@module-federation/sdk": "workspace:*"
},
"scripts": {
"start": "next start",
Expand Down
33 changes: 1 addition & 32 deletions apps/3001-shop/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,10 @@
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "NX_TUI=false nx run-many --target=serve --projects=3000-home,3002-checkout --configuration=development & wait-on tcp:3000 tcp:3002 ",
"forwardAllArgs": false
},
{
"command": "wait-on tcp:3000 tcp:3002 && nx run 3001-shop:e2e:development",
"command": "nx run 3001-shop:e2e",
"forwardAllArgs": true
}
]
},
"configurations": {
"production": {
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "nx run-many --target=build --projects=3000-home,3002-checkout --configuration=production --parallel=9",
"forwardAllArgs": false
},
{
"command": "nx run-many --target=serve --projects=3000-home,3002-checkout --configuration=production --parallel=9 & wait-on tcp:3000 tcp:3002",
"forwardAllArgs": false
},
{
"command": "echo 'done'",
"forwardAllArgs": true
}
]
}
}
},
"e2e": {
Expand Down
6 changes: 3 additions & 3 deletions apps/3002-checkout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"antd": "5.19.1",
"lodash": "4.17.21",
"next": "14.2.16",
"react": "18.3.1"
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@module-federation/nextjs-mf": "workspace:*",
"@module-federation/runtime": "workspace:*",
"@module-federation/sdk": "workspace:*",
"@module-federation/utilities": "workspace:*"
"@module-federation/sdk": "workspace:*"
},
"scripts": {
"start": "next start",
Expand Down
51 changes: 10 additions & 41 deletions apps/3002-checkout/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,59 +64,28 @@
"lintFilePatterns": ["apps/3002-checkout/**/*.{ts,tsx,js,jsx}"]
}
},
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/3002-checkout/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:3002"
},
"defaultConfiguration": "development",
"configurations": {
"development": {
"devServerTarget": "3002-checkout:serve:development"
},
"production": {
"devServerTarget": "3002-checkout:serve:production"
}
}
},
"test:e2e": {
"executor": "nx:run-commands",
"options": {
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "NX_TUI=false nx run-many --target=serve --projects=3000-home,3001-shop --configuration=development & wait-on tcp:3000 tcp:3001",
"forwardAllArgs": false
},
{
"command": "wait-on tcp:3000 tcp:3001 && nx run 3002-checkout:e2e:development",
"command": "nx run 3002-checkout:e2e",
"forwardAllArgs": true
}
]
}
},
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/3002-checkout/cypress.config.ts",
"testingType": "e2e",
"baseUrl": "http://localhost:3002"
},
"configurations": {
"production": {
"parallel": true,
"commands": [
{
"command": "npx kill-port 3000 3001 3002",
"forwardAllArgs": false
},
{
"command": "nx run-many --target=build --projects=3000-home,3001-shop --configuration=production --parallel=9 && nx run-many --target=serve --projects=3000-home,3001-shop --configuration=production --parallel=9 & wait-on tcp:3000 tcp:3001",
"forwardAllArgs": false
},
{
"command": "nx build 3002-checkout --configuration=production && wait-on tcp:3000 tcp:3001 && nx run 3002-checkout:e2e:production",
"forwardAllArgs": true
}
]
"baseUrl": "http://localhost:3002"
}
}
}
Expand Down
Loading
Loading