mobx-react-lite does not specify `react-dom` nor `react-native` as it's peer dependencies
Intended outcome:
npm install puts react-dom into the right directory so that mobx-react-lite can find it.
Actual outcome:
react-dom might be placed nested into the node_modules of another node_module so that if mobx-react-lite is not right next to react-dom it can not be found.
How to reproduce the issue:
tl;dr
- Clone https://github.com/clentfort/mobx-react-lite-npm-peer-deps/tree/main
- Run
npm exec redocly, seeError: Cannot find module 'react-dom'error.
I ran into this issue when trying to use a package that depends on mobx-react-lite (namely @redocly/cli). They have correctly added react-dom as a dependencies in their package.json. However, with a second dependency in play (cdktf-cli) running npm install will put react-dom into node_modules/@redocly/cli/node_modules/react-dom while mobx-react-lite ends up in node_modules/mobx-react-lite. With this node_modules layout mobx-react-lite can't find react-dom. I think mobx-react-lite needs to add react-dom to it's peerDependencies. It is already present in peerDependenciesMeta and flagged as optional, but that doesn't tell npm that react-dom is an actual peerDependency. It's just meta information about a non-exisiting peerDependency.
Versions
mobx-react-lite: 3.4.3 npm: 10.4.0 node: v20.10.0