Skip to content

Commit 7174af3

Browse files
committed
fix(core): npm-parser should handle symlinked nested deps for workspaces
1 parent 3903817 commit 7174af3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/nx/src/plugins/js/lock-file/npm-parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ function getNodes(
116116

117117
const packageName = path.split('node_modules/').pop();
118118
const version = findV3Version(snapshot, packageName);
119-
createNode(packageName, version, path, nodes, keyMap, snapshot);
119+
// symlinked packages in workspaces do not have versions
120+
if (version) {
121+
createNode(packageName, version, path, nodes, keyMap, snapshot);
122+
}
120123
});
121124
} else {
122125
Object.entries(data.dependencies).forEach(([packageName, snapshot]) => {

packages/nx/src/plugins/package-json/create-nodes.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('nx package.json workspaces plugin', () => {
6060
"packageExports": undefined,
6161
"packageMain": undefined,
6262
"packageName": "root",
63+
"packageVersion": undefined,
6364
},
6465
"targetGroups": {
6566
"NPM Scripts": [
@@ -113,6 +114,7 @@ describe('nx package.json workspaces plugin', () => {
113114
"packageExports": undefined,
114115
"packageMain": undefined,
115116
"packageName": "lib-a",
117+
"packageVersion": undefined,
116118
},
117119
"targetGroups": {
118120
"NPM Scripts": [
@@ -173,6 +175,7 @@ describe('nx package.json workspaces plugin', () => {
173175
"packageExports": undefined,
174176
"packageMain": undefined,
175177
"packageName": "lib-b",
178+
"packageVersion": undefined,
176179
},
177180
"targetGroups": {
178181
"NPM Scripts": [
@@ -282,6 +285,7 @@ describe('nx package.json workspaces plugin', () => {
282285
"packageExports": undefined,
283286
"packageMain": undefined,
284287
"packageName": "vite",
288+
"packageVersion": undefined,
285289
},
286290
"targetGroups": {},
287291
},
@@ -385,6 +389,7 @@ describe('nx package.json workspaces plugin', () => {
385389
"packageExports": undefined,
386390
"packageMain": undefined,
387391
"packageName": "vite",
392+
"packageVersion": undefined,
388393
},
389394
"targetGroups": {},
390395
},
@@ -484,6 +489,7 @@ describe('nx package.json workspaces plugin', () => {
484489
"packageExports": undefined,
485490
"packageMain": undefined,
486491
"packageName": "vite",
492+
"packageVersion": undefined,
487493
},
488494
"targetGroups": {},
489495
},
@@ -567,6 +573,7 @@ describe('nx package.json workspaces plugin', () => {
567573
"packageExports": undefined,
568574
"packageMain": undefined,
569575
"packageName": "root",
576+
"packageVersion": undefined,
570577
},
571578
"targetGroups": {
572579
"NPM Scripts": [
@@ -650,6 +657,7 @@ describe('nx package.json workspaces plugin', () => {
650657
"packageExports": undefined,
651658
"packageMain": undefined,
652659
"packageName": "root",
660+
"packageVersion": undefined,
653661
},
654662
"targetGroups": {
655663
"NPM Scripts": [
@@ -740,6 +748,7 @@ describe('nx package.json workspaces plugin', () => {
740748
"packageExports": undefined,
741749
"packageMain": undefined,
742750
"packageName": "root",
751+
"packageVersion": undefined,
743752
},
744753
"targetGroups": {},
745754
},
@@ -921,6 +930,7 @@ describe('nx package.json workspaces plugin', () => {
921930
},
922931
"packageMain": undefined,
923932
"packageName": "lib-a",
933+
"packageVersion": undefined,
924934
},
925935
"targetGroups": {
926936
"NPM Scripts": [
@@ -971,6 +981,7 @@ describe('nx package.json workspaces plugin', () => {
971981
},
972982
"packageMain": undefined,
973983
"packageName": "lib-b",
984+
"packageVersion": undefined,
974985
},
975986
"targetGroups": {
976987
"NPM Scripts": [

0 commit comments

Comments
 (0)