Angular 和模块联合的 SSR

SSR with Angular and Module Federation

我正在使用 angular 版本 13.1.0,并且我已经通过 ng add @nguniversal/common 启用了 SSR。添加此配置后,我使用 ng add @angular-architects/module-federation@14.0.1 添加模块联合。这会添加额外的配置来执行 SSR,其中之一是从 server.ts 文件中的 @nguniversal/common 修改 CustomResourceLoader

import { CustomResourceLoader } from '@nguniversal/common/clover/server/src/custom-resource-loader'; // Not found CustomResourceLoader
import { createFetch } from '@angular-architects/module-federation/nguniversal';

...

// Without mappings, remotes are loaded via HTTP
const mappings = {
};

// Monkey Patching Angular Universal for Module Federation
CustomResourceLoader.prototype.fetch = createFetch(mappings);

@nguniversal/common@13.0.2 的新版本不导出 CustomResourceLoader,因此无法修改它以供模块联合使用..

您知道使 @nguniversal/common 与模块联合兼容的方法吗?

此刻(2022年2月)模块联邦的github提到了这个:

"because of a bug in Angular Universal 13, SSR is currently not supported for Angular 13. However, we are monitoring this situation and providing a solution as soon as these issues are fixed."

https://github.com/angular-architects/module-federation-plugin/blob/main/migration-guide.md