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.

Module federation should declare the remote entries with its location

See original GitHub issue

Feature request

Let’s start from this example.

The app1 (shell/main/host) depends on app2. This dependency is declared in the webpack.config.js, but the location of app2 is declared in the /public/index.html

What is the expected behavior? I’d like to see them togheter, in the plugin options

    new ModuleFederationPlugin({
      name: "app1",
      library: { type: "var", name: "app1" },
      remotes: {
        app2: {alias: "app2", remoteEntry: "http://localhost:3002/remoteEntry.js"}
      },
      shared: ["react", "react-dom"],
    }),

What is motivation or use case for adding/changing the behavior? Easier to maintain

How should this be implemented in your opinion? It should not change the core behaviour. It’s like a syntax sugar: just copy the remotes.{key}.remoteEntry to the index.html as <script>

Are you willing to work on this yourself? I’d love to. Not sure if I know enough about webpack’s implementation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kenkozhengcommented, May 19, 2020

I partly agree with u. Declare in the index.html is not a good idea. But if declaring in the config file, the url of app2 will just be static. For example, we want to get the url of app2 from an admin backend.
Actually, I want webpack do the favor for me to finish the last step, not fetching remoteEntry.js by my code.

0reactions
whu12yzcommented, Aug 19, 2020

remoteEntry

how? could u please give an example @zhangwilling

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Federation - webpack
This plugin adds specific references to containers as externals and allows to import remote modules from these containers. It also calls the override...
Read more >
Setting up remote components and services with webpack ...
Once basic setup is done, we can extend the remote module to create remote components. Create a component in remote application (src/RemoteApp.tsx). import ......
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. This ...
Read more >
Webpack module federation is not working with eager shared ...
In order to make it work you need to change the way you are loading remote entry. Update your ModuleFederationPlugin config in ...
Read more >
4 Ways to Use Dynamic Remotes in Module Federation
This pattern would also not work if you have multiple deployment stages with different URLs and environments. If we could not test remote...
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