首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块联邦-没有AngularFireAuth提供程序

模块联邦-没有AngularFireAuth提供程序
EN

Stack Overflow用户
提问于 2020-08-12 01:58:00
回答 1查看 1.6K关注 0票数 1

我正在尝试用实现模块联邦,但我面临一个问题,不知道如何修复它。

的问题是:当X应用程序懒惰从使用Firebase的Y应用程序加载模块时,module不识别fire auth提供程序。

我有两个应用程序:、Auth、仪表板

我的Auth应用程序使用firebase进行用户登录。

防火墙请求登录是通过NgRX效果进行的:

代码语言:javascript
复制
    import {AngularFireAuth} from '@angular/fire/auth';

    @Injectable()
    export class AuthEffects {
      
      userLogin$: Observable<Action> = createEffect(() => {
        /* effect implementation */
      });
      
      constructor(private fireAuth: AngularFireAuth){}
    }

AuthModule导入:

代码语言:javascript
复制
imports: [
    /* ...other imports */
    StoreModule.forFeature('authState', authReducer),
    EffectsModule.forFeature([AuthEffects]),
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireAuthModule
]

仪表板AppRoutingModule导入:

代码语言:javascript
复制
const routes: Routes = [
  {
      path: '',
      pathMatch: 'full',
      loadChildren: () => import('auth/AuthModule').then(m => m.AuthModule)
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  exports: [RouterModule]
})

当我只启动Auth应用程序时,一切正常,我可以登录。

但是,当我试图远程使用Auth应用程序时,在仪表板应用程序中,我会得到以下错误:

代码语言:javascript
复制
NullInjectorError: StaticInjectorError(AppModule)[InjectionToken angularfire2.app.options]: 
  StaticInjectorError(Platform: core)[InjectionToken angularfire2.app.options]: 
    NullInjectorError: No provider for InjectionToken angularfire2.app.options!

部分Auth - webpack.config.js

代码语言:javascript
复制
    plugins: [
        new ModuleFederationPlugin({
          name: 'auth',
          library: {type: 'var', name: 'auth'},
          filename: 'remoteEntry.js',
          exposes: {
            './AuthModule': './src/app/login/auth.module.ts',
            './AuthComponent': './src/app/login/auth.component.ts',
            './AuthActions': './src/app/store/actions/auth.actions.ts',
            './AuthReducer': './src/app/store/reducers/auth.reducer.ts',
            './AuthEffects': './src/app/store/effects/auth.effects'
          },
          shared: {
            ...dependencies,
            '@angular/core': {
              requiredVersion: dependencies['@angular/core'],
              singleton: true,
            },
            '@angular/common': {
              requiredVersion: dependencies['@angular/common'],
              singleton: true,
            },
            '@angular/router': {
              requiredVersion: dependencies['@angular/router'],
              singleton: true,
            }
          }
        })
    ]

疟疾仪表板- webpack.config.js

代码语言:javascript
复制
    plugins: [
        new ModuleFederationPlugin({
          name: 'dashboard',
          library: {type: 'var', name: 'dashboard'},
          filename: 'remoteEntry.js',
          remotes: {
            auth: 'auth',
          },
          shared: {
            ...dependencies,
            '@angular/core': {
              requiredVersion: dependencies['@angular/core'],
              singleton: true,
            },
            '@angular/common': {
              requiredVersion: dependencies['@angular/common'],
              singleton: true,
            },
            '@angular/router': {
              requiredVersion: dependencies['@angular/router'],
              singleton: true,
            }
          }
        })
      ]

我试图自己解决它,但模块联盟是一个新的东西,我们有很少的帖子。

有人能帮我吗?如果你来这之前,非常感谢你!

EN

回答 1

Stack Overflow用户

发布于 2020-08-12 06:57:45

解决了!

谢谢扎克·杰克逊我能解决这个问题。

解决方案:

https://github.com/module-federation/module-federation.github.io/issues/14#issuecomment-672647713

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63368656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档