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.

Shared configuration is not supported when dynamic load remote module ??

See original GitHub issue

webpack.config.js

shared: {
          react: {eager: true, singleton: true, requiredVersion: '^16.13.1'},
          'react-dom': {
            eager: true,
            singleton: true,
            requiredVersion: '^16.13.1',
          },
          'react-router-dom': {requiredVersion: '^5.1.2'},
          'mobx-react-lite': {requiredVersion: '^1.5.2'},
          mobx: {requiredVersion: '^5.15.4'},
          axios: {requiredVersion: '^0.19.2'},
 }

when i dynamic loading remote module, it throw error:

image

Then i find the error is the ‘factory’ is not a function, it return a Promise

image

and then i find the step of register shared module, it use ‘webpack_require.e’, not use ‘webpack_require’, it will return a Promise

image

How can I solve this problem ?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Rfank2021commented, Jun 18, 2021

If remote set to eager:true, local should also set to eager:true, also bootstrap is needed to make sure only one react is in the initial chunk. Also don’t forget to use bundle-loader or for most new cases just add "module": "esnext" to tsconfig, otherwise typescript will have problem on dynamic import.

1reaction
Rfank2021commented, Jun 17, 2021

@ScriptedAlchemy I feel most people don’t understand what eager consumption means, maybe it’s better to have a wiki explaining what it really means? If we don’t understand, when we meet the issue, we can only treat it as black box, and try randomly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack module federation is not working with eager shared ...
I used dynamic load technique for my remote library and it seems shared modules are not being fetched again and again now.
Read more >
4 Ways to Use Dynamic Remotes in Module Federation
In a previous post, we discussed configuring a simple React application using Webpack Module Federation in a host-remote configuration.
Read more >
Let's Dynamic Remote modules with Webpack Module ...
Configuring the Host App; Load script from remote module dynamically; Load Component from webpack share scope; Consume remote component from ...
Read more >
Module Federation - webpack
This object is used as a shared scope in the remote container and is filled with the provided modules from a host. It...
Read more >
Getting Out of Version-Mismatch-Hell with Module Federation
Also, these versions might not be compatible with each other. ... when the dynamic micro frontend is loaded, module federation does not find ......
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