-
Hi, I'm having an exact same problem as described here: https://stackoverflow.com/questions/65467233/wp5-module-federation-singleton-instantiated-multiple-times?rq=2 Essentially no matter how I am trying to declare a node module (which I developed) as a shared library, it's pretty obvious that it is bundled by the remote, and if I debug it, a singleton class in the library gets loaded and the singleton instance instantiated by both the code bundled by the host app and the code bundled by the remote app. Any ideas are welcome, been looking for days into this, nothing seems to work. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Finally I got a break through. I went through my problem with a colleague who spotted that webpack doesn't emit any message for my library ('consume shared module / provide shared module') whereas such a message was there for react and other libraries. The library project didn't properly support ESM which caused webpack to exclude it (without an explicit error message which isn't ideal). Fixing the library to be CJS+ESM fixed the problem, only a single instance is loaded, Singletons finally work - happy days :) |
Beta Was this translation helpful? Give feedback.
Finally I got a break through. I went through my problem with a colleague who spotted that webpack doesn't emit any message for my library ('consume shared module / provide shared module') whereas such a message was there for react and other libraries. The library project didn't properly support ESM which caused webpack to exclude it (without an explicit error message which isn't ideal). Fixing the library to be CJS+ESM fixed the problem, only a single instance is loaded, Singletons finally work - happy days :)