From 36a009985386964951eba862c669a5da9c1703c5 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 11 Aug 2022 10:38:02 +0100 Subject: [PATCH 1/4] fix: resolve child, not sibling directory --- src/resolve.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/resolve.ts b/src/resolve.ts index 0cc0cb4..8bd6c93 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -61,12 +61,10 @@ function _resolve (id: string, opts: ResolveOptions = {}): string { 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') + url = new URL(joinURL(url.pathname, '_index.js'), url) } urls.push(new URL('./', url)) - // TODO: Remove in next major version seems not necessary - urls.push(new URL('./node_modules', url)) + urls.push(new URL(joinURL(url.pathname, 'node_modules'), url)) } } From 64e781508a21fb53a201eae726fee4160c92e4e6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 11 Aug 2022 10:43:58 +0100 Subject: [PATCH 2/4] fix: path both urls in --- src/resolve.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/resolve.ts b/src/resolve.ts index 8bd6c93..ee2fc8d 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -57,14 +57,10 @@ 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(joinURL(url.pathname, '_index.js'), url) - } urls.push(new URL('./', url)) - urls.push(new URL(joinURL(url.pathname, 'node_modules'), url)) + urls.push(new URL(joinURL(url.pathname, '_index.js'), url)) } } From 1c264ea454758f8492b7306c907a1236f157311b Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 11 Aug 2022 10:45:01 +0100 Subject: [PATCH 3/4] fix: restore todo --- src/resolve.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/resolve.ts b/src/resolve.ts index ee2fc8d..a931299 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -61,6 +61,8 @@ function _resolve (id: string, opts: ResolveOptions = {}): string { if (url.protocol === 'file:') { urls.push(new URL('./', url)) 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)) } } From 25e618e7926366153189284636957ed3035777ff Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Thu, 11 Aug 2022 11:47:11 +0200 Subject: [PATCH 4/4] Update src/resolve.ts --- src/resolve.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resolve.ts b/src/resolve.ts index a931299..e444d9f 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -60,6 +60,7 @@ function _resolve (id: string, opts: ResolveOptions = {}): string { for (const url of _urls) { if (url.protocol === 'file:') { 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))