Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react): add withModuleFederationForSSR function #13276

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

Coly010
Copy link
Contributor

@Coly010 Coly010 commented Nov 20, 2022

Current Behavior

Module Federation is not supported in SSR

Expected Behavior

SSR should support Module Federation

@Coly010 Coly010 requested a review from jaysoo November 20, 2022 19:09
@Coly010 Coly010 self-assigned this Nov 20, 2022
@vercel
Copy link

vercel bot commented Nov 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Nov 22, 2022 at 11:04AM (UTC)

Comment on lines 5 to 21
function determineRemoteUrl(remote: string) {
const remoteConfiguration = readCachedProjectConfiguration(remote);
const serveTarget = remoteConfiguration?.targets?.serve;

if (!serveTarget) {
throw new Error(
`Cannot automatically determine URL of remote (${remote}). Looked for property "host" in the project's "serve" target.\n
You can also use the tuple syntax in your webpack config to configure your remotes. e.g. \`remotes: [['remote1', '//localhost:4201']]\``
);
}

const host = serveTarget.options?.host ?? '//localhost';
const port = serveTarget.options?.port ?? 4201;
return `${
host.endsWith('/') ? host.slice(0, -1) : host
}:${port}/remoteEntry.js`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaysoo This logic may need to change depending on how the server is launched (if the path to the server's location of remoteEntry.js is not at the root URL for example).

@Coly010 Coly010 force-pushed the module-federation/react-with-ssr branch from e2b3aaa to 779d4fc Compare November 21, 2022 09:31
@Coly010 Coly010 force-pushed the module-federation/react-with-ssr branch from 779d4fc to f39be34 Compare November 22, 2022 11:03
@Coly010 Coly010 merged commit 8be2980 into nrwl:master Nov 22, 2022
@Coly010 Coly010 deleted the module-federation/react-with-ssr branch November 22, 2022 12:16
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant