Skip to content

Module Federation SSR error: "Shared module is not available for eager consumption" #14428

Closed

Description

Current Behavior

Following https://blog.nrwl.io/setting-up-module-federation-with-server-side-rendering-for-angular-66bae10ead2d from @Colum
In a host/remotes scenario (dashboard/login),
When serving the host with SSR
npx nx serve-ssr dashboard
got the error:
if(typeof factory !== "function") throw new Error("Shared module is not available for eager consumption: " + id);
thown at dist/apps/login/server/main.js
Also got the same when running: npx nx serve-ssr login and when running npx nx serve login
But, works well when running npx nx serve dashboard

Expected Behavior

Be able to run a host/remotes module federation with SSR

Github Repo

No response

Steps to Reproduce

  1. npx create-nx-workspace@latest myorg
  2. npm install @nrwl/angular
  3. npx nx g host dashboard --remotes=login --ssr
  4. npx nx serve-ssr dashboard

Nx Report

Node : 18.12.1
   OS   : win32 x64
   npm  : 8.6.0

   nx : 15.5.1
   @nrwl/angular : 15.5.1
   @nrwl/cypress : 15.5.1
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.5.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.5.1
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.5.1
   @nrwl/js : 15.5.1
   @nrwl/linter : 15.5.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : 15.5.1
   @nrwl/workspace : 15.5.1
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @nguniversal/express-engine: 15.0.0
         @nguniversal/builders: 15.0.0

Failure Logs

No response

Additional Information

Module federation works as expected with non-SSR apps.
This problem only arises with SSR.
So, it is more related to SSR than to Module Federation.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions