diff --git a/package.json b/package.json index 765c77a..fecbb81 100644 --- a/package.json +++ b/package.json @@ -25,12 +25,13 @@ "devDependencies": { "@nuxtjs/eslint-config-typescript": "latest", "@types/node": "latest", - "import-meta-resolve": "^1.1.1", "chai": "^4.3.4", "eslint": "latest", + "import-meta-resolve": "^1.1.1", "jiti": "^1.12.5", "mocha": "^9.1.2", "standard-version": "latest", - "unbuild": "^0.5.7" + "unbuild": "^0.5.7", + "pathe": "^0.2.0" } } diff --git a/src/resolve.ts b/src/resolve.ts index ae832e3..cafbb3b 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -1,5 +1,6 @@ import { realpathSync } from 'fs' import { pathToFileURL } from 'url' +import { isAbsolute } from 'pathe' import { moduleResolve } from 'import-meta-resolve' import { fileURLToPath, normalizeid } from './utils' import { pcall, BUILTIN_MODULES } from './_utils' @@ -37,6 +38,11 @@ function _resolve (id: string, opts: ResolveOptions = {}): string { return 'node:' + id } + // Skip absolute + if (isAbsolute(id)) { + return id + } + // Condition set const conditionsSet = opts.conditions ? new Set(opts.conditions) : DEFAULT_CONDITIONS_SET