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

feat: edge.explain - include bundled flag #240

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/edge.js
Expand Up @@ -92,6 +92,7 @@ class Edge {
type: this.type,
name: this.name,
spec: this.spec,
bundled: this.to ? this.to.getBundler() === this.from : false,
...(error ? { error } : {}),
...(from ? { from: from.explain(null, seen) } : {}),
}
Expand Down
18 changes: 18 additions & 0 deletions test/edge.js
Expand Up @@ -45,6 +45,9 @@ const top = {
},
isTop: true,
parent: null,
getBundler () {
return null
},
resolve (n) {
return n === 'a' ? a : n === 'b' ? b : null
},
Expand All @@ -66,6 +69,9 @@ const a = {
},
isTop: false,
parent: top,
getBundler () {
return null
},
resolve (n) {
return n === 'aa' ? aa : this.parent.resolve(n)
},
Expand All @@ -87,6 +93,9 @@ const b = {
},
isTop: false,
parent: top,
getBundler () {
return null
},
resolve (n) {
return n === 'aa' ? aa : this.parent.resolve(n)
},
Expand All @@ -108,6 +117,9 @@ const bb = {
},
isTop: false,
parent: b,
getBundler () {
return null
},
resolve (n) {
return this.parent.resolve(n)
},
Expand All @@ -129,6 +141,9 @@ const aa = {
},
isTop: false,
parent: a,
getBundler () {
return null
},
resolve (n) {
return this.parent.resolve(n)
},
Expand All @@ -150,6 +165,9 @@ const c = {
},
isTop: false,
parent: top,
getBundler () {
return null
},
resolve (n) {
return this.parent.resolve(n)
},
Expand Down
16 changes: 14 additions & 2 deletions test/node.js
Expand Up @@ -1601,7 +1601,7 @@ t.test('explain yourself', t => {
name: 'x',
version: '1.2.3',
location: 'node_modules/x',
dependents: [{ name: 'x', type: 'prod', spec: '1', from: n.explain() }],
dependents: [{ name: 'x', type: 'prod', spec: '1', bundled: false, from: n.explain() }],
})

const virtual = new Node({
Expand Down Expand Up @@ -1634,6 +1634,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'y',
spec: '2',
bundled: false,
from: n.explain(),
},
],
Expand All @@ -1648,6 +1649,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'z',
spec: '3',
bundled: false,
from: y.explain(),
},
],
Expand All @@ -1662,6 +1664,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'a',
spec: '4',
bundled: false,
from: z.explain(),
},
],
Expand Down Expand Up @@ -1704,7 +1707,7 @@ t.test('explain yourself', t => {
name: 'b',
version: '9.9.9',
location: 'node_modules/b',
dependents: [{ type: 'prod', name: 'b', spec: '1.2.3', error: 'INVALID', from: n.explain() }],
dependents: [{ type: 'prod', name: 'b', spec: '1.2.3', error: 'INVALID', bundled: false, from: n.explain() }],
})

// explain with a given edge
Expand All @@ -1731,6 +1734,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'b',
spec: '9',
bundled: false,
from: { location: '/virtual-root' },
},
],
Expand All @@ -1756,6 +1760,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'b',
spec: '1',
bundled: false,
from: {
name: 'a',
version: '1.1.1',
Expand All @@ -1765,6 +1770,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'a',
spec: '1',
bundled: false,
from: {
name: 'b',
version: '1.1.1',
Expand All @@ -1775,6 +1781,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'a',
spec: '1',
bundled: false,
from: {
name: 'c',
version: '1.1.1',
Expand All @@ -1784,6 +1791,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'c',
spec: '1',
bundled: false,
from: {
location: '/cy/cle',
},
Expand Down Expand Up @@ -1832,6 +1840,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'd',
spec: '1',
bundled: false,
from: {
name: 'c',
version: '1.2.3',
Expand All @@ -1846,6 +1855,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'c',
spec: '1',
bundled: false,
from: {
name: 'b',
version: '1.2.3',
Expand All @@ -1855,6 +1865,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'b',
spec: '1',
bundled: false,
from: {
name: 'a',
version: '1.2.3',
Expand All @@ -1864,6 +1875,7 @@ t.test('explain yourself', t => {
type: 'prod',
name: 'a',
spec: '1',
bundled: false,
from: {
location: '/project',
},
Expand Down