Skip to content

Commit a153042

Browse files
committed
Fixed lint issues and failing tests
1 parent c9b2a33 commit a153042

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/get-exports.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function resolvePackageImports (specifier, fromUrl) {
5555

5656
// Look for path inside packageJson
5757
let resolvedPath
58-
if (typeof imports == 'object') {
58+
if (Object.prototype.toString.call(imports) === '[object Object]') {
5959
const requireSpecifier = imports.require
6060
const importSpecifier = imports.import
6161
// look for the possibility of require and import which is standard for CJS/ESM
@@ -65,11 +65,11 @@ function resolvePackageImports (specifier, fromUrl) {
6565
} else if (imports.node || imports.default) {
6666
resolvedPath = imports.node || imports.default
6767
}
68-
} else if (typeof imports == 'string') {
68+
} else if (typeof imports === 'string') {
6969
resolvedPath = imports
7070
}
7171

72-
if (existsSync(resolvedPath)) {
72+
if (resolvedPath) {
7373
return resolvedPath
7474
}
7575
}
@@ -105,7 +105,6 @@ async function getCjsExports (url, context, parentLoad, source) {
105105
re = './'
106106
}
107107

108-
let newUrl
109108
// Entries in the import field should always start with #
110109
if (re.startsWith('#')) {
111110
re = resolvePackageImports(re, url)
@@ -115,8 +114,7 @@ async function getCjsExports (url, context, parentLoad, source) {
115114
}
116115
}
117116

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
120118

121119
if (newUrl.endsWith('.node') || newUrl.endsWith('.json')) {
122120
return

0 commit comments

Comments
 (0)