Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Only search cwd on user-script require calls #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Search the cwd first, then existing module paths
  • Loading branch information
jclem committed Apr 21, 2021
commit a49bf6b2cd2d19d7353cf281ec5f195f17a57cd6
24 changes: 10 additions & 14 deletions 24 dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2899,20 +2899,16 @@ const wrapRequire = new Proxy(require, {
moduleID = path__WEBPACK_IMPORTED_MODULE_0__.resolve(moduleID);
return target.apply(thisArg, [moduleID]);
}
try {
return target.apply(thisArg, [moduleID]);
}
catch (err) {
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// Webpack does not have an escape hatch for getting the actual
// module, other than `eval`.
paths: eval('module').paths.concat(process.cwd())
}
]);
return target.apply(thisArg, [modulePath]);
}
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// Search the current working directory first, then the existing paths.
// Webpack does not have an escape hatch for getting the actual
// module, other than `eval`.
paths: [process.cwd(), ...eval('module').paths]
}
]);
return target.apply(thisArg, [modulePath]);
},
get: (target, prop, receiver) => {
Reflect.get(target, prop, receiver);
Expand Down
23 changes: 10 additions & 13 deletions 23 src/wrap-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@ export const wrapRequire = new Proxy(__non_webpack_require__, {
return target.apply(thisArg, [moduleID])
}

try {
return target.apply(thisArg, [moduleID])
} catch (err) {
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// Webpack does not have an escape hatch for getting the actual
// module, other than `eval`.
paths: eval('module').paths.concat(process.cwd())
}
])
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// Search the current working directory first, then the existing paths.
// Webpack does not have an escape hatch for getting the actual
// module, other than `eval`.
paths: [process.cwd(), ...eval('module').paths]
}
])

return target.apply(thisArg, [modulePath])
}
return target.apply(thisArg, [modulePath])
},

get: (target, prop, receiver) => {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.