[lab] Incomplete peerDependencies break usage with yarn pnp
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
Yarn PnP (Plug’n’Play) is more strict when it comes to specifying a library’s peerDependencies correctly.
Currently, @mui/lab is missing the following entries in peerDependencies as they are peerDependencies of @mui/x-date-pickers
:
@emotion/react
@emotion/styled
This causes errors like this one:
ERROR in resolving fallback for shared module @emotion/styled
Module not found: Error: @mui/styled-engine tried to access @emotion/styled (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
Required package: @emotion/styled
Required by: @mui/styled-engine@virtual:7a413bb353e548319c90adb82631b0c089acd1a802fdcf34c7a70f0d92986c9f29874633545bb7dc3d02df8b9ae9870617074e94e1a662f0e58596867aac2836#npm:5.6.1 (via /workspace-root/.yarn/__virtual__/@mui-styled-engine-virtual-d4f5f5ea46/0/cache/@mui-styled-engine-npm-5.6.1-06c551ec66-cd17d05902.zip/node_modules/@mui/styled-engine/)
Ancestor breaking the chain: @mui/lab@virtual:be640854c908ca72c5c45d17e3a5d76a2c579538ed551547b39edc486c90638abf94c25a34fa05a0a9167f796b8fb98e280e0bad9b44c61172fe75f4bcf39869#npm:5.0.0-alpha.80
Expected behavior 🤔
If the mentioned packages were added to peerDependencies, these errors would not occur with yarn pnp.
It would maybe also make sense to add them as optional peer dependencies because mui can also be used with styled-components instead of emotion.
Steps to reproduce 🕹
This bug is connected to https://github.com/mui/mui-x/issues/4761. I created a PR to fix the issue on @mui/x-date-pickers
but after that, this library depending on @mui/x-date-pickers
will have the same problem as it also doesn’t declare these peer deps. So reproduction for this issue would be the same (also after mui-x
is fixed):
- Set up a new react app (i.e. via CRA)
npx create-react-app mui-x-date-pickers
- Make sure you have yarn installed
- run
yarn set version berry
in order to get the latest yarn version with pnp - run
yarn add @mui/lab @mui/material @mui/system
- Implement usage of one of these date pickers:
import {CalendarPicker} from '@mui/lab';
function App() {
const handleDateChange = () => {
};
return (
<CalendarPicker
date={null}
onChange={handleDateChange}
/>
);
}
export default App;
- start the app --> errors appear.
Context 🔦
I’m in an environment where I rely heavily upon yarn functionalities (yarn workspaces, pnp, etc.). This issue is a major blocker for me.
Your environment 🌎
`npx @mui/envinfo`
System:
OS: macOS 12.3.1
Binaries:
Node: 16.11.1 - /opt/javascript/ncanode/16.11.1/node/bin/node
Yarn: 3.2.0 - /opt/javascript/ncayarn/1.22.4/bin/yarn
npm: 8.0.0 - /opt/javascript/ncanode/16.11.1/node/bin/npm
Browsers:
Chrome: 101.0.4951.54
Edge: Not Found
Firefox: 99.0.1
Safari: 15.4
Browser used: Brave [Version 1.37.116 Chromium: 100.0.4896.127 (Official Build)]
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
No, I did try with
-alpha.2
(through resolutions. Didn’t fix the problem.I’m not using
@mui/x-date-pickers
through@mui/lab
, but the fact that it’s contained within@mui/lab
lets yarn pnp fail already because the peerDependencies are not declared.