From 5c7ac8a2c8704c70025590217971c721ae77e00f Mon Sep 17 00:00:00 2001 From: Zack Jackson Date: Tue, 13 Aug 2024 17:11:13 -0700 Subject: [PATCH] fix(runtime): provide error message when remote entry init fails (#2746) Co-authored-by: ScriptedAlchemy --- .changeset/tiny-pugs-fetch.md | 5 +++++ packages/runtime/src/module/index.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/tiny-pugs-fetch.md diff --git a/.changeset/tiny-pugs-fetch.md b/.changeset/tiny-pugs-fetch.md new file mode 100644 index 0000000000..718ec34980 --- /dev/null +++ b/.changeset/tiny-pugs-fetch.md @@ -0,0 +1,5 @@ +--- +'@module-federation/runtime': patch +--- + +provide error message when remote entry init fails diff --git a/packages/runtime/src/module/index.ts b/packages/runtime/src/module/index.ts index 28d22aba40..9479807bb1 100644 --- a/packages/runtime/src/module/index.ts +++ b/packages/runtime/src/module/index.ts @@ -103,6 +103,16 @@ class Module { origin: this.host, }); + if (typeof remoteEntryExports?.init === 'undefined') { + console.error( + 'The remote entry interface does not contain "init"', + '\n', + 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', + '\n', + 'Ensure that window[nameOfRemote] is returning a {get,init} object.', + ); + } + await remoteEntryExports.init( initContainerOptions.shareScope, initContainerOptions.initScope,