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

Commit dca2041

Browse files
authored
Merge pull request #60 from microsoft/allow_additional_req
Adds support for error messages to include a reference to require
2 parents 2d5021b + bb69053 commit dca2041

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/importTypescript.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
5050
// \/[*/] matches the start of a comment (single or multi-line).
5151
// ^\s+\*[^/] matches (presumably) a later line of a multi-line comment.
5252
const tsServicesNoCommentedRequire = tsServices.replace(/(\/[*/]|^\s+\*[^/]).*\brequire\(.*/gm, '');
53-
const linesWithRequire = tsServicesNoCommentedRequire.match(/^.*?\brequire\(.*$/gm);
54-
if (linesWithRequire && linesWithRequire.length) {
53+
const linesWithRequire = tsServicesNoCommentedRequire.match(/^.*?\brequire\(.*$/gm)
54+
55+
// Allow error messages to include references to require() in their strings
56+
const runtimeRequires = linesWithRequire && linesWithRequire.filter(l => !l.includes(": diag("))
57+
58+
if (runtimeRequires && runtimeRequires.length && linesWithRequire) {
5559
console.error('Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n');
5660
console.error(linesWithRequire.join('\n'));
5761
process.exit(1);

0 commit comments

Comments
 (0)