GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — Support installed npm modules and relative require by jclem · Pull Request #135 · actions/github-script Conversation
|
|
Hello from actions/github-script! (3110e8d) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| { | ||
| // 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.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The 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 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.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| try { | ||
| return target.apply(thisArg, [moduleID]) |
There was a problem 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 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 an error while loading. Please reload this page.
There was a problem 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:
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixing in #136
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.