我正在致力于一个具有微前端架构的角11项目。我的门户有多个被开发为MFE的应用程序。我确实有很多常见的设计组件,比如表单、表和仪表板etc.what是最好的实现方法,可以让这些组件在MFE中作为可重用的?
发布于 2022-01-07 15:40:15
如果您在@angular-architects/module-federation/webpack
中使用MFE,您可以创建一个共享库(我主要使用NX )。示例配置:
const sharedMappings = new SharedMappings();
sharedMappings.register(tsConfigPath, ['@xxx/shared-components'], workspaceRootPath);
// inside your module.export //
new ModuleFederationPlugin({
name: 'xxx',
filename: 'xxx',
exposes: {
'./Login': 'apps/frontend/auth/src/app/modules/login/login.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(),
}),
您可以找到更多有关这方面的信息:模块联合插件
https://stackoverflow.com/questions/70342623
复制相似问题