Port #7486 to release 1.8#7513
Conversation
# Conflicts: # src/compiler/commandLineParser.ts # src/compiler/diagnosticMessages.json
src/compiler/program.ts
Outdated
| if (rootLevelDirectory[rootLevelDirectory.length - 1] !== directorySeparator) { | ||
| rootLevelDirectory += directorySeparator; | ||
| } | ||
| programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true, rootLevelDirectory)); |
There was a problem hiding this comment.
So you are actually reporting this on the next file after the file that pushed over the size limit. So if the compiler was loading a massive file "./tmp/bundle.js" that was 20MB, followed by "./src/app.js" that was 1MB, you'd report on "./src". You're also reporting before you call host.getSourceFile, so the file/folder reported as being too large may not even exit.
Any reason you are not reporting and setting to -1 after you call host.getSourceFile and add the length to programSizeForNonTsFiles below?
There was a problem hiding this comment.
I agree it makes more sense to report error right after the file exceeding the limit. Updating
|
I made a comment in email about ensuring we don't flood with |
90763f9 to
f13a9c7
Compare
src/compiler/program.ts
Outdated
| else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { | ||
| diagnostic = Diagnostics.File_0_not_found; | ||
| diagnosticArgument = [fileName]; | ||
| if (hasTypeScriptFileExtension(fileName) || options.disableSizeLimit || programSizeForNonTsFiles !== -1) { |
There was a problem hiding this comment.
This magic -1 value is being used in a few places now. Can you make this a const with a meaningful name and use that to make the code more readable (e.g. const sizeLimitExceeded = -1). It would also help readability if this was a simple helper function (e.g. function sizeLimitExceed() { return !options.disableLimit && programSizeForNonTsFiles === sizeLimitExceeded;}) used in these conditions.
src/compiler/program.ts
Outdated
| diagnostic = Diagnostics.File_0_not_found; | ||
| fileName += ".ts"; | ||
| diagnosticArgument = [fileName]; | ||
| if (!exceedProgramSizeLimit()) { |
There was a problem hiding this comment.
i would add it below. somethig like
if (diagnostic && !exceedProgramSizeLimit())|
👍 |
|
👍 Thanks! |
No description provided.