Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
install/deps: Stop flattening modules that require peer deps
Browse files Browse the repository at this point in the history
This is necessary because we don't know where their peer dep is installed.
In fact, it might not _be_ installed and that's still a valid tree.  By not
flattening it we can ensure that it's always able to load it regardless of where
it was required.

Fixes: #17639
PR-URL: #17678
Credit: @iarna
Reviewed-By: @zkat
  • Loading branch information
iarna committed Jul 10, 2017
1 parent 1658b79 commit 06c154f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/install/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
}
if (tree.children.some(undeletedModuleMatches)) return null

// Peer deps can't be flattened because we don't know where they'll be installed.
// We can later add optimiations to flatten the dep if that's valid.
if (pkg.peerDependencies && Object.keys(pkg.peerDependencies).length) return null

// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
Expand Down

0 comments on commit 06c154f

Please sign in to comment.