-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🪲 Bug: Doesn't work with Webpack Module Federation #140
Comments
Hi @tgelu, The reason for two package.json files is that bundlers do get confused in some cases (this post describes issues I encountered). But if I read it correctly, the error is about missing version. Do you think that adding a version to generated package.json files would be enough? Cheers! |
I am not familiar with the issues described in detail in that article. I have not had any major issue with using the
But I may lack some knowledge of edge cases or other things, so I'm not going to comment on that.
From my own tests, seems like it would be enough, yes. PS: it still seems a little bit like those extra package.json files try to "trick" some build systems in some ways, so IMHO it is still not the prudent choice :D. But this is besides the point. |
For now, I patched it in version 3.1.2 by adding version to both But I will look into solving it properly. EDIT: I would be grateful if you can check if this works around the problem. |
Seems to be working now :) - thanks a lot! Feel free to close the issue. |
UPDATE: I did not test properly. The version warning is gone but now I get a new warning:
So I am guessing webpack is still confused about this package's package.json file :( |
Heh, It was too easy to be true. I'll try to publish a beta version today with the solution you proposed initially. Would you be so kind to test it, so I can publish the fix afterwards? |
@tgelu I published a beta version which removes additional package json files: From what I can see, it works with both CJS and ESM modules. Please test it yourself and I'll publish a new version
|
Getting no warnings on the @beta release 👍 |
Thanks for checking. I've just published v3.2.0, I think that is it. |
Thank you! |
The two
package.json
files from the build outputesm/package.json
andcjs/package.json
which each contain one line confuse webpack module federation and consequently do not load properly in a federated micro frontend app.Code example
I cannot show a code example but I can explain how the error manifests itself.
Webpack's Module Federation does many things, but at some point it tries to understand the installed version of each dependency. When it reaches
react-animate-height
it looks for thepackage.json
and reads the version from there. But becausereact-animate-height
has more nestedpackage.json
files (which isn't a standard) it finds the deepest one which only contain thetype
property and isn't a validpackage.json
file. This confuses the build system because it sees a dependency which is installed but with noversion
orname
.The error from webpack looks like this:
Expected behavior
react-animate-height
should work in a federated app. The build output should not contain any otherpackage.json
files than the root one. (as an aside: I am pretty sure theimport
andrequire
entries in the rootpackage.json
are enough for build systems to know where to locate the entry points, this is pretty standard. I know of no reason to add those extrapackage.json
files)Possible Solution
In the root
package.json
:Steps to Reproduce (for bugs)
reeact-animate-height
in both apps, the host and the remote.Screenshots
N/A
Your Environment
N/A
Additional context
We're building a micro frontend application with webpack and can't use this package.
The text was updated successfully, but these errors were encountered: