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): eagerly load default packages #10207

Merged
merged 1 commit into from
May 9, 2022
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
17 changes: 16 additions & 1 deletion packages/angular/src/utils/mfe/with-module-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
} from '@nrwl/workspace/src/utilities/typescript';
import { ParsedCommandLine } from 'typescript';
import { readWorkspaceJson } from 'nx/src/project-graph/file-utils';
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
import { readRootPackageJson } from './utils';
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');

export type MFERemotes = string[] | [remoteName: string, remoteUrl: string][];

Expand Down Expand Up @@ -225,6 +225,20 @@ function applyAdditionalShared(
}
}

function applyDefaultEagerPackages(
sharedConfig: Record<string, SharedLibraryConfig>
) {
const DEFAULT_PACKAGES_TO_LOAD_EAGERLY = ['@angular/localize/init'];
for (const pkg of DEFAULT_PACKAGES_TO_LOAD_EAGERLY) {
if (sharedConfig[pkg]) {
return {
...sharedConfig,
eager: true,
};
}
}
}

export async function withModuleFederation(options: MFEConfig) {
const DEFAULT_NPM_PACKAGES_TO_AVOID = ['zone.js', '@nrwl/angular/mfe'];

Expand Down Expand Up @@ -260,6 +274,7 @@ export async function withModuleFederation(options: MFEConfig) {
...npmPackages,
};

applyDefaultEagerPackages(sharedDependencies);
applySharedFunction(sharedDependencies, options.shared);
applyAdditionalShared(
sharedDependencies,
Expand Down