From 87a28620bc9139b07365b6755addb1924333e930 Mon Sep 17 00:00:00 2001 From: Rohith Ramakrishnan <6977429+MadaraUchiha-314@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:52:13 -0700 Subject: [PATCH] fix: add optional check while accessing webpack internals #2968 (#3120) --- .changeset/chilly-experts-walk.md | 5 +++++ packages/node/src/utils/hot-reload.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilly-experts-walk.md diff --git a/.changeset/chilly-experts-walk.md b/.changeset/chilly-experts-walk.md new file mode 100644 index 0000000000..f0674ecd93 --- /dev/null +++ b/.changeset/chilly-experts-walk.md @@ -0,0 +1,5 @@ +--- +'@module-federation/node': patch +--- + +add optional check while accessing webpack internals diff --git a/packages/node/src/utils/hot-reload.ts b/packages/node/src/utils/hot-reload.ts index 8c58d0f0f6..534c031e9a 100644 --- a/packages/node/src/utils/hot-reload.ts +++ b/packages/node/src/utils/hot-reload.ts @@ -168,7 +168,7 @@ export const performReload = async ( } }); //@ts-ignore - __webpack_require__.federation.instance.moduleCache.clear(); + __webpack_require__?.federation?.instance?.moduleCache?.clear(); helpers.global.resetFederationGlobalInfo(); globalThis.moduleGraphDirty = false; globalThis.mfHashMap = {};