Closed jesperume closed 1 month ago
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 ๐
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
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.