File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,16 @@ class Package {
5050 }
5151
5252 resolveExports ( importPath ) {
53- for ( const exportKey in this . exports ) {
53+ if ( ! this . exports ) return null ;
54+ for ( const [ exportKey , exportValue ] of Object . entries ( this . exports ) ) {
5455 const normalizedExportKey = ospath . join ( this . name , exportKey ) ;
55- if ( ( typeof this . exports [ exportKey ] === "object" ) && ( normalizedExportKey === importPath ) && ( "require" in this . exports [ exportKey ] ) && ( "import" in this . exports [ exportKey ] ) ) {
56+ const isObject = typeof exportValue === "object" ;
57+ const isPathMatch = normalizedExportKey === importPath ;
58+ const hasRequiredKeys = [ "require" , "import" ] . every ( key => Object . keys ( exportValue ) . includes ( key ) ) ;
59+ if ( isObject && isPathMatch && hasRequiredKeys ) {
5660 return {
57- absCjsFile : this . exports [ exportKey ] [ " require" ] ,
58- absEsmFile : this . exports [ exportKey ] [ " import" ]
61+ absCjsFile : exportValue . require ?. default || exportValue . require ,
62+ absEsmFile : exportValue . import ?. default || exportValue . import
5963 }
6064 }
6165 }
You can’t perform that action at this time.
0 commit comments