You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
extractLicenses crashes with "Cannot read properties of undefined (reading 'trim')" when using Module Federation shared modules with webpack >= 5.107 #34360
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
21.x (with webpack <= 5.106.2)
Description
@angular-devkit/build-angular:browser production builds that use Module Federation shared modules (for example, via @angular-architects/module-federation) crash when extractLicenses is true.
The crash comes from license-webpack-plugin 4.0.2, a dependency of @angular-devkit/build-angular. webpack 5.107.0 (webpack/webpack#20860) changed ProvideSharedModule.identifier() from provide module (scope) name@version = request to provide module (scope) name@version|request. The plugin still parses the identifier with filename.split('=')[1].trim() (dist/WebpackInnerModuleIterator.js), which throws.
@angular-devkit/build-angular 22.2.x depends on webpack 5.111.0, so every Module Federation app on the webpack builder is affected unless it disables extractLicenses (and so loses 3rdpartylicenses.txt).
license-webpack-plugin has had no commits since 2023. I reported the bug there as well: .
Possible actions:
patch, fork or vendor license-webpack-plugin in @angular-devkit/build-angular, or
guard the provide module case (the fix is a few lines, see the linked issue).
Minimal Reproduction
ng new mf-app (Angular 22), then ng add @angular-architects/module-federation --type host.
Make sure webpack.config.js declares at least one shared package (the default shareAll(...) is enough).
ng build --configuration production (with extractLicenses: true, the default for production).
Workaround: apply the fix to license-webpack-plugin with patch-package. Setting "extractLicenses": false also avoids the crash, but then no license file is generated.
@angular-devkit/build-angular:browser does not natively support Module Federation or custom Webpack configurations. Using ModuleFederationPlugin requires modifying the internal Webpack configuration via a third-party builder (such as @angular-architects/module-federation), which is not supported by the Angular team. Additionally, the Webpack-based build pipeline (browser builder) is deprecated in favor of the @angular/build:application builder (which can be used with solutions like @angular-architects/native-federation).
Because this crash is caused by an upstream incompatibility between webpack >= 5.107.0 and license-webpack-plugin when ProvideSharedModule is added to the Webpack compilation, we do not plan to fork or monkey-patch license-webpack-plugin in @angular-devkit/build-angular.
If a fix is released upstream in license-webpack-plugin (e.g., 4.0.3), it will be picked up automatically by the existing ^4.0.2 version range. In the meantime, the recommended workarounds are:
Migrating to the @angular/build:application builder and @angular-architects/native-federation
Patching license-webpack-plugin locally (e.g., via patch-package or pnpm patch)
Reporting this to @angular-architects/module-federation, as their builder could potentially adjust or wrap the plugin in the custom Webpack config.
Activity
alan-agius4 commentedon Oct 15, 2026
@angular-devkit/build-angular:browserdoes not natively support Module Federation or custom Webpack configurations. UsingModuleFederationPluginrequires modifying the internal Webpack configuration via a third-party builder (such as@angular-architects/module-federation), which is not supported by the Angular team. Additionally, the Webpack-based build pipeline (browserbuilder) is deprecated in favor of the@angular/build:applicationbuilder (which can be used with solutions like@angular-architects/native-federation).Because this crash is caused by an upstream incompatibility between
webpack >= 5.107.0andlicense-webpack-pluginwhenProvideSharedModuleis added to the Webpack compilation, we do not plan to fork or monkey-patchlicense-webpack-pluginin@angular-devkit/build-angular.If a fix is released upstream in
license-webpack-plugin(e.g.,4.0.3), it will be picked up automatically by the existing^4.0.2version range. In the meantime, the recommended workarounds are:@angular/build:applicationbuilder and@angular-architects/native-federationlicense-webpack-pluginlocally (e.g., viapatch-packageorpnpm patch)@angular-architects/module-federation, as their builder could potentially adjust or wrap the plugin in the custom Webpack config.