Skip to content

Commit 9e32644

Browse files
ScriptedAlchemysquadronai[bot]github-advanced-security[bot]2heal1
authored
feat(enhanced): fully hoisted runtime (#2932)
Co-authored-by: squadronai[bot] <170149692+squadronai[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Hanric <[email protected]>
1 parent b2bfa48 commit 9e32644

File tree

71 files changed

+26729
-21426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+26729
-21426
lines changed

.changeset/ai-brave-tiger.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@module-federation/data-prefetch": patch
3+
---
4+
5+
Refactored the way prefetch entries are imported for improved dynamic loading handling.
6+
7+
- Changed the import of prefetch entries to use a function wrapper for more dynamic control.
8+
- Updated data types to ensure consistency with the new function-based import approach.
9+
- Modified the `injectPrefetch` function structure to incorporate the new import method.
10+
- Modified the `MFDataPrefetch` class to handle the new import function when resolving exports.

.changeset/ai-brave-wolf.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@module-federation/nextjs-mf": minor
3+
---
4+
5+
Simplified InvertedContainerPlugin by removing configuration dependencies and improving runtime module integration.
6+
7+
- Refactored `InvertedContainerPlugin` to remove redundant configurations.
8+
- Deleted `EmbeddedContainerPlugin` and moved its logic into `InvertedContainerPlugin`.
9+
- Modified `InvertedContainerRuntimeModule` to dynamically locate and integrate container entry modules.
10+
- Commented out runtime chunk creation in `configureServerCompilerOptions`.
11+
- Enhanced module dependency handling using `FederationModulesPlugin` hooks.

.changeset/ai-hungry-wolf.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@module-federation/runtime": patch
3+
---
4+
5+
Added comprehensive integration tests for the API synchronization and enhanced the embedded module proxy implementation.
6+
7+
- Added detailed integration tests for API consistency between embedded and index modules.
8+
- Tests include export comparison and method consistency for `FederationHost` and `Module` classes.
9+
- Introduced and updated the `embedded.ts` file to dynamically access the runtime modules at runtime.
10+
- Included detailed implementations for accessing and wrapping existing runtime functions.
11+
- Exposed the previously private `formatOptions` method in the `FederationHost` class publicly.
12+
- Enhanced error handling for uninstantiated or unregistered runtime access.
13+
```

.changeset/ai-lazy-cat.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@module-federation/enhanced": patch
3+
---
4+
5+
Added support for hoisting federation runtime modules and enhancing dependency management.
6+
7+
- Introduced `FederationModulesPlugin` to handle federation-related hooks and dependencies.
8+
- Added new `FederationRuntimeDependency` and logic to include it conditionally.
9+
- Enhanced `ContainerPlugin` and related plugins to support experimental `federationRuntime` options.
10+
- Modified `HoistContainerReferencesPlugin` to hoist additional modules in chunks.
11+
- Implemented changes across multiple files to support the new plugin and dependency management features.

.changeset/ai-quick-lion.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@module-federation/sdk": patch
3+
---
4+
5+
Added experimental option for federation runtime in ContainerPluginOptions.
6+
7+
- Extended `ContainerPluginOptions` to include an `experiments` property.
8+
- Within `experiments`, added a `federationRuntime` option.
9+
- `federationRuntime` can be either `false` or `'hoisted'`.

.changeset/ai-sleepy-lion.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@module-federation/enhanced": patch
3+
---
4+
5+
Refactor `HoistContainerReferencesPlugin` to optimize module disconnection and cleanup logic.
6+
7+
- Removed `moduleToDelete` set as it was redundant.
8+
- Ensured all referenced modules are disconnected from unused chunks directly.
9+
- Added call to `cleanUpChunks` within the main loop to clean up chunks using `allReferencedModules`.

.changeset/chilly-rocks-deliver.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@module-federation/runtime": patch
3+
---
4+
5+
- Refactor `embedded.ts` to use a proxy pattern for better runtime compatibility:
6+
- Implement FederationHost and Module classes that delegate to the actual runtime implementation
7+
- Expose all public methods and properties from the original classes
8+
- Use a lazy initialization approach to ensure proper runtime loading
9+
- Add comprehensive test suite for API synchronization between embedded.ts and index.ts
10+
- Introduce new test file `sync.spec.ts` with extensive tests for API compatibility
11+
- Ensure FederationHost and Module classes have the same methods in both files
12+
- Test various scenarios including remote loading, manifest handling, and circular dependencies
13+
- Modify `core.ts` to make `formatOptions` method public
14+

.changeset/eight-comics-reflect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/enhanced': patch
3+
---
4+
5+
handle chunk entry modules correctly in MfStartupChunkDependenciesPlugin

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ jobs:
3636
- name: Check Code Format
3737
run: npx nx format:check
3838

39+
- name: Warm Nx Cache
40+
run: npx nx run-many --targets=build --projects=tag:type:pkg
41+
3942
- name: Run Build for All
4043
run: npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache
4144

4245
- name: Run Affected Test
4346
run: npx nx affected -t test --parallel=2 --exclude='*,!tag:type:pkg' --skip-nx-cache
4447

45-
- name: Warm Nx Cache
46-
run: npx nx run-many --targets=build --projects=tag:type:pkg
48+
- name: Run Affected Experimental Tests
49+
run: npx nx affected -t test:experiments --parallel=2 --exclude='*,!tag:type:pkg' --skip-nx-cache
4750

4851
e2e-modern:
4952
needs: checkout-install

.github/workflows/devtools.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,35 @@ jobs:
3535
run: pnpm install
3636

3737
- name: Run Affected Build
38-
run: npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache
38+
run: npx nx run-many --targets=build --projects=tag:type:pkg
3939

4040
- name: Configuration xvfb
4141
shell: bash
4242
run: sudo apt-get update && sudo apt-get install xvfb
4343

44-
- name: E2E Chrome Devtools
45-
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 && sleep 10 && npx nx e2e:devtools chrome-devtools
44+
- name: E2E Chrome Devtools Dev
45+
uses: nick-fields/retry@v3
46+
with:
47+
timeout_minutes: 10
48+
max_attempts: 3 # Initial attempt + 2 retries
49+
command: |
50+
npx kill-port 3009 3010 3011 3012 3013 4001 &&
51+
pnpm run app:manifest:dev & echo "done" && \
52+
npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 tcp:3013 && \
53+
sleep 10 &&
54+
npx nx e2e:devtools chrome-devtools
55+
56+
- name: E2E Chrome Devtools Prod
57+
uses: nick-fields/retry@v3
58+
with:
59+
timeout_minutes: 10
60+
max_attempts: 3 # Initial attempt + 2 retries
61+
command: |
62+
npx kill-port 3009 3010 3011 3012 3013 4001 &&
63+
pnpm run app:manifest:prod & echo "done" && \
64+
npx wait-on tcp:3009 tcp:3010 tcp:3011 tcp:3012 tcp:3013 && \
65+
sleep 10 &&
66+
npx nx e2e:devtools chrome-devtools
4667
4768
- name: kill port
48-
run: lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill
69+
run: npx kill-port 3013 3009 3010 3011 3012 4001

0 commit comments

Comments
 (0)