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

🐛 BUG: not work with @mui/material ( @material-ui v5 ) #3724

Open
1 task done
TongChia opened this issue Sep 17, 2021 · 5 comments
Open
1 task done

🐛 BUG: not work with @mui/material ( @material-ui v5 ) #3724

TongChia opened this issue Sep 17, 2021 · 5 comments

Comments

@TongChia
Copy link

Quick checklist

  • I am using the latest version of Snowpack and all plugins.

What package manager are you using?

yarn

What operating system are you using?

macOS, Linux

Describe the bug

a strange error when snowpack dev whith @mui/material (or @material-ui/core v5)

my app.tsx like:

import { h } from 'preact';
import './App.css';
// import { useState, useEffect } from 'preact/hooks';
// import logo from './logo.svg';
// import { makeStyles } from '@mui/styles';
// import { ThemeProvider } from '@mui/material/styles';
import { Button } from '@mui/material';

function App() {
  return (
    <Button>Hello !</Button>
  )
}

i got error message
The requested module '/_snowpack/pkg/@mui.core.ModalUnstyled.v5.0.0-alpha.47.js' does not provide an export named 'SliderMark'

check this file
node_modules/.cache/snowpack/build/@mui/material@5.0.0/@mui/material.js
MUI components export from '@mui/core/ModalUnstyled' 😱

export {  SliderMark,  SliderMarkLabel,  SliderRail, ................ } from '@mui/core/ModalUnstyled';

is that a esbuild bug ?

i can fix it with

import Button from '@mui/material/Button';

Steps to reproduce

  1. npx create-snowpack-app using template app-template-preact-typescript
  2. yarn add @mui/material @emotion/react @emotion/styled
  3. add @mui component to App.tsx import { Typography } from "@mui/material"
  4. yarn start
  5. error: The requested module '/_snowpack/pkg/@mui.core.ModalUnstyled.v5.0.0-alpha.47.js' does not provide an export named 'SliderMark'

Link to minimal reproducible example (optional)

No response

@GoldenTK
Copy link

I also still have this problem? Why it's not working??

Uncaught SyntaxError: The requested module '/_snowpack/pkg/@mui.core.ModalUnstyled.v5.0.0-alpha.48.js' does not provide an export named 'SliderMark'

@TongChia
Copy link
Author

I also still have this problem? Why it's not working??

Uncaught SyntaxError: The requested module '/_snowpack/pkg/@mui.core.ModalUnstyled.v5.0.0-alpha.48.js' does not provide an export named 'SliderMark'

I think this is caused by "circular references"
i can fix it now ↓
edit node_modules/@mui/material/Modal/Modal.js

// import ModalUnstyled, { modalUnstyledClasses } from '@mui/core/ModalUnstyled';
import { ModalUnstyled, modalUnstyledClasses } from '@mui/core';

and node_modules/@mui/material/Modal/index.js

// export * from '@mui/core/ModalUnstyled';
export { ModalUnstyled, ModalManager, modalUnstyledClasses, getModalUtilityClass } from '@mui/core';

and clean cache

rm -rf node_modules/.cache

@httpete
Copy link

httpete commented Oct 5, 2021

I can confirm @TongChia worked for me on 3.8.8.

@TongChia
Copy link
Author

Simple way to solve the problem :
in my code ↓

// import Modal from '@mui/material/Modal';
import Modal from '@mui/material/Modal/Modal';   // skip index  😄

snowpack version 3.8.8
reference:
https://github.com/TongChia/Caddy-Proxy-Manager/blob/fafdca9a2ece008de4ea01f947867ae34d08ee6b/src/components/MyDialog.tsx#L2

@dieuwedeboer
Copy link

I had a similar issue here with Snowpack 3.8.8 the error I was getting was:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `ForwardRef(Modal)`.

But as it was showing up when importing Select, I just replaced
import Select from '@mui/material/Select' with import Select from '@mui/material/Select/Select'

Not an ideal solution and I noticed a bit of visual degradation using the component that way, but one can always manually tweak a few styles or include missing classes directly.

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

No branches or pull requests

4 participants