From bb46e80d44304eb6bff94a9f4ee5516baffb598d Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 13 Sep 2019 13:07:50 -0500 Subject: [PATCH] Fix extensions that try to load from node_modules.asar Should allow manual installation of bracket pair colorizer 2: #544. --- scripts/vscode.patch | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/vscode.patch b/scripts/vscode.patch index ba005d1..51a9c1c 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -1032,15 +1032,30 @@ index 7c3b6ae53e..18dec6effa 100644 get webviewResourceRoot(): string { diff --git a/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts b/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts -index 6d31b177ac..d7c1705c57 100644 +index 6d31b177ac..67c955a59d 100644 --- a/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts +++ b/src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts +@@ -41,12 +41,12 @@ const args = minimist(process.argv.slice(2), { + const Module = require.__$__nodeRequire('module') as any; + const originalLoad = Module._load; + +- Module._load = function (request: string) { ++ Module._load = function (request: string, parent: object, isMain: boolean) { + if (request === 'natives') { + throw new Error('Either the extension or a NPM dependency is using the "natives" node module which is unsupported as it can cause a crash of the extension host. Click [here](https://go.microsoft.com/fwlink/?linkid=871887) to find out more'); + } + +- return originalLoad.apply(this, arguments); ++ return originalLoad.apply(this, [request.replace(/node_modules\.asar(\.unpacked)?/, 'node_modules'), parent, isMain]); + }; + })(); + @@ -128,7 +128,7 @@ function _createExtHostProtocol(): Promise { } else { // Do not wait for web companion to reconnect protocol.onSocketClose(() => { - onTerminate(); -+ process.send!('VSCODE_EXTHOST_DISCONNECTED'); // onTerminate(); ++ process.send!({ type: 'VSCODE_EXTHOST_DISCONNECTED' }); }); } }