You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that if i update my host_v1 module-federation-config.ts file like below that fixes things..
What I also noticed is that when i perform a normal build with the app everything works.
When checking the difference I noticed that when i'm running the pnpm nx run host_v1:serve There is a runtime.js file loaded on the page..
During a normal rspack build everything is working as expected.
I'm wondering if the run time itself is not getting the proper paths to the urls from the other remote.
Before:
import { ModuleFederationConfig } from '@nx/module-federation'
const config: ModuleFederationConfig = {
name: 'host_v1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: ['header_v1', 'footer_v1'],
}
/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config
After:
import { ModuleFederationConfig } from '@nx/module-federation'
const config: ModuleFederationConfig = {
name: 'host_v1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
exposes: {}, // THIS IS CHANGEEEEEE
remotes: ['header_v1', 'footer_v1'],
}
/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config
The text was updated successfully, but these errors were encountered:
Current Behavior
When I execute:
pnpm nx run host_v1:serve
and I open up the localhost link.I get the following error:
Expected Behavior
When I execute:
pnpm nx run host_v1:serve
and I open up the localhost link.I expect to see the modules linked correctly and the webpage working.
GitHub Repo
https://github.com/sceptre12/nx_bug1
Steps to Reproduce
Execute the following:
pnpx create-nx-workspace@latest --pm pnpm
pnpm nx add @nx/react
pnpm nx g @nx/react:host apps/shell_v1 --e2eTestRunner none --bundler rspack --style tailwind
Open up the shell_v1 proejct.json file and select the project name and do a find and replace to ensure the name for the project is shell_v1
pnpm nx g @nx/react:remote apps/remotes/header --e2eTestRunner none --bundler rspack --style tailwind --host shell_v1
pnpm nx g @nx/react:remote apps/remotes/footer --e2eTestRunner none --bundler rspack --style tailwind --host shell_v1
pnpm nx run shell_v1:serve --verbose --skip-nx-cache
Click on the link. On the webpage click on header or footer and you should see a similar error
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
There is a work around for this issue.
It seems that if i update my host_v1 module-federation-config.ts file like below that fixes things..
What I also noticed is that when i perform a normal build with the app everything works.
When checking the difference I noticed that when i'm running the
pnpm nx run host_v1:serve
There is a runtime.js file loaded on the page..During a normal rspack build everything is working as expected.
I'm wondering if the run time itself is not getting the proper paths to the urls from the other remote.
Before:
After:
The text was updated successfully, but these errors were encountered: