From 417b141df90d3c5f9e68766416e5e5b539d2bc37 Mon Sep 17 00:00:00 2001 From: Orta Date: Fri, 11 Sep 2020 11:07:41 -0400 Subject: [PATCH] Update import TS --- scripts/importTypescript.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/importTypescript.js b/scripts/importTypescript.js index a36c217..707ea27 100644 --- a/scripts/importTypescript.js +++ b/scripts/importTypescript.js @@ -59,6 +59,11 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n` '$1// MONACOCHANGE\n$1var result = undefined;\n$1// END MONACOCHANGE' ); + tsServices = tsServices.replace( + /^( +)fs = require\("fs"\);$/m, + '$1// MONACOCHANGE\n$1fs = undefined;\n$1// 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 // about require() and then check for lines actually calling require(). @@ -74,13 +79,13 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n` // Allow error messages to include references to require() in their strings const runtimeRequires = - linesWithRequire && linesWithRequire.filter((l) => !l.includes(': diag(')); + linesWithRequire && linesWithRequire.filter((l) => !l.includes(': diag(') && !l.includes("ts.DiagnosticCategory")); if (runtimeRequires && runtimeRequires.length && linesWithRequire) { console.error( 'Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n' ); - console.error(linesWithRequire.join('\n')); + console.error(runtimeRequires.map(r => `${r} (${tsServicesNoCommentedRequire.indexOf(r)})`).join('\n')); process.exit(1); }