Skip to content

Commit c134edc

Browse files
committed
simplify _VSCODE_NODE_MODULES util
1 parent b8b4142 commit c134edc

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

unit/electron/renderer.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,8 @@ if (util.inspect && util.inspect['defaultOptions']) {
7373
}
7474

7575
// VSCODE_GLOBALS: node_modules
76-
globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), {
77-
get(target, mod) {
78-
if (!target[mod] && typeof mod === 'string') {
79-
target[mod] = (require.__$__nodeRequire ?? require)(mod);
80-
}
81-
return target[mod];
82-
}
83-
});
76+
globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), { get: (_target, mod) => (require.__$__nodeRequire ?? require)(String(mod)) });
77+
8478
// VSCODE_GLOBALS: package/product.json
8579
globalThis._VSCODE_PRODUCT_JSON = (require.__$__nodeRequire ?? require)('../../../product.json');
8680
globalThis._VSCODE_PACKAGE_JSON = (require.__$__nodeRequire ?? require)('../../../package.json');

unit/node/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ if (majorRequiredNodeVersion !== currentMajorNodeVersion) {
5858
function main() {
5959

6060
// VSCODE_GLOBALS: node_modules
61-
globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), {
62-
get(target, mod) {
63-
if (!target[mod] && typeof mod === 'string') {
64-
target[mod] = require(mod);
65-
}
66-
return target[mod];
67-
}
68-
});
61+
globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), { get: (_target, mod) => require(String(mod)) });
6962

7063
// VSCODE_GLOBALS: package/product.json
7164
globalThis._VSCODE_PRODUCT_JSON = require(`${REPO_ROOT}/product.json`);

0 commit comments

Comments
 (0)