fix(react): Update error message for invalid remote name (#19744)
This commit is contained in:
parent
b8296859f2
commit
022f1ea355
@ -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 remote "${remote}". Check that the remote name is correct in your module federation config file.\n`
|
||||
);
|
||||
}
|
||||
const serveTarget = remoteConfiguration?.targets?.[target];
|
||||
|
||||
if (!serveTarget) {
|
||||
|
||||
@ -50,7 +50,11 @@ export function readCachedProjectConfiguration(
|
||||
): ProjectConfiguration {
|
||||
const graph = readCachedProjectGraph();
|
||||
const node = graph.nodes[projectName];
|
||||
return node.data;
|
||||
try {
|
||||
return node.data;
|
||||
} catch (e) {
|
||||
throw new Error(`Cannot find project: '${projectName}' in your workspace.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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 remote: "${remote}". Check that the remote name is correct in your module federation config file.\n`
|
||||
);
|
||||
}
|
||||
const serveTarget = remoteConfiguration?.targets?.[target];
|
||||
|
||||
if (!serveTarget) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user