@@ -23,7 +23,7 @@ function findAddon(): any | undefined {
2323 ) as Record < string , string >
2424
2525 // compatible addons (abi -> addon path)
26- const compatibleAddons : Record < string , string > = { }
26+ const compatibleAddons : Map < BuildConfiguration , string > = new Map ( )
2727
2828 const configs = Object . keys ( manifest )
2929 for ( const configStr of configs ) {
@@ -39,20 +39,18 @@ function findAddon(): any | undefined {
3939 }
4040
4141 const addonRelativePath = manifest [ configStr ]
42- compatibleAddons [ config . abi ?? 0 ] = path . resolve (
43- buildDir ,
44- addonRelativePath ,
45- )
42+ compatibleAddons . set ( config , path . resolve ( buildDir , addonRelativePath ) )
4643 }
4744
4845 // sort the compatible abis in descending order
49- const compatibleAbis = Object . keys ( compatibleAddons ) . sort ( ( a , b ) => {
50- return Number . parseInt ( b , 10 ) - Number . parseInt ( a , 10 )
51- } )
46+ const compatibleAddonsSorted = [ ...compatibleAddons . entries ( ) ] . sort (
47+ ( [ c1 , _p1 ] , [ c2 , _p2 ] ) => {
48+ return ( c2 . abi ?? 0 ) - ( c1 . abi ?? 0 )
49+ } ,
50+ )
5251
5352 // try each available addon ABI
54- for ( const abi of compatibleAbis ) {
55- const addonPath = compatibleAddons [ abi ]
53+ for ( const [ _config , addonPath ] of compatibleAddonsSorted ) {
5654 try {
5755 addon = require ( addonPath )
5856 break
0 commit comments