@@ -12,6 +12,7 @@ import {
1212 getLibraryName ,
1313 isNodeApiModule ,
1414 stripExtension ,
15+ findNodeApiModulePathsByDependency ,
1516} from "./path-utils.js" ;
1617import { setupTempDirectory } from "./test-utils.js" ;
1718
@@ -397,6 +398,50 @@ describe("findNodeApiModulePaths", () => {
397398 ) ;
398399} ) ;
399400
401+ describe ( "findNodeApiModulePathsByDependency" , ( ) => {
402+ it . only ( "should find Node-API paths by dependency (excluding certain packages)" , async ( context ) => {
403+ const packagesNames = [ "lib-a" , "lib-b" , "lib-c" ] ;
404+ const tempDir = setupTempDirectory ( context , {
405+ "app/package.json" : JSON . stringify ( {
406+ name : "app" ,
407+ dependencies : Object . fromEntries (
408+ packagesNames . map ( ( packageName ) => [ packageName , "^1.0.0" ] )
409+ ) ,
410+ } ) ,
411+ ...Object . fromEntries (
412+ packagesNames . map ( ( packageName ) => [
413+ `app/node_modules/${ packageName } ` ,
414+ {
415+ "package.json" : JSON . stringify ( {
416+ name : packageName ,
417+ main : "index.js" ,
418+ } ) ,
419+ "index.js" : "" ,
420+ "addon.apple.node/react-native-node-api-module" : "" ,
421+ } ,
422+ ] )
423+ ) ,
424+ } ) ;
425+
426+ const result = await findNodeApiModulePathsByDependency ( {
427+ fromPath : path . join ( tempDir , "app" ) ,
428+ platform : "apple" ,
429+ includeSelf : false ,
430+ excludePackages : [ "lib-a" ] ,
431+ } ) ;
432+ assert . deepEqual ( result , {
433+ "lib-b" : {
434+ path : path . join ( tempDir , "app/node_modules/lib-b" ) ,
435+ modulePaths : [ "addon.apple.node" ] ,
436+ } ,
437+ "lib-c" : {
438+ path : path . join ( tempDir , "app/node_modules/lib-c" ) ,
439+ modulePaths : [ "addon.apple.node" ] ,
440+ } ,
441+ } ) ;
442+ } ) ;
443+ } ) ;
444+
400445describe ( "determineModuleContext" , ( ) => {
401446 it ( "should read package.json only once across multiple module paths for the same package" , ( context ) => {
402447 const tempDir = setupTempDirectory ( context , {
0 commit comments