Uncaught TypeError: Cannot read properties of undefined (reading 'call')
See original GitHub issueBug report
What is the current behavior? Can’t have same package.json name on host and remote. Getting error at some point using module federation, guessing when splitChunks kicks in.
If the current behavior is a bug, please provide the steps to reproduce. Set host’s and remote’s name in package.json to same value. Try to load a remote page large enough to trigger splitting chunks (again guessing).
What is the expected behavior? Should not result in error, or, provides a better error message
Other relevant information:
-
Similar experience as @ydmitry in issue 12964 where there is a point that adding a single line of code to a React component’s render method results in the error, and removing the line clears the error. Line was a simple MUI <Typography> which already appears multiple times in the component.
-
Same as @ydmitry setting splitChunks = false on remote resolved the error
-
Ran across another report of the error https://discourse.aurelia.io/t/aurelia-1-and-webpack-module-federation-plugin-different-package-json-names/4398 which suggested the error occurred when the package.json names were different and setting them to the same name resolved the error.
-
On checking my package names, found they were the same. Removed splitChunks = false, verified error was present again, changed package names to be different, and error was gone.
I’m fine for now. Hope this helps someone else struggling with this error.
webpack version:
Node.js version:
Operating System:
Additional tools:
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:24 (4 by maintainers)
Top GitHub Comments
Just to give some context – I’m currently developing a proof of concept related to microfrontends utilising webpack module federation. I’m also using NX (https://nx.dev/) to handle the different microfrontends. NX has this notion of only having a single
package.json
(root) instead of having apackage.json
per individual microfrontend/app.Solution
Now, webpack assumes that you have defined a “unique”
name
inside yourpackage.json
file per microfrontend in order for it to work. Since I’m using NX, the solution I encountered is to modify theuniqueName
attribute in webpack config so it doesn’t rely on thename
attribute frompackage.json
.Source: https://webpack.js.org/configuration/
After I’ve added
uniqueName
per webpack config (one for each microfrontend/app) then it worked as expected and this error went away.I’m also getting the same issue. It seems that the host/container is getting confused between
installedModules
and__webpack_modules__
webpack_modules
webpack/container/reference/marketing
installedModules
webpack/container/remote/marketing/MarketingApp
So now when the code reaches
__webpack_modules__[moduleId]
it returns undefined becausemoduleId
iswebpack/container/remote/marketing/MarketingApp
coming frominstalledModules
My host configuration looks
My App.tsx looks:
Which returns an error