-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
2.7.0 : MUI named import generate error #8828
Comments
Looks like
Note that this is not a Remix specific issue, and will be an issue for any Vite SSR projects. Closing as this isn't something solvable by Remix. |
Hi @pcattori, I'd love to let you know that In addition, I was able to make it work by BTW, I'm not any familiar with ESM/CJS problem (too hard for me) but trying to get luck on this issue. |
@QzCurious could you try bundling |
For production build, it works. And for your convenience, here is a reproduction code I used for testing it. Curious about the suggestion, why would we only configuring it for production and make it unusable for local dev? |
The conditional Here's how it should be configured: export default defineConfig({
// dev: failed; build: success; remix-serve: failed
// https://github.com/kiliman/remix-vite-mui/blob/aee050114dae1b01d35276a7d7641d5df45fcfba/vite.config.ts#L10
ssr: {
noExternal: process.env.NODE_ENV === "production" ? [/^@mui\//] : [], // or `['@mui/**']`
},
plugins: [
remix(),
tsconfigPaths(),
// dev: success; build: success; remix-serve: failed
process.env.NODE_ENV === "development" &&
cjsInterop({
dependencies: ["@mui/material/*"],
}),
],
}); |
Reproduction
Clone : https://github.com/raskyer/remix-bug
npm run dev
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
System Info
Used Package Manager
npm
Expected Behavior
I want to be able to import :
import Button from '@mui/material/Button
as stated in :https://mui.com/material-ui/getting-started/usage/
without issue.
Actual Behavior
I have the following error :
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
The text was updated successfully, but these errors were encountered: