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(resolve): always try to resolve url as dir too #67

Merged
merged 4 commits into from Aug 11, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/resolve.ts
Expand Up @@ -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(url)
url.pathname = joinURL(url.pathname, '_index.js')
}
urls.push(new URL('./', url))
urls.push(new URL(joinURL(url.pathname, '_index.js'), url))
pi0 marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Remove in next major version seems not necessary
urls.push(new URL('./node_modules', url))
}
Expand Down