@@ -332,6 +332,13 @@ export class Resolver {
332332 }
333333 return initial
334334 }
335+ if ( binding ?. path . isImportNamespaceSpecifier ( ) ) {
336+ const declaration = binding . path . parentPath
337+ if ( declaration . isImportDeclaration ( ) ) {
338+ const target = this . tree . resolve ( file , declaration . node . source . value )
339+ if ( target ) return this . exported ( target , key , depth + 1 )
340+ }
341+ }
335342 if ( binding ?. path . isImportSpecifier ( ) || binding ?. path . isImportDefaultSpecifier ( ) ) {
336343 const declaration = binding . path . parentPath
337344 if ( declaration . isImportDeclaration ( ) ) {
@@ -348,6 +355,31 @@ export class Resolver {
348355 }
349356 }
350357 }
358+ if ( path . isAwaitExpression ( ) ) {
359+ const awaited = child ( path , 'argument' )
360+ if ( awaited . isCallExpression ( ) ) {
361+ const callee = child ( awaited , 'callee' )
362+ if (
363+ callee . isMemberExpression ( ) &&
364+ ! callee . node . computed &&
365+ t . isIdentifier ( callee . node . object , { name : 'Promise' } ) &&
366+ ! callee . scope . getBinding ( 'Promise' ) &&
367+ t . isIdentifier ( callee . node . property , { name : 'all' } )
368+ ) {
369+ const array = children ( awaited , 'arguments' ) [ 0 ]
370+ if ( array ?. isArrayExpression ( ) && ! array . node . elements . some ( t . isSpreadElement ) ) {
371+ const selected = this . selected ( array , key , file , depth + 1 , seen )
372+ if ( selected !== undefined ) return { $await : selected }
373+ }
374+ }
375+ }
376+ }
377+ if ( path . isArrayExpression ( ) && / ^ (?: 0 | [ 1 - 9 ] \d * ) $ / . test ( key ) ) {
378+ const elements = children ( path , 'elements' )
379+ const index = Number ( key )
380+ if ( index < elements . length && ! elements . slice ( 0 , index + 1 ) . some ( ( p ) => p . isSpreadElement ( ) ) )
381+ return this . value ( elements [ index ] , file , depth + 1 )
382+ }
351383 if ( path . isObjectExpression ( ) ) {
352384 for ( const prop of children ( path , 'properties' ) . reverse ( ) ) {
353385 if ( prop . isObjectMethod ( ) && ! prop . node . computed && propertyName ( prop . node . key ) === key )
@@ -357,7 +389,8 @@ export class Resolver {
357389 if ( prop . isSpreadElement ( ) ) {
358390 const selected = this . selected ( child ( prop , 'argument' ) , key , file , depth + 1 , seen )
359391 if ( selected !== undefined ) return selected
360- return undefined // An unknown later spread can override an earlier property.
392+ /** An unknown later spread can override an earlier property. */
393+ return undefined
361394 }
362395 }
363396 }
@@ -465,7 +498,10 @@ export class Resolver {
465498 if ( ! selection ) return undefined
466499 const init = child ( binding , 'init' )
467500 const [ first , ...rest ] = selection . keys
468- let value = typeof first === 'string' ? this . selected ( init , first , file , depth + 1 ) : undefined
501+ let value =
502+ typeof first === 'string' || typeof first === 'number'
503+ ? this . selected ( init , String ( first ) , file , depth + 1 )
504+ : undefined
469505 const keys = value === undefined ? selection . keys : rest
470506 if ( value === undefined ) value = this . value ( init , file , depth + 1 )
471507 for ( const key of keys ) {
@@ -916,8 +952,8 @@ export class Resolver {
916952 if ( t . isMemberExpression ( node ) || t . isOptionalMemberExpression ( node ) ) {
917953 const key = node . computed ? read ( 'property' ) : propertyName ( node . property )
918954 const selected =
919- typeof key === 'string'
920- ? this . selected ( child ( path , 'object' ) , key , file , depth + 1 )
955+ typeof key === 'string' || typeof key === 'number'
956+ ? this . selected ( child ( path , 'object' ) , String ( key ) , file , depth + 1 )
921957 : undefined
922958 if ( selected !== undefined ) return selected
923959 const base = read ( 'object' )
0 commit comments