Module Federation remotes work in nx serve but not in nx storybook #3985
Unanswered
mprendki-relativity
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Description
Module federation remotes are working correctly when running the application with nx serve, but fail to load when running Storybook with nx storybook. The remote components that should be imported dynamically are not being resolved properly in the Storybook environment.
Environment
Framework: React 19.1.1 with TypeScript
Build Tool: Vite 7.1.0
Module Federation: @module-federation/vite ^1.7.1
Storybook: 9.1.1 with @storybook/react-vite ^9.1.1
Nx Workspace: 21.3.11
Node: >=20.0.0
Key Package Versions
Module Federation Configuration
Remote Component Usage
Storybook Configuration`
Expected Behavior
Remote components should load successfully in Storybook environment, same as they do in the main application served with nx serve.
Actual Behavior
Remote components fail to load in Storybook, likely due to module federation configuration not being properly applied or resolved in the Storybook/Vite builder context.
Additional Context
Using Nx monorepo workspace
Storybook is configured to use the same vite.config.ts file
Environment variables (like VITE_CDN_URL) are properly loaded with dotenv
The issue seems to be specific to the Storybook builder not properly handling module federation configuration from Vite config
Questions
...Any guidance on resolving this integration issue would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions