I am creating a microfrontend application using Angular ModuleFederation Application.
I've a reactive form in the 1 micro app
<input type="text" [formControl]="email" />
<span class="text-danger" *ngIf="email.hasError('required')">This field is required</span>
So, when I run this app http://localhost:4201/setup
everything works fine with the validation.
After packing this app,
new ModuleFederationPlugin({
// For remotes (please adjust)
name: "businessSetup",
filename: "businessSetupRemoteEntry.js",
exposes: {
'./BusinessSetupModule': './projects/business-setup/src/app/components/setup/setup.module.ts',
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
When I run the host app http://localhost:4200
, the micro app loads but there is a weird behavior with the validation. It is duplicating as below and I've no clue.
host app webpack
new ModuleFederationPlugin({
// For hosts (please adjust)
remotes: {
"businessSetup": "businessSetup@http://localhost:4201/businessSetupRemoteEntry.js",
},
shared: share({
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
...sharedMappings.getDescriptors()
})
}),
Any clues, please?
Update:
This is just not working with the route url changes
Works when the url is
http://localhost:4200
but not when the url is
http://localhost:4200/test