webpack
webpack copied to clipboard
Async modules not resolved correctly with module federation
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)
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: -
Yep, sounds like a bug
Im seeing the same behaviour on a Next.js app
@jorgev259 No need to duplicate, on the top we have example of the problem
It seems the top-level-await should be placed in your main-app
instead of component-app
according to the doc.
It seems the top-level-await should be placed in your
main-app
instead ofcomponent-app
according to the doc.
This solution is different from the expected behavior above. Normal import statement should work normally (no await needed) for async modules as stated here.
While for now, if the async module is within module federation, it resolves into a promise
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
bump
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)
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
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 fromcomponent-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)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?
any work arounds here?