Skip to content

Commit

Permalink
fix(resolve): always try to resolve url as dir too (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 11, 2022
1 parent 4752796 commit dd14c01
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/resolve.ts
Expand Up @@ -57,14 +57,11 @@ function _resolve (id: string, opts: ResolveOptions = {}): string {
_urls.push(DEFAULT_URL)
}
const urls = [..._urls]
for (let url of _urls) {
for (const url of _urls) {
if (url.protocol === 'file:') {
if (!url.pathname.match(/[^/]+\.[^/.]+$/)) {
// URL does not ends with extension. It is probably a directory.
url = new URL(url)
url.pathname = joinURL(url.pathname, '_index.js')
}
urls.push(new URL('./', url))
// If url is directory
urls.push(new URL(joinURL(url.pathname, '_index.js'), url))
// TODO: Remove in next major version seems not necessary
urls.push(new URL('./node_modules', url))
}
Expand Down

0 comments on commit dd14c01

Please sign in to comment.