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 federate-module generator #19286

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

ndcunningham
Copy link
Contributor

@ndcunningham ndcunningham commented Sep 21, 2023

This PR contains

A federate module generator which should do a few things:

Command

nx generate @nx/react:federate-module Carosel --path=carosel/src/lib/carosel --remote=ui
  1. It will generate/update a remote adding a path to a module provided to the generator
  2. Update if existing the module-federation.config.js to add a new entry to the exposes property for the new module

@ndcunningham ndcunningham self-assigned this Sep 21, 2023
@vercel
Copy link

vercel bot commented Sep 21, 2023

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

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Oct 6, 2023 5:26pm

Copy link
Contributor

@Coly010 Coly010 left a comment

Choose a reason for hiding this comment

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

Looks great!

i think there are a couple of things missing.

When we add the federated module, we should also add a path alias to the root tsconfig file following the same format.

”remote-app/MyModule”: [“./path/to/file”]

The only other things I’d love to have relate to testing.

  1. can we test an integrated repo, where the lib is a separate project? The remote could be in apps/ but the file we want to federate is in libs/ - perhaps we should update the description on the path flag in the schema to mention workspace root.
    You can see an example of where I’ve done this in an Angular app: https://github.com/Coly010/mf-federated-service-example/blob/main/apps/auth-remote/module-federation.config.js

  2. It would be great if our e2es tested federating a path, and then having that path be consumed in the host, and ensuring that build works and when served, the content of the federated module renders correctly.

i think the e2es you have currently which check if the files exist etc could become unit tests.

but overall this is awesome! 🎉 great work

Copy link
Contributor

@Coly010 Coly010 left a comment

Choose a reason for hiding this comment

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

One typo, but otherwise this looks great! 🎉

This is an exciting feature to have!

packages/react/src/generators/federate-module/schema.json Outdated Show resolved Hide resolved
@ndcunningham ndcunningham merged commit 8ccd88c into nrwl:master Oct 6, 2023
6 checks passed
@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 Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: react Issues related to React support for Nx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants