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

fix(react): mf remote name incorrect with directory option #17430

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

victoriahu
Copy link
Contributor

@victoriahu victoriahu commented Jun 5, 2023

Current Behavior

When a developer generates a remote via CLI and passes in a directory (e.g. ▶ yarn nx generate @nrwl/react:remote --name=test --host=host-name --directory=apps/host-name/applications), the remote uses the project name, while the host does not use the project name.

Then the developer must take the following steps to run their host without error:

  • Change their remote name in apps/host-name/src/remotes.d.ts.

declare module "test/Module"; >> declare module "host-name-applications-test/Module";

  • Change their remote name in apps/host-name/module-federation.config.ts.
const moduleFederationConfig = {
  ...baseConfig,
  name: "host-name",
  remotes: [
    ... other remotes,
    // "," --> delete this line
    // change from this --> "test", to the below:
    "host-name-applications-test",
  ],
  additionalShared: [
    ...baseConfig.additionalShared,
  ],
};

This is because Nx uses the directory to prepend the project name, and passing in options.name to the host does not prepend the directory. Therefore passing in a directory to the CLI will mean that the parameter passed in to the updateHostWithRemote method will always be incorrect.

Expected Behavior

When a developer generates a remote via CLI and passes in a directory, the remote and the host both use the project name. There is no need to update either the remotes.d.ts or module-federation.config.ts files.

Related Issue(s)

#16308

Fixes #

@victoriahu victoriahu requested a review from a team as a code owner June 5, 2023 22:29
@victoriahu victoriahu requested a review from jaysoo June 5, 2023 22:29
@vercel
Copy link

vercel bot commented Jun 5, 2023

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

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2023 10:32pm

@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 Jun 28, 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.

2 participants