Skip to content

Commit d942a1c

Browse files
fix(nextjs-mf): only call module factory in valid conditions (#2226)
Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent ec033d7 commit d942a1c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/fast-games-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/nextjs-mf': patch
3+
---
4+
5+
only call module factory in valid conditions in runtime plugin

packages/nextjs-mf/src/plugins/container/runtimePlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ export default function (): FederationRuntimePlugin {
7373
onLoad(args) {
7474
const { exposeModuleFactory, exposeModule, id } = args;
7575
const moduleOrFactory = exposeModuleFactory || exposeModule;
76-
if (!moduleOrFactory) return; // Ensure moduleOrFactory is defined
77-
let exposedModuleExports: any = moduleOrFactory();
76+
if (!moduleOrFactory) return args; // Ensure moduleOrFactory is defined
7877

7978
if (typeof window === 'undefined') {
79+
let exposedModuleExports: any = moduleOrFactory();
80+
8081
const handler: ProxyHandler<any> = {
8182
get(target, prop, receiver) {
8283
// Check if accessing a static property of the function itself

0 commit comments

Comments
 (0)