Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): add workaround for MF SSR #13372

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -47,13 +47,39 @@ function buildServerAppWithCustomWebpackConfiguration(
pathToWebpackConfig: string
) {
return executeServerBuilder(options, context as any, {
webpackConfiguration: (baseWebpackConfig) =>
mergeCustomWebpackConfig(
webpackConfiguration: async (baseWebpackConfig) => {
// Angular 15 auto includes code from @angular/platform-server
// This includes the code outside the shared scope created by ModuleFederation
// This code will be included in the generated code from our generators,
// maintaining it within the shared scope.
// Therefore, if the build is an MF Server build, remove the auto-includes from
// the base webpack config from Angular
let mergedConfig = await mergeCustomWebpackConfig(
baseWebpackConfig,
pathToWebpackConfig,
options,
context.target
),
);

if (
mergedConfig.plugins
.map((p) => p.constructor.name)
.includes('UniversalFederationPlugin')
) {
mergedConfig.entry.main = mergedConfig.entry.main.filter(
(m) => !m.startsWith('@angular/platform-server/init')
);
mergedConfig.module.rules = mergedConfig.module.rules.filter((m) =>
!m.loader
? true
: !m.loader.endsWith(
'@angular-devkit/build-angular/src/builders/server/platform-server-exports-loader.js'
)
);
}

return mergedConfig;
},
});
}

Expand Down