Skip to content

Commit

Permalink
feat: omit resolved from registry dependencies
Browse files Browse the repository at this point in the history
Start npm/rfcs#486. This implements `$disable-write-resolves` without
creating an option. Next I'll figure out how to plumb a npm config
option thru to shrinkwrap.
  • Loading branch information
Caleb ツ Everett committed Nov 16, 2021
1 parent ddeb2d9 commit 3f2c894
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ class Node {
return this === this.root || this === this.root.target
}

get isRegistryDependency () {
if (this.edgesIn.size === 0) return false
for (const edge of this.edgesIn) {
if (!npa(edge.spec).registry) return false
}
return true
}

* ancestry () {
for (let anc = this; anc; anc = anc.resolveParent) {
yield anc
Expand Down
3 changes: 2 additions & 1 deletion lib/shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class Shrinkwrap {
})

const resolved = consistentResolve(node.resolved, node.path, path, true)
if (resolved) {
if (resolved && !node.isRegistryDependency) {
meta.resolved = resolved
}

Expand Down Expand Up @@ -953,6 +953,7 @@ class Shrinkwrap {
// git, file, dir, or remote, then the resolved value is necessary.
if (node.resolved &&
!node.isLink &&
!node.isRegistryDependency &&
rSpec.type !== 'git' &&
rSpec.type !== 'file' &&
rSpec.type !== 'directory' &&
Expand Down

0 comments on commit 3f2c894

Please sign in to comment.