Skip to content

Commit

Permalink
fix(angular): eagerly load default packages (#10207)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed May 9, 2022
1 parent 38345da commit b513271
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/angular/src/utils/mfe/with-module-federation.ts
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

0 comments on commit b513271

Please sign in to comment.