-
Notifications
You must be signed in to change notification settings - Fork 554
Support installed npm modules and relative require #135
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
Changes from 1 commit
ddba1b1
f4e5d39
e853490
75e3a5b
c416f56
83c92d6
3ca4cd5
c1c139b
ade5cea
f57c84a
1f8fc98
d37f92f
7e8659d
7e12bd7
b0e12e7
01f87b6
3ede589
19e7914
4a93ad9
fb7e8f7
5ee517d
256da4e
c758586
b616178
2923e50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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()) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Have you tried adding
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have mis-tested, but when I tested this, using this method did not result in the ability to |
||||||
| } | ||||||
| ]) | ||||||
|
|
||||||
| return target.apply(thisArg, [modulePath]) | ||||||
| } | ||||||
| }, | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concern: I feel like the order here of the
tryvs.catchblock is backwards.When using a
require('lodash')from mygithub-scriptblock now, that may end up requiring an incompatible version of the module if it exists as a dependency somewhere "near" to where thegithub-scriptcode is executed rather than relying on the CWD'spackage.jsonfile. 😬There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is a good point. Instead, we should perhaps remove this entire try/catch construct and just do this:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing in #136
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!