module-federation-examples icon indicating copy to clipboard operation
module-federation-examples copied to clipboard

From my feature module app_base_href value and interceptor declared in the app module can not be accessible.

Open dmlgncn opened this issue 3 years ago • 1 comments

I m exposing one future module from my mfe. From my feature module app_base_href setter and interceptor declared in the app module will not be accessible.

In my app.module.ts

import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { MfeFutureModule } from './mfe-future/mfe-future.module';
import { AuthTokenInterceptorService } from './services/auth/auth-token-interceptor.service';
@NgModule({
  declarations: [
     AppComponent,
     ErrorPopupComponent
  ],
  imports: [
     HttpClientModule,
     BrowserModule,
     MfeFutureModule, 
    HotkeyModule.forRoot({ cheatSheetCloseEsc: true, }),
     NgxWebstorageModule.forRoot(),
  ],
  providers: [
    {
      provide: APP_BASE_HREF,
      useValue:'/admin/ui/editor'
    },   
           {
      provide: HTTP_INTERCEPTORS,
      useClass: AuthTokenInterceptorService,
      multi: true
    }
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
plugins: [
    new ModuleFederationPlugin({
      name: 'editor',

      library: {

        type: 'var',

        name: 'editor'

      },

      filename: "remoteEntry.js",

      exposes: {

        './Module':'./src/app/kpi-mfe/mfe-future.module.ts'

      },

      shared: share({
        "@angular/core": { requiredVersion: 'auto', singleton: true  },
        "@angular/common": { requiredVersion: 'auto', singleton: true  },
        "@angular/router": { requiredVersion: 'auto' , singleton: true },
        "@angular/common/http": { requiredVersion: 'auto', singleton: true  },

        // Uncomment for sharing lib of an Angular CLI or Nx workspace
        ...sharedMappings.getDescriptors()
      })

    }),

If I add them to my future module , I m getting an error and it is not proposed for future modules as mentioned below: https://juristr.com/blog/2021/04/angular-di-and-lazy-modules/

Also I added them(interceptor and base_href) to one component in my future module. But it does not work as well. Can you help me?

dmlgncn avatar Jun 07 '22 02:06 dmlgncn

Not an angular dev, so cannot help here. I do work with a consulting firm who specialized in angular and MF If your company needs contract/consulting on angular

ScriptedAlchemy avatar Jun 28 '22 07:06 ScriptedAlchemy