First of all you need to know difference between peerDependencies and dependencies.
peerDependencies:
- peerDependencies are used to specify that your library expects a particular package (like axios, react, react-dom, etc.) to be installed in the consuming application. It means your library is compatible with a range of versions, but you don't want to install them yourself as they might already be present in the application.
dependencies:
- dependencies are packages that your library directly depends on and which must be installed when someone installs your library. This would add them to the bundle, which is not what you want in this case.
NOTE:
- Avoid Adding to dependencies if You Don’t Want to Include Them in the App Bundle: If you add the same packages under dependencies, it would force those packages to be bundled with your library, which defeats the purpose of using peerDependencies. This is not recommended for shared libraries like React or Axios.