Skip to content

Commit 0172491

Browse files
fix(enhanced): rehydrate bundler runtime in web workers (#4417)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
1 parent a2f44a1 commit 0172491

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.changeset/sharp-crabs-sing.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+
Fix federation runtime bootstrap to rehydrate bundler runtime in workers.

packages/enhanced/src/lib/container/runtime/FederationRuntimePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class FederationRuntimePlugin {
136136
});
137137
}
138138
const embedRuntimeLines = Template.asString([
139-
`if(!${federationGlobal}.runtime){`,
139+
`if(!${federationGlobal}.runtime || !${federationGlobal}.bundlerRuntime){`,
140140
Template.indent([
141141
`var prevFederation = ${federationGlobal};`,
142142
`${federationGlobal} = {}`,

packages/enhanced/test/unit/container/FederationRuntimePlugin.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,19 @@ describe('FederationRuntimePlugin runtimePluginCalls', () => {
188188
expect(template).toContain('plugin_0 ? (plugin_0.default || plugin_0)');
189189
});
190190
});
191+
192+
describe('runtime bootstrap guards', () => {
193+
it('rehydrates bundler runtime when runtime exists but bundlerRuntime is missing', () => {
194+
const template = FederationRuntimePlugin.getTemplate(
195+
compiler as Compiler,
196+
mockOptions,
197+
'bundler-runtime.js',
198+
{},
199+
);
200+
201+
expect(template).toContain(
202+
'if(!__webpack_require__.federation.runtime || !__webpack_require__.federation.bundlerRuntime)',
203+
);
204+
});
205+
});
191206
});

0 commit comments

Comments
 (0)