-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Hyphen in module federation host project name causes remotes application to crash in dev mode #28497
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
Comments
We have the same problem preventing us from upgrading to v20. There was a PR that partially fixed this in v20.0.1 but it didn't catch everything. |
@jesperume Good catch! And apologies for the disruption around this, and apologies to @barrymichaeldoyle too. There were two different changes in Nx 20 which caused these issues as a side effect. From my testing, I didn't encounter the dev remote issue, but I understand it. I'll get this fixed asap. |
@Coly010 you absolute legend! Thank you 🎉 And thank you @jesperume for logging the issue 👍 |
…trol plugin #28497 (#28512) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> As part of the work to normalize `-` in MF project names for Federation, setting the NX_MF_DEV_REMOTES env var was missed. This causes issues with the RuntimeLibraryControlPlugin ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Remote names should be normalized correctly ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28497
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
It's not possible to upgrade to NX 20 when a react host in module federation contains a hyphen in the project name.
Expected Behavior
It's should be possible to upgrade to NX 20 with the new Module federation 2.0 runtime continuing to use a hyphen in the project name for a host, for example "app-shell".
GitHub Repo
No response
Steps to Reproduce
npx nx generate @nx/react:host --directory=apps/app-shell --bundler=webpack --name=app-shell --remotes=remote1 --dynamic=true --e2eTestRunner=none --no-interactive
Running
npx nx run app-shell:serve
will work when the remote will be built and served staticallyRunning
npx nx run app-shell:serve --devRemotes=remote1
will not work as the react application will crash due to "Cannot read properties of null (reading 'useContext')"After hours of troubleshooting I can see that the host name in http://localhost:4200/remoteEntry.js is incorrect and makes the the remote to not reuse the hosts resources. The failing code is below. Notice the app-shell name has not been transformed as it have in other places where "app-shell" has been transformed to "app_shell" (with underscore).
This patch will make it work and I hope it helps figuring out where the changes need to be made. Notice that in the repo there is several places where process.env.NX_MF_DEV_REMOTES will be set.
Nx Report
Node : 20.17.0
OS : win32-x64
Native Target : x86_64-windows
npm : 10.5.0
nx : 20.0.1
@nx/js : 20.0.1
@nx/jest : 20.0.1
@nx/eslint : 20.0.1
@nx/workspace : 20.0.1
@nx/cypress : 20.0.1
@nx/devkit : 20.0.1
@nx/eslint-plugin : 20.0.1
@nx/playwright : 20.0.1
@nx/react : 20.0.1
@nx/vite : 20.0.1
@nx/web : 20.0.1
@nx/webpack : 20.0.1
typescript : 5.5.4
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/playwright/plugin
@nx/jest/plugin
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
Please make it possible to continue to use hyphens in host project names. I hope you can revisit the other change that has been made in remotes that can no longer contain hyphens. In javascript developlement kebab-case are golden standard for directories and therefore it won't make sense to force project names to not be able to contain hyphens.
The text was updated successfully, but these errors were encountered: