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

Adds support for the requires in TS 4.1b #69

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/importTypescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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);
}

Expand Down