Skip to content

Angular 21 SSR AngularNodeAppEngine | Native federation | Plain Starter Project adding mfes #1103

@CaspianVahagn

Description

@CaspianVahagn

With what library do you have an issue?

native-federation

Reproduction of the bug/regression with instructions

To reproduce the bug:
generate a new project using the angular cli with version 21.

Follow the tutorial Angular Architects Tutorial as described here:

https://www.angulararchitects.io/blog/ssr-and-hydration-with-native-federation-for-angular/

Expected behavior

Run simple mfe application in SSR

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

  • Native Federation
  • Angular version 21
  • @softarc/native-federation-node 3.5.5
  • SSR using AngularNodeAppEngine instead of CommonEngine

npm ls:

├── @angular-architects/native-federation@21.2.3
├── @angular-devkit/build-angular@21.2.10
├── @angular/animations@21.2.12
├── @angular/build@21.2.10
├── @angular/cli@21.2.10
├── @angular/common@21.2.12
├── @angular/compiler-cli@21.2.12
├── @angular/compiler@21.2.12
├── @angular/core@21.2.12
├── @angular/forms@21.2.12
├── @angular/platform-browser@21.2.12
├── @angular/platform-server@21.2.12
├── @angular/router@21.2.12
├── @angular/ssr@21.2.10
├── @emnapi/core@1.10.0 extraneous
├── @emnapi/runtime@1.10.0 extraneous
├── @emnapi/wasi-threads@1.2.1 extraneous
├── @napi-rs/wasm-runtime@1.1.4 extraneous
├── @softarc/native-federation-node@3.5.5
├── @tailwindcss/postcss@4.3.0
├── @tybys/wasm-util@0.10.2 extraneous
├── @types/express@5.0.6
├── @types/node@20.19.40
├── cors@2.8.6
├── es-module-shims@1.10.1
├── express@5.2.1
├── jsdom@28.1.0
├── postcss@8.5.14
├── prettier@3.8.3
├── rxjs@7.8.2
├── tailwindcss@4.3.0
├── tslib@2.8.1
├── typescript@5.9.3
└── vitest@4.1.5

Other information

Issues Occuring:

  1. ng add @angular-architects/native-federation --project shell --type dynamic-host --port 4200 will add federation config but will incorrectly assume how the bootstrap-server.ts is structured and is missing a bracket } (minor inconvenience)

  2. the generated `server.ts' assumes the old express setup hence the server will never run properly. Angular defaults to:

console.log('Starting SSR for Shell');

(async () => {

  await initNodeFederation({
    remotesOrManifestUrl: '../browser/federation.manifest.json',
    relBundlePath: '../browser/',
  });

  await import('./bootstrap-server'); // this will never work since run is not properly invoked
  console.log('Node Federation initialized');

})();

it will crash with:

The 'reqHandler' export in 'server.ts' is either undefined or does not provide a recognized request handler. Using the internal SSR middleware instead.
node:internal/fs/promises:640
return new FileHandle(await PromisePrototypeThen(
^

Error: ENOENT: no such file or directory, open '../browser/federation.manifest.json'

it appears as if the Public folder where the federation.manifest.json is located is not properly resolved.

angular.json:

        "esbuild": {
          "builder": "@angular/build:application",
          "options": {
            "outputPath": "dist/shell",
            "index": "projects/shell/src/index.html",
            "browser": "projects/shell/src/main.ts",
            "tsConfig": "projects/shell/tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "projects/shell/public" // this should be resolved, and read from the manifest ? 
              }
            ],

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

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions