diff --git a/dist/index.js b/dist/index.js index 3e3b905..159c7c5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2903,9 +2903,13 @@ const wrapRequire = new Proxy(require, { return target.apply(thisArg, [moduleID]); } catch (err) { - return target.resolve(moduleID, { - paths: eval('module').paths.concat(process.cwd()) - }); + const modulePath = target.resolve.apply(thisArg, [ + moduleID, + { + paths: eval('module').paths.concat(process.cwd()) + } + ]); + return target.apply(thisArg, [modulePath]); } }, get: (target, prop, receiver) => { diff --git a/src/wrap-require.ts b/src/wrap-require.ts index 22e4b00..de15f6e 100644 --- a/src/wrap-require.ts +++ b/src/wrap-require.ts @@ -10,9 +10,14 @@ export const wrapRequire = new Proxy(__non_webpack_require__, { try { return target.apply(thisArg, [moduleID]) } catch (err) { - return target.resolve(moduleID, { - paths: eval('module').paths.concat(process.cwd()) - }) + const modulePath = target.resolve.apply(thisArg, [ + moduleID, + { + paths: eval('module').paths.concat(process.cwd()) + } + ]) + + return target.apply(thisArg, [modulePath]) } },