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

Commit c1c139b

Browse filesBrowse files
committed
Add a catch to support requiring installed modules
1 parent 3ca4cd5 commit c1c139b
Copy full SHA for c1c139b

File tree

Expand file treeCollapse file tree

2 files changed

+40
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+40
-4
lines changed

‎dist/index.js

Copy file name to clipboardExpand all lines: dist/index.js
+33-3Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ exports.request = request;
24272427
/***/ }),
24282428

24292429
/***/ 272:
2430-
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
2430+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
24312431

24322432
"use strict";
24332433
__webpack_require__.r(__webpack_exports__);
@@ -2455,13 +2455,20 @@ function callAsyncFunction(args, source) {
24552455
var external_path_ = __webpack_require__(622);
24562456

24572457
// CONCATENATED MODULE: ./src/wrap-require.ts
2458+
/* module decorator */ module = __webpack_require__.hmd(module);
24582459

24592460
const wrapRequire = new Proxy(require, {
24602461
apply: (target, thisArg, [moduleID]) => {
24612462
if (moduleID.startsWith('.')) {
24622463
moduleID = Object(external_path_.join)(process.cwd(), moduleID);
2464+
return target.apply(thisArg, [moduleID]);
2465+
}
2466+
try {
2467+
return target.apply(thisArg, [moduleID]);
2468+
}
2469+
catch (err) {
2470+
return target.resolve(moduleID, { paths: [...module.paths, process.cwd()] });
24632471
}
2464-
return target.apply(thisArg, [moduleID]);
24652472
},
24662473
get: (target, prop, receiver) => {
24672474
Reflect.get(target, prop, receiver);
@@ -2494,7 +2501,7 @@ async function main() {
24942501
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
24952502
const result = await callAsyncFunction({
24962503
require: wrapRequire,
2497-
nativeRequire: require,
2504+
__original_require__: require,
24982505
github,
24992506
context: lib_github.context,
25002507
core: core,
@@ -8803,5 +8810,28 @@ function regExpEscape (s) {
88038810
/******/ };
88048811
/******/ }();
88058812
/******/
8813+
/******/ /* webpack/runtime/harmony module decorator */
8814+
/******/ !function() {
8815+
/******/ __webpack_require__.hmd = function(module) {
8816+
/******/ module = Object.create(module);
8817+
/******/ if (!module.children) module.children = [];
8818+
/******/ Object.defineProperty(module, 'loaded', {
8819+
/******/ enumerable: true,
8820+
/******/ get: function () { return module.l; }
8821+
/******/ });
8822+
/******/ Object.defineProperty(module, 'id', {
8823+
/******/ enumerable: true,
8824+
/******/ get: function () { return module.i; }
8825+
/******/ });
8826+
/******/ Object.defineProperty(module, 'exports', {
8827+
/******/ enumerable: true,
8828+
/******/ set: function () {
8829+
/******/ throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
8830+
/******/ }
8831+
/******/ });
8832+
/******/ return module;
8833+
/******/ };
8834+
/******/ }();
8835+
/******/
88068836
/******/ }
88078837
);

‎src/wrap-require.ts

Copy file name to clipboardExpand all lines: src/wrap-require.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ export const wrapRequire = new Proxy(__non_webpack_require__, {
44
apply: (target, thisArg, [moduleID]) => {
55
if (moduleID.startsWith('.')) {
66
moduleID = path.join(process.cwd(), moduleID)
7+
return target.apply(thisArg, [moduleID])
8+
}
9+
10+
try {
11+
return target.apply(thisArg, [moduleID])
12+
} catch (err) {
13+
return target.resolve(moduleID, {paths: [...module.paths, process.cwd()]})
714
}
8-
return target.apply(thisArg, [moduleID])
915
},
1016

1117
get: (target, prop, receiver) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.