Skip to content

Commit

Permalink
fix(react): Update error message for invalid remote name (#19744)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham authored Oct 23, 2023
1 parent b829685 commit 022f1ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/angular/src/utils/mf/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion packages/nx/src/project-graph/project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
}

/**
Expand Down
9 changes: 8 additions & 1 deletion packages/react/src/module-federation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

1 comment on commit 022f1ea

@vercel
Copy link

@vercel vercel bot commented on 022f1ea Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.