-
Notifications
You must be signed in to change notification settings - Fork 284
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
import causes a require is not defined #2039
Comments
https://codedamn.com/news/javascript/fix-require-is-not-defined This is related to the new changes type: 'module' |
Thank you for the article. I have read it, but I am not using |
You are not, but material is, like @mantine/notifications, because they are using the old system cjs. |
I'm getting the same So, I'm wondering if there's something about the hydrogen/vite setup that's causing this automatic CJS -> ESM conversion to not work for dependencies? And if so, I'm not sure if there's a vite config option that could fix it, or if something might need to change in the hydrogen/oxygen plugins. None of the config changes I've seen suggested (such as those found here) have worked for me, however. |
@mantine/notifications was also using proptypes. |
Try: export default defineConfig({
ssr: {
optimizeDeps: {
include: ['dep-name']
}
}
}) |
The However, MUI elements appear completely unstyled (the classNames are there, but not taking any effect). After trying to render a
|
This resolved the issue for me - thanks! 🙌 |
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2024.4.1
What version of Remix are you using?
No response
Steps to Reproduce
npm create @shopify/hydrogen@latest
npm install @mui/material @emotion/react @emotion/styled
&npm install @fontsource/roboto
import { CssBaseline } from '@mui/material';
npm run dev
Expected Behavior
Should import the CssBseline component.
Actual Behavior
Breaks and shows this error:
During SSR HMR: ReferenceError: require is not defined
The text was updated successfully, but these errors were encountered: