Hi!
The new native federation version looks pretty good, and its very fast. However, with the version it looks like sharedMappings are no longer singleton, or something prevents it from working like before. The loading service we have not working anymore, which seems to be the case because the subscription to loading state lives on a separate instance of the service (it only ever receives the initial false and then never again). This is already the case in the shell, not even in the micro frontend. It looked like the service is injected twice, even though it should be a singleton instance. I found it weird that it is seemingly in the shared mapping and the bootstrap as well:
loading-indicator.service.ts:16 [LoadingIndicatorService] INSTANCE CREATED #1 Error
at new _LoadingIndicatorService (http://localhost:4200/_somelib.js:119862:83)
at Object.LoadingIndicatorService_Factory [as factory] (http://localhost:4200/_somelib.js:119885:14)
at http://localhost:4200/chunk-FXF3KUBP.js:1340:47
at runInInjectorProfilerContext (http://localhost:4200/chunk-FXF3KUBP.js:409:9)
at R3Injector.hydrate (http://localhost:4200/chunk-FXF3KUBP.js:1338:21)
at R3Injector.get (http://localhost:4200/chunk-FXF3KUBP.js:1218:33)
at R3Injector.retrieve (http://localhost:4200/chunk-FXF3KUBP.js:1129:25)
at injectInjectorOnly (http://localhost:4200/chunk-FXF3KUBP.js:676:39)
at ɵɵinject (http://localhost:4200/chunk-FXF3KUBP.js:688:61)
at inject (http://localhost:4200/chunk-FXF3KUBP.js:697:12)
...
loading-indicator.service.ts:16 [LoadingIndicatorService] INSTANCE CREATED #1 Error
at new _LoadingIndicatorService (http://localhost:4200/bootstrap-LYF4SCVX.js:136:83)
at Object.LoadingIndicatorService_Factory [as factory] (http://localhost:4200/bootstrap-LYF4SCVX.js:159:14)
at http://localhost:4200/chunk-FXF3KUBP.js:1340:47
at runInInjectorProfilerContext (http://localhost:4200/chunk-FXF3KUBP.js:409:9)
at R3Injector.hydrate (http://localhost:4200/chunk-FXF3KUBP.js:1338:21)
at R3Injector.get (http://localhost:4200/chunk-FXF3KUBP.js:1218:33)
at ChainedInjector.get (http://localhost:4200/_angular_core.HquQGppmK0-dev.js:8244:36)
at lookupTokenUsingModuleInjector (http://localhost:4200/_angular_core.HquQGppmK0-dev.js:588:39)
at getOrCreateInjectable (http://localhost:4200/_angular_core.HquQGppmK0-dev.js:613:12)
at ɵɵdirectiveInject (http://localhost:4200/_angular_core.HquQGppmK0-dev.js:8851:19)
Federation config:
import { share, withNativeFederation } from '@angular-architects/native-federation/config';
export default withNativeFederation({
name: 'shell',
shared: {
...share({
'@angular/core': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
includeSecondaries: { keepAll: true },
},
'@angular/common': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
includeSecondaries: { keepAll: true },
},
'@angular/common/http': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/common/locales/de': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/common/locales/en': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/router': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/forms': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/platform-browser': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/platform-browser-dynamic': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@jsverse/transloco': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
rxjs: {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
}),
},
sharedMappings: ['somelib'],
features: {
ignoreUnusedDeps: true,
},
});
Happy to provide more information if required!
Hi!
The new native federation version looks pretty good, and its very fast. However, with the version it looks like sharedMappings are no longer singleton, or something prevents it from working like before. The loading service we have not working anymore, which seems to be the case because the subscription to loading state lives on a separate instance of the service (it only ever receives the initial
falseand then never again). This is already the case in the shell, not even in the micro frontend. It looked like the service is injected twice, even though it should be a singleton instance. I found it weird that it is seemingly in the shared mapping and the bootstrap as well:Federation config:
Happy to provide more information if required!