Skip to content

Native Federation recompiles shell artifacts on remote changes in monorepo (Angular 21.1.0) causing very slow rebuilds #1068

@benzmarkus

Description

@benzmarkus

With what library do you have an issue?

"@angular-architects/native-federation": "patch:@angular-architects/native-federation@npm%3A21.1.0#~/.yarn/patches/@angular-architects-native-federation-npm-21.1.0-8c5fce9727.patch",

A fix was provided but did not solve the full problem.

Reproduction of the bug/regression with instructions

Description

We are using Native Federation (v21.1.0) in a monorepo setup with a shell application and multiple smaller remote applications. We are currently on Angular 21.

During development, when running the shell together with one remote, we observe that any change in a remote triggers recompilation of federation artifacts for the shell as well.

The Angular compilation itself is fast. However, the Native Federation artifact compilation step is extremely slow, and this significantly impacts development speed.

Current Behavior

  1. Start shell and one remote
  2. Change code in the remote
  3. Remote rebuild starts (expected)
  4. Shell federation artifacts are also recompiled (unexpected / expensive)
  5. Artifact compilation takes much longer than the Angular build itself

As a result, incremental rebuild times are very slow.

Impact

  • Very slow incremental rebuilds
  • Poor developer experience in larger monorepos
  • Artifact compilation dominates overall rebuild time

Questions

  • Is this behavior expected with Native Federation in monorepos?
  • Are there recommended settings to prevent shell artifact recompilation on remote changes?
  • Is incremental artifact compilation or caching supported or planned?

Sample federation config

const {
  withNativeFederation,
  shareAll,
} = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({
  name: 'products',

  exposes: {
   ......
  },

  remotes: {},

  shared: {
    ...shareAll({
      singleton: true,
      strictVersion: true,
      requiredVersion: 'auto',
    }),
  },

  skip: [
    'rxjs/ajax',
    'rxjs/fetch',
    'rxjs/testing',
    'rxjs/webSocket',
    // Skip packages with problematic imports
    'tracking',
    /tracking\/.*/,
    '@angular/common/locales/extra',
    /rxjs\/internal\/.*/,
    // CommonJS packages that don't work with ESM
    'gender-detection-from-name',
    'crypto-hash',
    'jsxml',
  ],

  // New feature for more performance and avoiding issues with node libs
  // https://github.com/manfredsteyer/nf-test
  features: {
    ignoreUnusedDeps: true,
  },
});

Expected behavior

  • Changes in a remote should only rebuild:
    • The remote Angular build
    • Remote federation artifacts (if required)
  • The shell should not recompile federation artifacts unless:
    • Shell source code changes
    • Federation configuration changes

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

Environment

  • Angular: 21.x
  • Native Federation: 21.1.0
  • Workspace: Monorepo
  • Architecture:
    • 1 shell application
    • Multiple remote applications
  • Dev workflow:
    • Start shell and one remote
    • Make changes in the remote

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