Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: use createRequire() for require.resolve()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 28, 2022
1 parent 4404671 commit 0d90db6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/runtimes/node/bundlers/zisi/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createRequire } from 'module'
import { version as nodeVersion } from 'process'

import findUp from 'find-up'
import pathExists from 'path-exists'
import resolveLib from 'resolve'
import { lt as ltVersion } from 'semver'

const requireLib = createRequire(__filename)

const BACKSLASH_REGEXP = /\\/g

// Find the path to a module's `package.json`
Expand Down Expand Up @@ -74,7 +77,7 @@ const resolvePathPreserveSymlinks = async function (path: string, baseDirs: stri
}

const resolvePathFollowSymlinks = function (path: string, baseDirs: string[]) {
return require.resolve(path, { paths: baseDirs })
return requireLib.resolve(path, { paths: baseDirs })
}

// `require.resolve()` on a module's specific file (like `package.json`)
Expand Down

0 comments on commit 0d90db6

Please sign in to comment.