| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Hello from actions/github-script! (3110e8d) |
Sorry, something went wrong.
Co-authored-by: Josh Gross <joshmgross@github.com>
| { | ||
| // Webpack does not have an escape hatch for getting the actual | ||
| // module, other than `eval`. | ||
| paths: eval('module').paths.concat(process.cwd()) |
There was a problem hiding this comment.
Question: Have you tried adding node_modules to the path here? I think that should work, while also preventing accidental resolutions to local modules, i.e. require('hi') => require(process.cwd() + '/hi.js')? 🤔
| paths: eval('module').paths.concat(process.cwd()) | |
| paths: eval('module').paths.concat(path.resolve(process.cwd(), 'node_modules')) |
Sorry, something went wrong.
There was a problem hiding this comment.
I may have mis-tested, but when I tested this, using this method did not result in the ability to require('foo') and have it resolve to ./foo.js. Surprisingly, module.paths.push(process.cwd()) did have this effect, but not this method.
Sorry, something went wrong.
| } | ||
|
|
||
| try { | ||
| return target.apply(thisArg, [moduleID]) |
There was a problem hiding this comment.
Concern: I feel like the order here of the try vs. catch block is backwards.
When using a require('lodash') from my github-script block now, that may end up requiring an incompatible version of the module if it exists as a dependency somewhere "near" to where the github-script code is executed rather than relying on the CWD's package.json file. 😬
Sorry, something went wrong.
There was a problem hiding this comment.
Ah this is a good point. Instead, we should perhaps remove this entire try/catch construct and just do this:
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// 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])
Sorry, something went wrong.
There was a problem hiding this comment.
Fixing in #136
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This adds support for the following:
This is accomplished by wrapping the require passed to the script in a proxy.
Thanks to @joshmgross and @wraithgar for doing the real work here 😄