@@ -4389,4 +4389,64 @@ t.test('installLinks behavior with project-internal file dependencies', async t
43894389 t . ok ( nestedDep , 'nested-dep should be found' )
43904390 t . ok ( nestedDep . isLink , 'nested-dep should be a link (project-internal)' )
43914391 } )
4392+
4393+ t . test ( 'installLinks=true with transitive external file dependencies' , async t => {
4394+ // mainpkg installs b (external file dep) with --install-links
4395+ // b depends on a (another external file dep via file:../a)
4396+ // Both should be installed (not linked) and dependencies should resolve correctly
4397+ const testRoot = t . testdir ( {
4398+ a : {
4399+ 'package.json' : JSON . stringify ( {
4400+ name : 'a' ,
4401+ main : 'index.js' ,
4402+ } ) ,
4403+ 'index.js' : 'export const A = "A";' ,
4404+ } ,
4405+ b : {
4406+ 'package.json' : JSON . stringify ( {
4407+ name : 'b' ,
4408+ main : 'index.js' ,
4409+ dependencies : {
4410+ a : 'file:../a' ,
4411+ } ,
4412+ } ) ,
4413+ 'index.js' : 'import {A} from "a";export const fn = () => console.log(A);' ,
4414+ } ,
4415+ mainpkg : {
4416+ 'package.json' : JSON . stringify ( { } ) ,
4417+ } ,
4418+ } )
4419+
4420+ const mainpkgPath = join ( testRoot , 'mainpkg' )
4421+ const bPath = join ( testRoot , 'b' )
4422+ createRegistry ( t , false )
4423+
4424+ const arb = newArb ( mainpkgPath , { installLinks : true } )
4425+
4426+ // Add the external file dependency using the full path
4427+ await arb . buildIdealTree ( { add : [ `file:${ bPath } ` ] } )
4428+
4429+ const tree = arb . idealTree
4430+
4431+ // Both packages should be present in the tree
4432+ const packageB = tree . children . get ( 'b' )
4433+ const packageA = tree . children . get ( 'a' )
4434+
4435+ t . ok ( packageB , 'package b should be found in tree' )
4436+ t . ok ( packageA , 'package a should be found in tree (transitive dependency)' )
4437+
4438+ // Both should be installed (not linked) due to installLinks=true
4439+ t . notOk ( packageB . isLink , 'package b should not be a link (installLinks=true)' )
4440+ t . notOk ( packageA . isLink , 'package a should not be a link (transitive with installLinks=true)' )
4441+
4442+ // Verify that the resolved paths are correct
4443+ t . match ( packageB . resolved , / f i l e : .* [ / \\ ] b $ / , 'package b should have correct resolved path' )
4444+ t . match ( packageA . resolved , / f i l e : .* [ / \\ ] a $ / , 'package a should have correct resolved path' )
4445+
4446+ // Verify the dependency relationship
4447+ const edgeToA = packageB . edgesOut . get ( 'a' )
4448+ t . ok ( edgeToA , 'package b should have an edge to a' )
4449+ t . ok ( edgeToA . valid , 'the edge from b to a should be valid' )
4450+ t . equal ( edgeToA . to , packageA , 'the edge from b should point to package a' )
4451+ } )
43924452} )
0 commit comments