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.

Async modules not resolved correctly with module federation

See original GitHub issue

Bug report

What is the current behavior? async modules (e.g. using top-level-await) are resolved into promise by Module Federation

If the current behavior is a bug, please provide the steps to reproduce. https://github.com/vincenthend/webpack-module-federation-async-modules Repo above is two webpack apps using module-federation main-app is importing a function from component-app, where there is a top-level-await in the imported module.

The imported module is resolved as Promise instead of object (even if using import syntax) image

What is the expected behavior? Imported modules from module federation should resolve normally whether it’s async modules or not

Other relevant information: webpack version: 5.61.0 Node.js version: 14.8 Operating System: macOS 10.15 Additional tools: -

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sokracommented, Apr 1, 2022

imagen

When working with async modules you need to make sure that your are working only with ESM imports. And also make sure to not accidentically transpile them (via babel) to CommonJs (as shown in the screenhot, (0, _utils).hasRole is how babel transpiles imports)

0reactions
lifeilucommented, Jul 18, 2022

Imported modules from module federation should resolve normally whether it’s async modules or not

Bug report

What is the current behavior? async modules (e.g. using top-level-await) are resolved into promise by Module Federation

If the current behavior is a bug, please provide the steps to reproduce. https://github.com/vincenthend/webpack-module-federation-async-modules Repo above is two webpack apps using module-federation main-app is importing a function from component-app, where there is a top-level-await in the imported module.

The imported module is resolved as Promise instead of object (even if using import syntax) image

What is the expected behavior? Imported modules from module federation should resolve normally whether it’s async modules or not

Other relevant information: webpack version: 5.61.0 Node.js version: 14.8 Operating System: macOS 10.15 Additional tools: -

I have the same problem, it seems to be a bug?

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 >
Tutorial - A Guide to Module Federation for Enterprise
js serves as an asynchronous barrier for our local and remote code. This is a required file in order for Module Federation to...
Read more >
Code Splitting - webpack
Dynamic Imports: Split code via inline function calls within modules. ... when importing a CommonJS module, the import will no longer resolve to...
Read more >
How to Use Module Federation with Re.Pack 3 | blog {callstack}
Module Federation is a Webpack 5 feature that carefully migrated to Re. ... the modules in an async chunk, but provides them synchronously....
Read more >
4 Ways to Use Dynamic Remotes in Module Federation
How to configure URLs for your federated remote modules dynamically.
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