Skip to content
This repository was archived by the owner on Nov 5, 2021. It is now read-only.

Commit 5389ec0

Browse files
authored
Merge pull request #69 from microsoft/ts_4_1_b
Adds support for the requires in TS 4.1b
2 parents f92998e + 417b141 commit 5389ec0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/importTypescript.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
5959
'$1// MONACOCHANGE\n$1var result = undefined;\n$1// END MONACOCHANGE'
6060
);
6161

62+
tsServices = tsServices.replace(
63+
/^( +)fs = require\("fs"\);$/m,
64+
'$1// MONACOCHANGE\n$1fs = undefined;\n$1// END MONACOCHANGE'
65+
);
66+
6267
// Flag any new require calls (outside comments) so they can be corrected preemptively.
6368
// To avoid missing cases (or using an even more complex regex), temporarily remove comments
6469
// about require() and then check for lines actually calling require().
@@ -74,13 +79,13 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
7479

7580
// Allow error messages to include references to require() in their strings
7681
const runtimeRequires =
77-
linesWithRequire && linesWithRequire.filter((l) => !l.includes(': diag('));
82+
linesWithRequire && linesWithRequire.filter((l) => !l.includes(': diag(') && !l.includes("ts.DiagnosticCategory"));
7883

7984
if (runtimeRequires && runtimeRequires.length && linesWithRequire) {
8085
console.error(
8186
'Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n'
8287
);
83-
console.error(linesWithRequire.join('\n'));
88+
console.error(runtimeRequires.map(r => `${r} (${tsServicesNoCommentedRequire.indexOf(r)})`).join('\n'));
8489
process.exit(1);
8590
}
8691

0 commit comments

Comments
 (0)