Skip to content

Commit d8773d7

Browse files
fix(enhanced): add runtime safety checks to prevent errors
- Add typeof check for oldStartup function in EmbedFederationRuntimeModule - Add typeof check for __webpack_require__.x in StartupHelpers These defensive checks prevent runtime errors when expected functions don't exist in certain build configurations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 52b123f commit d8773d7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class EmbedFederationRuntimeModule extends RuntimeModule {
7171
` hasRun = true;`,
7272
` ${initRuntimeModuleGetter};`,
7373
`}`,
74-
`return oldStartup();`,
74+
`if (typeof oldStartup === 'function') {`,
75+
` return oldStartup();`,
76+
`}`,
7577
],
7678
)};`,
7779
]);

packages/enhanced/src/lib/startup/StartupHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const generateEntryStartup = (
4949
'',
5050
'\n',
5151
'var promises = [];',
52-
'__webpack_require__.x();',
52+
'if (typeof __webpack_require__.x === "function") __webpack_require__.x();',
5353
];
5454

5555
const treeRuntimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);

0 commit comments

Comments
 (0)