From a15746d09375c8d29a16720a5f0d1355e9abf659 Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Thu, 8 May 2025 13:06:37 -0700 Subject: [PATCH 1/2] Working version --- .../arborist/lib/arborist/isolated-reifier.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/workspaces/arborist/lib/arborist/isolated-reifier.js b/workspaces/arborist/lib/arborist/isolated-reifier.js index a9a31dbf2e00a..d1e3ed23068bf 100644 --- a/workspaces/arborist/lib/arborist/isolated-reifier.js +++ b/workspaces/arborist/lib/arborist/isolated-reifier.js @@ -6,6 +6,7 @@ const pacote = require('pacote') const { join } = require('node:path') const { depth } = require('treeverse') const crypto = require('node:crypto') +const path = require('node:path') // cache complicated function results const memoize = (fn) => { @@ -96,6 +97,7 @@ module.exports = cls => class IsolatedReifier extends cls { result.localPath = node.path result.isWorkspace = true result.resolved = node.resolved + result.isLink = node.isLink || false await this.assignCommonProperties(node, result) } @@ -136,6 +138,7 @@ module.exports = cls => class IsolatedReifier extends cls { result.optional = node.optional result.resolved = node.resolved result.version = node.version + result.isLink = node.isLink || false } async assignCommonProperties (node, result) { @@ -317,11 +320,15 @@ module.exports = cls => class IsolatedReifier extends cls { hasShrinkwrap: false, inDepBundle: false, integrity: null, - isLink: false, + isLink: node.isLink || false, isRoot: false, isInStore: inStore, - path: join(proxiedIdealTree.root.localPath, location), - realpath: join(proxiedIdealTree.root.localPath, location), + path: node.isLink ? + join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : + join(proxiedIdealTree.root.localPath, location), + realpath: node.isLink ? + join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : + join(proxiedIdealTree.root.localPath, location), resolved: node.resolved, version: pkg.version, package: pkg, @@ -367,14 +374,19 @@ module.exports = cls => class IsolatedReifier extends cls { nmFolder = join('node_modules', '.store', key, 'node_modules') } else { from = node.isProjectRoot ? root : root.fsChildren.find(c => c.location === node.localLocation) - nmFolder = join(node.localLocation, 'node_modules') + nmFolder = node.isLink ? + join(proxiedIdealTree.root.localPath, node.localLocation || '', 'node_modules') : + join(node.localLocation, 'node_modules') } const processDeps = (dep, optional, external) => { optional = !!optional external = !!external - const location = join(nmFolder, dep.name) + const location = dep.isLink ? + join(proxiedIdealTree.root.localPath, dep.localLocation || '', 'node_modules', dep.name) : + join(nmFolder, dep.name) + const binNames = dep.package.bin && Object.keys(dep.package.bin) || [] const toKey = getKey(dep) @@ -388,7 +400,10 @@ module.exports = cls => class IsolatedReifier extends cls { // TODO: we should no-op is an edge has already been created with the same fromKey and toKey binNames.forEach(bn => { - target.binPaths.push(join(from.realpath, 'node_modules', '.bin', bn)) + const binPath = dep.isLink ? + join(proxiedIdealTree.root.localPath, from.realpath, 'node_modules', '.bin' , bn) : + join(from.realpath, 'node_modules', 'bin', bn) + target.binpaths.push(binpath) }) const link = { From e426a70e77c364ab935ce9865fc6b0edc32436f3 Mon Sep 17 00:00:00 2001 From: kchindam-infy Date: Wed, 25 Jun 2025 12:03:01 -0700 Subject: [PATCH 2/2] removed unused variables and fixed linting issue --- .../arborist/lib/arborist/isolated-reifier.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/workspaces/arborist/lib/arborist/isolated-reifier.js b/workspaces/arborist/lib/arborist/isolated-reifier.js index d1e3ed23068bf..4bc1998af17d7 100644 --- a/workspaces/arborist/lib/arborist/isolated-reifier.js +++ b/workspaces/arborist/lib/arborist/isolated-reifier.js @@ -6,7 +6,6 @@ const pacote = require('pacote') const { join } = require('node:path') const { depth } = require('treeverse') const crypto = require('node:crypto') -const path = require('node:path') // cache complicated function results const memoize = (fn) => { @@ -82,7 +81,7 @@ module.exports = cls => class IsolatedReifier extends cls { } queue.push(e.to) }) - if (!next.isProjectRoot && !next.isWorkspace && !next.ideallyInert) { + if (!next.isProjectRoot && !next.isWorkspace) { root.external.push(await this.externalProxyMemo(next)) } } @@ -150,8 +149,8 @@ module.exports = cls => class IsolatedReifier extends cls { const nonOptionalDeps = edges.filter(e => !e.optional).map(e => e.to.target) result.localDependencies = await Promise.all(nonOptionalDeps.filter(n => n.isWorkspace).map(this.workspaceProxyMemo)) - result.externalDependencies = await Promise.all(nonOptionalDeps.filter(n => !n.isWorkspace && !n.ideallyInert).map(this.externalProxyMemo)) - result.externalOptionalDependencies = await Promise.all(optionalDeps.filter(n => !n.ideallyInert).map(this.externalProxyMemo)) + result.externalDependencies = await Promise.all(nonOptionalDeps.filter(n => !n.isWorkspace).map(this.externalProxyMemo)) + result.externalOptionalDependencies = await Promise.all(optionalDeps.map(this.externalProxyMemo)) result.dependencies = [ ...result.externalDependencies, ...result.localDependencies, @@ -324,11 +323,11 @@ module.exports = cls => class IsolatedReifier extends cls { isRoot: false, isInStore: inStore, path: node.isLink ? - join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : - join(proxiedIdealTree.root.localPath, location), + join(proxiedIdealTree.root.localPath, node.localPath || '', location) : + join(proxiedIdealTree.root.localPath, location), realpath: node.isLink ? - join(proxiedIdealTree.root.localPath, node.locationPath || '', location) : - join(proxiedIdealTree.root.localPath, location), + join(proxiedIdealTree.root.localPath, node.localPath || '', location) : + join(proxiedIdealTree.root.localPath, location), resolved: node.resolved, version: pkg.version, package: pkg, @@ -375,8 +374,8 @@ module.exports = cls => class IsolatedReifier extends cls { } else { from = node.isProjectRoot ? root : root.fsChildren.find(c => c.location === node.localLocation) nmFolder = node.isLink ? - join(proxiedIdealTree.root.localPath, node.localLocation || '', 'node_modules') : - join(node.localLocation, 'node_modules') + join(proxiedIdealTree.root.localPath, node.localLocation || '', 'node_modules') : + join(node.localLocation, 'node_modules') } const processDeps = (dep, optional, external) => { @@ -386,7 +385,6 @@ module.exports = cls => class IsolatedReifier extends cls { const location = dep.isLink ? join(proxiedIdealTree.root.localPath, dep.localLocation || '', 'node_modules', dep.name) : join(nmFolder, dep.name) - const binNames = dep.package.bin && Object.keys(dep.package.bin) || [] const toKey = getKey(dep) @@ -401,9 +399,9 @@ module.exports = cls => class IsolatedReifier extends cls { binNames.forEach(bn => { const binPath = dep.isLink ? - join(proxiedIdealTree.root.localPath, from.realpath, 'node_modules', '.bin' , bn) : - join(from.realpath, 'node_modules', 'bin', bn) - target.binpaths.push(binpath) + join(proxiedIdealTree.root.localPath, from.realpath, 'node_modules', '.bin', bn) : + join(from.realpath, 'node_modules', '.bin', bn) + target.binPaths.push(binPath) }) const link = {