Open shinobu-uwu opened 2 months ago
It doesn't look like this bug report has enough info for one of us to reproduce it. Please provide a CodeSandbox (https://material-ui.com/r/issue-template-latest), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
I created a repo for a freshly created extension and the issue is happening too, the relevant code is in src/popup.tsx
I've confirmed the behavior using the provided repro with both Material UI v5 and v6. Interestingly, the issue does not happen when using the Box
component (all other components seem to have it). It also doesn't happen when creating a component using styled
from @emotion/styled
or @mui/material
directly:
import isPropValid from '@emotion/is-prop-valid'
import styled from '@emotion/styled'
const H1 = styled('h1', {
shouldForwardProp: prop => isPropValid(prop) && prop !== 'color'
})(props => ({
color: props.color
}))
or
import { styled } from "@mui/material";
const H1 = styled('h1', {
shouldForwardProp: prop => prop !== 'color'
})(props => ({
color: props.color
}))
@Andarist would you have some clue on what could be happening? Could this be a cache issue? The error I'm getting is Uncaught TypeError: defaultShouldForwardProp is not a function
from here:
https://github.com/emotion-js/emotion/blob/main/packages/styled/src/base.js#L79
I didn't get to the bottom of this but it looks like a potential Parcel bug.
rootShouldForwardProp
here is an empty object ({}
). This leads to a crash - this should be a function.rootShouldForwardProp.js
module gets initialized correctly~import
(well, custom require
shim in the transpiled bundle) loads it as {}
It's worth noting that it gets resolved to {}
through this require shim:
function localRequire(x) {
var res = localRequire.resolve(x);
return res === false ? {} : newRequire(res);
}
When '../styles/rootShouldForwardProp.js'
gets requested for the first time by './Button.js'
the localRequire.resolve(x)
successfully resolves to 'iPpMB'
. That's the correct module ID that leads to loading your rootShouldForwardProp
.
But when './rootShouldForwardProp.js'
gets requested by '../styles/styled.js'
then localRequire.resolve(x)
returns false
. As we can see, that makes it return {}
.
That relative path gets looked up in this manifest object:
{
"@mui/system/createStyled": "gneAb",
"./defaultTheme.js": "gUo0Q",
"./identifier.js": "jF6EC",
"./rootShouldForwardProp.js": false,
"./slotShouldForwardProp.js": false,
"@parcel/transformer-js/src/esmodule-helpers.js": "boKlo"
}
We can see here that many of those are resolved by Parcel correctly, including 2 relative paths. For some reason './rootShouldForwardProp.js'
is not (and the problem isn't unique to it as './slotShouldForwardProp.js'
suffers from this too)
@DiegoAndai @Andarist is there a workaround that you've discovered that may help? I tried adding a Box and a styled component in various places, but still get the same error.
@DiegoAndai @Andarist any update?
Getting the same error using latest @plasmo @mui/material @emotion/react @emotion/styled
Got it working by downgrading to the versions used here: https://github.com/PlasmoHQ/examples/blob/5a93025794b6a748df8dccabdb926dfead3f114d/with-mui/package.json
@chirayuk @JaitenThomas @reedjones, sorry for the delay.
I dug a bit more into this, sadly I don't have a workaround yet, but I got this info:
v5.15.14
, with this change: https://github.com/mui/material-ui/pull/41201/files#diff-3d12c34697056e1dcc866171889c0aae4f35324276b847c34d99b469103641dcThis points, as stated above, to an issue with plasmo/parcel, as they should be able to handle this code. Would anyone be willing to open an issue on their side, linking to this one, so we can get someone from their team to help debug it and develop potential solutions?
Removing the lines on point 2 is not an option as it would be a breaking change. Besides, it's valid code so it should be supported. If there are other potential solutions on the Material UI side, I'm willing to work on them, but I'm not familiar with plasmo/parcel bundling to know what those solutions could be.
Steps to reproduce
Steps:
npm create plasmo --with-src
npm install @mui/material @emotion/react @emotion/styled
Button
orTypography
tosrc/popup.tsx
npm run dev
Current behavior
App doesn't render, blank screen is presented
Expected behavior
Components being rendered
Context
Render mui components in my browser extension
Your environment
``` Browser: Google Chrome System: OS: macOS 14.5 Binaries: Node: 22.5.1 - /opt/homebrew/bin/node npm: 10.8.2 - /opt/homebrew/bin/npm pnpm: 9.6.0 - /opt/homebrew/bin/pnpm Browsers: Chrome: 123.0.6312.59 Edge: Not Found Safari: 17.5 npmPackages: @emotion/react: ^11.13.3 => 11.13.3 @emotion/styled: ^11.13.0 => 11.13.0 @mui/core-downloads-tracker: 6.0.0 @mui/icons-material: ^6.0.0 => 6.0.0 @mui/material: ^6.0.0 => 6.0.0 @mui/private-theming: 6.0.0 @mui/styled-engine: 6.0.0 @mui/system: 6.0.0 @mui/types: 7.2.16 @mui/utils: 6.0.0 @types/react: 18.2.48 => 18.2.48 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 typescript: 5.3.3 => 5.3.3 ```npx @mui/envinfo
Search keywords: defaultShouldForwardProp is not a function error