From ad4a942460aa7975cd232fb8f34841524b13d8d8 Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Tue, 14 Dec 2021 16:55:59 +0100 Subject: [PATCH] Fixes #2815: Remove `require` reference in `typescriptServices` --- build/importTypescript.js | 4 ++++ src/typescript/lib/typescriptServices-amd.js | 2 +- src/typescript/lib/typescriptServices.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/importTypescript.js b/build/importTypescript.js index 1f452411..a0c29efe 100644 --- a/build/importTypescript.js +++ b/build/importTypescript.js @@ -69,6 +69,10 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n` /= require\("perf_hooks"\)/m, '/* MONACOCHANGE */= {}/* END MONACOCHANGE */' ); + tsServices = tsServices.replace( + /typeof require === "function"/m, + '/* MONACOCHANGE */false/* END MONACOCHANGE */' + ); // Flag any new require calls (outside comments) so they can be corrected preemptively. // To avoid missing cases (or using an even more complex regex), temporarily remove comments diff --git a/src/typescript/lib/typescriptServices-amd.js b/src/typescript/lib/typescriptServices-amd.js index f10e941d..4a7cd482 100644 --- a/src/typescript/lib/typescriptServices-amd.js +++ b/src/typescript/lib/typescriptServices-amd.js @@ -3495,7 +3495,7 @@ var ts; } } function tryGetNodePerformanceHooks() { - if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && /* MONACOCHANGE */false/* END MONACOCHANGE */) { try { var performance_1; var _a /* MONACOCHANGE */= {}/* END MONACOCHANGE */, nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; diff --git a/src/typescript/lib/typescriptServices.js b/src/typescript/lib/typescriptServices.js index 9470c630..9519033d 100644 --- a/src/typescript/lib/typescriptServices.js +++ b/src/typescript/lib/typescriptServices.js @@ -3495,7 +3495,7 @@ var ts; } } function tryGetNodePerformanceHooks() { - if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && /* MONACOCHANGE */false/* END MONACOCHANGE */) { try { var performance_1; var _a /* MONACOCHANGE */= {}/* END MONACOCHANGE */, nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;