22 Matching Annotations
  1. Mar 2021
    1. Peer dependency A dependency (listed in the peerDependencies field of the manifest) describes a relationship between two packages. Contrary to regular dependencies, a package A with a peer dependency on B doesn't guarantee that A will be able to access B - it's up to the package that depends on A to manually provide a version of B compatible with request from A. This drawback has a good side too: the package instance of B that A will access is guaranteed to be the exact same one as the one used by the ancestor of A. This matters a lot when B uses instanceof checks or singletons.
  2. Nov 2020
  3. Oct 2020
  4. Sep 2020
    1. But this is only a halfway decent way to clarify that this is an external dependency, because the only way to resolve a peer dependency warning is to install react from npm—there's no way to notify npm that you resolve the dependency to a browser global. So peer dependencies should be avoided in favor of external declarations. Then Rollup will take care of warning about "unresolved dependencies", even if external declarations can't express a particular version range with which your library is compatible like peer dependencies can.

      Interesting. Didn't realize. From my perspective, I usually do install packages via npm, so wouldn't have known about this problem.

      npm and rollup both try to solve this problem but in different ways that apparently conflict? So if a lib author lists peerDependencies then it can cause problems for those getting lib via browser (CDN)? How come so many libs use it then? How come I've never heard of this problem before?

    2. You oftentimes see packages list react as a peer dependency. Since this prevents react from being installed into that package's node_modules, this is another way of preventing Rollup from bundling the module. This is also nice _if_ you want the application to install react from npm, because if an application forgets to install a peer dependency, npm will issue a warning.
    1. peerDependencies are different. They are not automatically installed. When a dependency is listed in a package as a peerDependency, it is not automatically installed. Instead, the code that includes the package must include it as its dependency.
  5. Dec 2019
    1. For React components projects, it's expected that they will not have a direct dependency on React/React DOM/prop-types, but instead have them as peer dependencies.
    1. peerDeps can't be disabled. If someone wants to create a neutrino-preset-preact based on the react preset, they won't be able to get rid of the warnings.
    1. The one thing I did have to change to get them to work, was adding the neutrino peerDependency additionally as a devDependency, since apparently that's the recommended way to ensure it's installed. OAO's behaviour of automatically installing peer dependencies does not occur in {npm, yarn, lerna} by design (see lerna/lerna#691, npm/npm#11213 and https://docs.npmjs.com/files/package.json#peerdependencies).
  6. Nov 2019
    1. Peer Dependencies react-hooks-testing-library does not come bundled with a version of react or react-test-renderer to allow you to install the specific version you want to test against.
    1. This package does not include Mocha - I have set Mocha as peer dependency on purpose, so I don't lock consumer to a specific Mocha version but most importantly, I don't have to update this package when Mocha is updated, and all the new features will be available automatically from your local Mocha package.
  7. Nov 2018
    1. As a package manager, a large part of npm's job when installing your dependencies is managing their versions. But its usual model, with a "dependencies" hash in package.json, clearly falls down for plugins. Most plugins never actually depend on their host package, i.e. grunt plugins never do require("grunt"), so even if plugins did put down their host package as a dependency, the downloaded copy would never be used. So we'd be back to square one, with your application possibly plugging in the plugin to a host package that it's incompatible with.

      in other words, a peer dependency enables a kind of reverse dependency. so a plugin to appA can this way 'require' that appA would be of a specific version, not as its own dependency but rather as a neighbour or parent package.