diff --git a/packages/angular/src/utils/mf/utils.ts b/packages/angular/src/utils/mf/utils.ts index b63c5e061dec27..1e67fc9cba352d 100644 --- a/packages/angular/src/utils/mf/utils.ts +++ b/packages/angular/src/utils/mf/utils.ts @@ -48,7 +48,14 @@ export function getFunctionDeterminateRemoteUrl(isServer: boolean = false) { const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.mjs'; return function (remote: string) { - const remoteConfiguration = readCachedProjectConfiguration(remote); + let remoteConfiguration = null; + try { + remoteConfiguration = readCachedProjectConfiguration(remote); + } catch (e) { + throw new Error( + `Cannot find project "${remote}". Check that the name is correct in module-federation config file.\n` + ); + } const serveTarget = remoteConfiguration?.targets?.[target]; if (!serveTarget) { diff --git a/packages/react/src/module-federation/utils.ts b/packages/react/src/module-federation/utils.ts index 85e6c0e0b6fa90..82de463d160599 100644 --- a/packages/react/src/module-federation/utils.ts +++ b/packages/react/src/module-federation/utils.ts @@ -21,7 +21,14 @@ export function getFunctionDeterminateRemoteUrl(isServer: boolean = false) { const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.js'; return function (remote: string) { - const remoteConfiguration = readCachedProjectConfiguration(remote); + let remoteConfiguration = null; + try { + remoteConfiguration = readCachedProjectConfiguration(remote); + } catch (e) { + throw new Error( + `Cannot find project "${remote}". Check that the name is correct in module-federation config file.\n` + ); + } const serveTarget = remoteConfiguration?.targets?.[target]; if (!serveTarget) {