rsnext/packages/next/lib/resolve-request.ts
Tim Neutkens b124ed2e14
Added no-shadow rule to eslint (#13645)
Was going through _document and noticed some variable shadowing going on. Added a rule for it to our eslint configuration and went through all warnings with @Timer.
2020-06-01 21:00:22 +00:00

18 lines
700 B
TypeScript

import resolve from 'next/dist/compiled/resolve/index.js'
import path from 'path'
export function resolveRequest(req: string, issuer: string) {
// The `resolve` package is prebuilt through ncc, which prevents
// PnP from being able to inject itself into it. To circumvent
// this, we simply use PnP directly when available.
if (process.versions.pnp) {
const { resolveRequest: pnpResolveRequest } = require(`pnpapi`)
return pnpResolveRequest(req, issuer, { considerBuiltins: false })
} else {
const basedir =
issuer.endsWith(path.posix.sep) || issuer.endsWith(path.win32.sep)
? issuer
: path.dirname(issuer)
return resolve.sync(req, { basedir })
}
}