question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App with Module federation doesn't load all scripts

See original GitHub issue

Bug report

What is the current behavior? There are a few apps configured with ModuleFederationPlugin:

  • main (loads one component from i_service and one component from b_service)
  • i_service that exposes one component to main app
  • b_service that exposes one component to main app

When I start main app I see only the first loaded component. i_service and b_service expose components with the same hierarchy and naming (./src/common/components/Router/Router) and I guess this is the issue (name collision)

If the current behavior is a bug, please provide the steps to reproduce.

Repos:

npm install and npm start in every repo will start 3 apps (localhost:8080, localhost:8081, localhost:8082)

  • open localhost:8080
  • click to Billing in navigation, this will load Billing page
  • click to Identity in navigation and page stays the same (should load component from another service)

Also this reproducible when you load Billing and Identity later.

What is the expected behavior?

Main app should load both components and resolve chunk even with the same name

Other relevant information: webpack version: 5.4.0 Node.js version: 14.15.1 Operating System: Windows Additional tools:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sokracommented, Dec 15, 2020

i_service and b_service expose components with the same hierarchy and naming (./src/common/components/Router/Router) and I guess this is the issue (name collision)

you must have different output.uniqueNames in each app. This defaults the to "name" in package.json. Make sure the each repo has a different "name" in the package.json.

0reactions
siarhei-zharnasekcommented, Dec 16, 2020

@sokra applications had the same name (copypasted) and making them unique fixed the issue, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack module federation is not working with eager shared ...
It seems like the main reason of why it failed initially was that remoteEntry.js file was loaded after the code that actually runs...
Read more >
Module Federation - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Module Federation | Re.Pack - Netlify
Module Federation is an architecture, which splits the application into multiple pieces. These pieces are called containers. Similarly to micro-services, ...
Read more >
Tutorial - A Guide to Module Federation for Enterprise
Module Federation allows a JavaScript application to dynamically load code from another application and in the process, share dependencies.
Read more >
Module Federation - SurviveJS
To avoid manual work with the DOM, we can use React to develop the application quickly. Make sure you have both react and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found