Skip to content

Module Federation crashes with production configuration in Angular 21 #20332

@leo2823

Description

@leo2823

Bug Description

Module federation crashes with a run-time error starting from @angular-devkit/build-angular@21.0.4 (which requires webpack@5.104). The error message is one of the following, according to the strategy of dependencies' sharing adopted (shareAll or share, you can find more into the webpack configuration of the reproduction example):

  • TypeError: Class extends value undefined is not a constructor or null
  • TypeError: (0 , c.bootstrapApplication) is not a function

webpack@5.104 introduced some changes into the concatenateModules optimization option that seem to cause this error. I tested the webpack configuration disabling this option and no error was thrown.

Link to Minimal Reproduction and step to reproduce

https://github.com/leo2823/ng-mfe-issue
Steps:

  1. Run npm i
  2. Run ng serve --configuration=production

Expected Behavior

No run-time error thrown among the listed ones.

Actual Behavior

TypeError: (0 , c.bootstrapApplication) is not a function
at 6801 (801.js:1:1166)
at webpack_require (main.js:23:2346)

TypeError: Class extends value undefined is not a constructor or null
at 4360 (37.js:1:22082)
at webpack_require (main.js:23:2346)
at 9898 (37.js:1:51831)
at webpack_require (main.js:23:2346)

Environment

System:
    OS: Windows 11
  Binaries:
    Node: 24.12.0
    npm: 11.6.2
  Packages:
    webpack: 5.104.1

Is this a regression?

Yes (please specify version below)

Last Working Version

5.103

Additional Context

This commit seems to introduce the unexpected run-time errors.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions