Skip to content

extractLicenses crashes with "Cannot read properties of undefined (reading 'trim')" when using Module Federation shared modules with webpack >= 5.107 #34360

Closed as not planned

Description

@agilulf-dev

Command

build

Is this a regression?

  • 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

  1. ng new mf-app (Angular 22), then ng add @angular-architects/module-federation --type host.
  2. Make sure webpack.config.js declares at least one shared package (the default shareAll(...) is enough).
  3. ng build --configuration production (with extractLicenses: true, the default for production).

Exception or Error

- Generating browser application bundles (phase: setup)...
✔ Browser application bundle generation complete.
An unhandled exception occurred: Cannot read properties of undefined (reading 'trim')

Your Environment

Angular CLI: 22.2.x
Node: 24.21.0
@angular-devkit/build-angular: 22.2.2
@angular-architects/module-federation: 22.0.0
webpack: 5.111.0
license-webpack-plugin: 4.0.2
OS: Linux

Anything else relevant?

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.

Activity

  1. added this to the needsTriage milestone on Oct 15, 2026
  2. alan-agius4 commented on Oct 15, 2026

    @alan-agius4
    Collaborator

    @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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions