Closed rlue closed 4 years ago
I can't find any stated rationale for the associated "remove peerDependencies" commits across several related repositories. I think the correct fix is to add peer dependencies to this and related packages, instead of removing them from this package's dependencies.
Now, instead of warnings during resolution, you get errors at build or runtime:
ModuleNotFoundError: Module not found: Error: rc-animate tried to access react-dom, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: react-dom (via "react-dom")
Required by: rc-animate@npm:3.1.1 (via /Users/brandonbloom/Projects/deref/.yarn/cache/rc-animate-npm-3.1.1-ebc3b6785f-bc3baf9704.zip/node_modules/rc-animate/es/AnimateChild.js)
The Problem
rc-animate
depends onrc-util
, which peer-depends onreact
andreact-dom
. The latest version of Yarn (2.0 / berry) does not handle this peer dependency inheritance automatically, instead requiring peer dependencies to be explicitly specified at every level of the dependency tree:As currently configured,
rc-animate
produces the following console warnings when being added to a yarn 2.0 project:This requirement is documented here and explained in detail here.
The Solution
package.json
needs apeerDependencies
property that matches the contents of the one inrc-util
.Note
This same issue applies to all react-component repos that depend on
rc-util
or any other package that peer-depends onreact
andreact-dom
. Presumably, this is every project until thereact-component
umbrella. I'm too lazy to create separate issues on each one; is there a better way to report this issue across the entire project?