Skip to content

Commit

Permalink
fix(resolve): ensure absolute id exists and resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 25, 2022
1 parent 43dcaba commit f505b7c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { realpathSync } from 'fs'
import { existsSync, realpathSync } from 'fs'
import { pathToFileURL } from 'url'
import { isAbsolute } from 'pathe'
import { moduleResolve } from 'import-meta-resolve'
Expand Down Expand Up @@ -38,9 +38,11 @@ function _resolve (id: string, opts: ResolveOptions = {}): string {
return 'node:' + id
}

// Skip absolute
if (isAbsolute(id)) {
return id
// Skip resolve for absolute paths
if (isAbsolute(id) && existsSync(id)) {
// Resolve realPath and normalize slash
const realPath = realpathSync(fileURLToPath(id))
return pathToFileURL(realPath).toString()
}

// Condition set
Expand Down

0 comments on commit f505b7c

Please sign in to comment.