Cannot import @mui/material from an ESM dependency #78116
Labels
Module Resolution
Module resolution (CJS / ESM, module resolving).
Webpack
Related to Webpack with Next.js.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/nextjs-issue-cannot-import-mui-material-from-mjs-dependency-88x7qr
To Reproduce
pnpm install
pnpm run build
in thepackages/example-alert
folderpnpm run dev
)Current vs. Expected behavior
The following error appears: Error: Element type is invalid. Received a promise that resolves to: [object Module]. Lazy element type must resolve to a class or function.
This happens in both the app router and the pages router, if a dependency renders something from
@mui/material
.It does work with Turbopack, but not with Webpack.
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Available memory (MB): 4242 Available CPU cores: 2 Binaries: Node: 20.9.0 npm: 9.8.1 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 15.3.1-canary.7 // Latest available version is detected (15.3.1-canary.7). eslint-config-next: N/A react: 19.1.0 react-dom: 19.1.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution, Webpack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
The package is compiled to this:
The
Alert
import is not resolved to a component somehow while using webpack.The text was updated successfully, but these errors were encountered: