@@ -55,7 +55,7 @@ function resolvePackageImports (specifier, fromUrl) {
55
55
56
56
// Look for path inside packageJson
57
57
let resolvedPath
58
- if ( typeof imports == ' object') {
58
+ if ( Object . prototype . toString . call ( imports ) === '[ object Object] ') {
59
59
const requireSpecifier = imports . require
60
60
const importSpecifier = imports . import
61
61
// look for the possibility of require and import which is standard for CJS/ESM
@@ -65,11 +65,11 @@ function resolvePackageImports (specifier, fromUrl) {
65
65
} else if ( imports . node || imports . default ) {
66
66
resolvedPath = imports . node || imports . default
67
67
}
68
- } else if ( typeof imports == 'string' ) {
68
+ } else if ( typeof imports === 'string' ) {
69
69
resolvedPath = imports
70
70
}
71
71
72
- if ( existsSync ( resolvedPath ) ) {
72
+ if ( resolvedPath ) {
73
73
return resolvedPath
74
74
}
75
75
}
@@ -105,7 +105,6 @@ async function getCjsExports (url, context, parentLoad, source) {
105
105
re = './'
106
106
}
107
107
108
- let newUrl
109
108
// Entries in the import field should always start with #
110
109
if ( re . startsWith ( '#' ) ) {
111
110
re = resolvePackageImports ( re , url )
@@ -115,8 +114,7 @@ async function getCjsExports (url, context, parentLoad, source) {
115
114
}
116
115
}
117
116
118
- // Resolve the re-exported module relative to the current module.
119
- newUrl = pathToFileURL ( require . resolve ( re , { paths : [ dirname ( fileURLToPath ( url ) ) ] } ) ) . href
117
+ const newUrl = pathToFileURL ( require . resolve ( re , { paths : [ dirname ( fileURLToPath ( url ) ) ] } ) ) . href
120
118
121
119
if ( newUrl . endsWith ( '.node' ) || newUrl . endsWith ( '.json' ) ) {
122
120
return
0 commit comments