Skip to content

Production build not working in Angular 21 #1074

@wszydlak

Description

@wszydlak

With what library do you have an issue?

module-federation

Reproduction of the bug/regression with instructions

Steps to reproduce:

npx create-nx-workspace // use angular template
npx nx g @nx/angular:application apps/test
npm install --save-dev @angular-architects/module-federation
npx nx g @angular-architects/module-federation:init --type host
npx nx serve test --configuration production

When running application i get errors like:

Image

Details

In dev build everything works fine.

I got also another errors, but meaning same - some imported modules property/function was undefined.

How to fix?

I fixed this by removing commonChunk: false option from project.json

I'm not sure if this is correct way as module-federation:init generator explicitly sets commonChunk: false.
According to angular docs: https://angular.dev/tools/cli/build-system-migration commonChunk should be removed, as this was a performance optimization which is no longer needed.

However this seems like it applies to esbuild related builders, not the webpack ones.

Also - creating application which does not use module-federation and setting there "commonChunk: false" makes angular app still working, so the issue is related not to angular itself, but module-federation package.

Expected behavior

I expect module-federation to properly work in angular 21 webpack based builds

Versions of Native/Module Federation, Angular, Node, Browser, and operating system

Module Federation: 20.0.0
Angular: 21.1.1
Nx: 22.5.1

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions