Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix package exports array resolution #21

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ function resolvePackageTarget(
continue
}

if (!fileExists(resolveResult)) {
lastException = null
continue
}

return resolveResult
}

Expand Down
14 changes: 14 additions & 0 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,20 @@ test(
process.emitWarning = oldEmitWarning
})

assert.equal(
resolve('package-export-map-array/a', import.meta.url),
new URL('node_modules/package-export-map-array/b.js', import.meta.url)
.href,
'should be able to resolve to the first entry in an export map array'
)

assert.equal(
resolve('package-export-map-array/c', import.meta.url),
new URL('node_modules/package-export-map-array/d.js', import.meta.url)
.href,
'should be able to resolve to the nth entry in an export map array'
)

assert.equal(
resolve(
'#a',
Expand Down
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions test/node_modules/package-export-map-array/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.