Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e12bd7

Browse files
committed
Call resolve, then require
1 parent 7e8659d commit 7e12bd7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

dist/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,9 +2903,13 @@ const wrapRequire = new Proxy(require, {
29032903
return target.apply(thisArg, [moduleID]);
29042904
}
29052905
catch (err) {
2906-
return target.resolve(moduleID, {
2907-
paths: eval('module').paths.concat(process.cwd())
2908-
});
2906+
const modulePath = target.resolve.apply(thisArg, [
2907+
moduleID,
2908+
{
2909+
paths: eval('module').paths.concat(process.cwd())
2910+
}
2911+
]);
2912+
return target.apply(thisArg, [modulePath]);
29092913
}
29102914
},
29112915
get: (target, prop, receiver) => {

src/wrap-require.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ export const wrapRequire = new Proxy(__non_webpack_require__, {
1010
try {
1111
return target.apply(thisArg, [moduleID])
1212
} catch (err) {
13-
return target.resolve(moduleID, {
14-
paths: eval('module').paths.concat(process.cwd())
15-
})
13+
const modulePath = target.resolve.apply(thisArg, [
14+
moduleID,
15+
{
16+
paths: eval('module').paths.concat(process.cwd())
17+
}
18+
])
19+
20+
return target.apply(thisArg, [modulePath])
1621
}
1722
},
1823

0 commit comments

Comments
 (0)