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

Commit

Permalink
Don't automatically install optional peer dependencies
Browse files Browse the repository at this point in the history
Fix: npm/rfcs#224

PR-URL: #138
Credit: @bonkydog
Close: #138
Reviewed-by: @isaacs
  • Loading branch information
bonkydog authored and isaacs committed Sep 18, 2020
1 parent 383ccfc commit e13ba3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 186 deletions.
5 changes: 3 additions & 2 deletions lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,9 @@ This is a one-time fix-up, please be patient...
return true

// If the edge has no destination, that's a problem.
if (!edge.to)
return true
if (!edge.to) {
return edge.type !== 'peerOptional'
}

// If user has explicitly asked to update this package by name, it's a problem.
if (this[_updateNames].includes(edge.name))
Expand Down
189 changes: 5 additions & 184 deletions tap-snapshots/test-arborist-build-ideal-tree.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28328,52 +28328,6 @@ Node {
"name": "@types/color-name",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
},
"@types/prop-types" => Node {
"dev": true,
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "@types/prop-types",
"spec": "*",
"type": "prod",
},
},
"location": "node_modules/@types/prop-types",
"name": "@types/prop-types",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
},
"@types/react" => Node {
"dev": true,
"edgesIn": Set {
Edge {
"from": "node_modules/tap/node_modules/ink",
"name": "@types/react",
"spec": ">=16.8.0",
"type": "peerOptional",
},
},
"edgesOut": Map {
"@types/prop-types" => Edge {
"name": "@types/prop-types",
"spec": "*",
"to": "node_modules/@types/prop-types",
"type": "prod",
},
"csstype" => Edge {
"name": "csstype",
"spec": "^2.2.0",
"to": "node_modules/csstype",
"type": "prod",
},
},
"location": "node_modules/@types/react",
"name": "@types/react",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.19.tgz",
},
"ajv" => Node {
"dev": true,
"edgesIn": Set {
Expand Down Expand Up @@ -29761,22 +29715,6 @@ Node {
"name": "cross-spawn",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
},
"csstype" => Node {
"dev": true,
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "csstype",
"spec": "^2.2.0",
"type": "prod",
},
},
"location": "node_modules/csstype",
"name": "csstype",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.8.tgz",
},
"dashdash" => Node {
"dev": true,
"edgesIn": Set {
Expand Down Expand Up @@ -35253,7 +35191,7 @@ Node {
"@types/react" => Edge {
"name": "@types/react",
"spec": ">=16.8.0",
"to": "node_modules/@types/react",
"to": null,
"type": "peerOptional",
},
"ansi-escapes" => Edge {
Expand Down Expand Up @@ -49434,52 +49372,6 @@ Node {
"name": "@types/color-name",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
},
"@types/prop-types" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "@types/prop-types",
"spec": "*",
"type": "prod",
},
},
"location": "node_modules/@types/prop-types",
"name": "@types/prop-types",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
},
"@types/react" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/ink",
"name": "@types/react",
"spec": ">=16.8.0",
"type": "peerOptional",
},
Edge {
"from": "node_modules/tap",
"name": "@types/react",
"spec": "^16.9.16",
"type": "prod",
},
},
"edgesOut": Map {
"@types/prop-types" => Edge {
"name": "@types/prop-types",
"spec": "*",
"to": "node_modules/@types/prop-types",
"type": "prod",
},
"csstype" => Edge {
"name": "csstype",
"spec": "^2.2.0",
"to": "node_modules/csstype",
"type": "prod",
},
},
"location": "node_modules/@types/react",
"name": "@types/react",
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.19.tgz",
},
"ajv" => Node {
"edgesIn": Set {
Edge {
Expand Down Expand Up @@ -50833,19 +50725,6 @@ Node {
"name": "cross-spawn",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
},
"csstype" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "csstype",
"spec": "^2.2.0",
"type": "prod",
},
},
"location": "node_modules/csstype",
"name": "csstype",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.8.tgz",
},
"dashdash" => Node {
"edgesIn": Set {
Edge {
Expand Down Expand Up @@ -51957,7 +51836,7 @@ Node {
"@types/react" => Edge {
"name": "@types/react",
"spec": ">=16.8.0",
"to": "node_modules/@types/react",
"to": null,
"type": "peerOptional",
},
"ansi-escapes" => Edge {
Expand Down Expand Up @@ -55874,9 +55753,10 @@ Node {
},
"edgesOut": Map {
"@types/react" => Edge {
"error": "MISSING",
"name": "@types/react",
"spec": "^16.9.16",
"to": "node_modules/@types/react",
"to": null,
"type": "prod",
},
"async-hook-domain" => Edge {
Expand Down Expand Up @@ -57927,50 +57807,6 @@ Node {
"name": "@types/color-name",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
},
"@types/prop-types" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "@types/prop-types",
"spec": "*",
"type": "prod",
},
},
"location": "node_modules/@types/prop-types",
"name": "@types/prop-types",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
},
"@types/react" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/ink",
"name": "@types/react",
"spec": ">=16.8.0",
"type": "peerOptional",
},
},
"edgesOut": Map {
"@types/prop-types" => Edge {
"name": "@types/prop-types",
"spec": "*",
"to": "node_modules/@types/prop-types",
"type": "prod",
},
"csstype" => Edge {
"name": "csstype",
"spec": "^2.2.0",
"to": "node_modules/csstype",
"type": "prod",
},
},
"location": "node_modules/@types/react",
"name": "@types/react",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.19.tgz",
},
"ajv" => Node {
"edgesIn": Set {
Edge {
Expand Down Expand Up @@ -59298,21 +59134,6 @@ Node {
"name": "cross-spawn",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
},
"csstype" => Node {
"edgesIn": Set {
Edge {
"from": "node_modules/@types/react",
"name": "csstype",
"spec": "^2.2.0",
"type": "prod",
},
},
"location": "node_modules/csstype",
"name": "csstype",
"optional": true,
"peer": true,
"resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.8.tgz",
},
"dashdash" => Node {
"edgesIn": Set {
Edge {
Expand Down Expand Up @@ -60368,7 +60189,7 @@ Node {
"@types/react" => Edge {
"name": "@types/react",
"spec": ">=16.8.0",
"to": "node_modules/@types/react",
"to": null,
"type": "peerOptional",
},
"ansi-escapes" => Edge {
Expand Down

0 comments on commit e13ba3b

Please sign in to comment.