Skip to content
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

New case for "__webpack_modules__[moduleId] is not a function" error with Module Federation #17989

Closed
tqnghia1998 opened this issue Jan 22, 2024 · 1 comment · Fixed by #18069
Labels

Comments

@tqnghia1998
Copy link

Bug report

What is the current behavior?
With a certain dependency graph, webpack module federation applications crash with error:

__webpack_modules__[moduleId] is not a function
or Cannot read properties of undefined (reading 'call')

This is indeed a known bug and had been fixed, but it happens again with module federation #11770
Issue describe:

  • Folder structure:
/src
├── /components
│   ├── Button.js
├── /helpers
│   ├── index.js
├── /utils
│   ├── index.js
├── App.js
  • Dependency graph:

example remote app

  • Bundle result:

chunking result

  • What is the problem:
    ./src/utils/index.jsx module is declared in src_helpers_index_js but required in src_comopnent_Button_js, so in runtime, it cannot find the module

Like I mentioned, this is a known issue and @sokra had fixed it in #11770. But he didn't handle for module federation case, because in this case, two federated modules ./RemoteApp and ./helpers are using the same runtime id

If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/tqnghia1998/webpack-chunking-error-demo (latest webpack version, just yarn install, then yarn start)

What is the expected behavior?
No runtime errors, ./src/utils/index.jsx should be initialized when loading RemoteApp

Other relevant information:
Webpack version: 5.89.0
Node.js version: v18.12.1
Operating System: Mac 14.2.1
Additional tools: -

@alexander-akait
Copy link
Member

PR welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants