CR feedback / Change upper limit / Add disableSizeLimit compiler option
This commit is contained in:
parent
b155fa847a
commit
a3aa0002a3
|
@ -332,6 +332,11 @@ namespace ts {
|
|||
name: "noImplicitUseStrict",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
|
||||
},
|
||||
{
|
||||
name: "disableSizeLimit",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Disable_the_upper_limit_for_the_total_file_size_of_a_project
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -2620,7 +2620,10 @@
|
|||
"category": "Message",
|
||||
"code": 6112
|
||||
},
|
||||
|
||||
"Disable the upper limit for the total file size of a project.": {
|
||||
"category": "Message",
|
||||
"code": 6113
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
@ -2825,7 +2828,7 @@
|
|||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
"Too many javascript files in the project. Consider add to the `exclude` list in the config file.": {
|
||||
"Too many JavaScript files in the project. Use an exact 'files' list, or use 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'": {
|
||||
"category": "Error",
|
||||
"code": 17012
|
||||
}
|
||||
|
|
|
@ -742,24 +742,38 @@ namespace ts {
|
|||
(oldOptions.target !== options.target) ||
|
||||
(oldOptions.noLib !== options.noLib) ||
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs)) {
|
||||
(oldOptions.allowJs !== options.allowJs) ||
|
||||
(oldOptions.disableSizeLimit !== options.disableSizeLimit)) {
|
||||
oldProgram = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
let programSize = 0;
|
||||
for (const name of rootNames) {
|
||||
const path = toPath(name, currentDirectory, getCanonicalFileName);
|
||||
if (programSize <= maxProgramSize) {
|
||||
processRootFile(name, /*isDefaultLib*/ false);
|
||||
if (!hasTypeScriptFileExtension(name) && filesByName.get(path)) {
|
||||
programSize += filesByName.get(path).text.length;
|
||||
if (options.disableSizeLimit === true) {
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
}
|
||||
else {
|
||||
let programSize = 0;
|
||||
for (const name of rootNames) {
|
||||
const path = toPath(name, currentDirectory, getCanonicalFileName);
|
||||
if (programSize <= maxProgramSize) {
|
||||
processRootFile(name, /*isDefaultLib*/ false);
|
||||
const file = filesByName.get(path);
|
||||
if (!hasTypeScriptFileExtension(name) && file && file.text) {
|
||||
programSize += file.text.length;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If the program size limit was reached when processing a file, this file is
|
||||
// likely in the problematic folder than contains too many files
|
||||
const commonSourceDirectory = getCommonSourceDirectory();
|
||||
let rootLevelDirectory = path.substring(0, Math.max(commonSourceDirectory.length, path.indexOf(directorySeparator, commonSourceDirectory.length)));
|
||||
if (rootLevelDirectory[rootLevelDirectory.length - 1] !== directorySeparator) {
|
||||
rootLevelDirectory += directorySeparator;
|
||||
}
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_JavaScript_files_in_the_project_Use_an_exact_files_list_or_use_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));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_javascript_files_in_the_project_Consider_add_to_the_exclude_list_in_the_config_file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -501,17 +501,19 @@ namespace ts {
|
|||
const name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
// fs.statSync would throw an exception if the file is a symlink
|
||||
// whose linked file doesn't exist. fs.lstatSync would return a stat
|
||||
// object for the symlink file itself in this case
|
||||
const stat = _fs.lstatSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
// whose linked file doesn't exist.
|
||||
try {
|
||||
const stat = _fs.statSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
for (const current of directories) {
|
||||
|
|
|
@ -2437,6 +2437,7 @@ namespace ts {
|
|||
allowSyntheticDefaultImports?: boolean;
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
disableSizeLimit?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
|
|
|
@ -2871,5 +2871,5 @@ namespace ts {
|
|||
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
|
||||
}
|
||||
|
||||
export const maxProgramSize = 35 * 1024 * 1024;
|
||||
export const maxProgramSize = 20 * 1024 * 1024;
|
||||
}
|
||||
|
|
|
@ -1222,9 +1222,14 @@ namespace ts.server {
|
|||
// As the project openning might not be complete if there are too many files,
|
||||
// therefore to surface the diagnostics we need to make sure the given client file is opened.
|
||||
if (clientFileName) {
|
||||
const currentClientFileInfo = this.openFile(clientFileName, /*openedByClient*/ true);
|
||||
project.addRoot(currentClientFileInfo);
|
||||
programSize += currentClientFileInfo.content.length;
|
||||
if (this.host.fileExists(clientFileName)) {
|
||||
const currentClientFileInfo = this.openFile(clientFileName, /*openedByClient*/ true);
|
||||
project.addRoot(currentClientFileInfo);
|
||||
programSize += currentClientFileInfo.content.length;
|
||||
}
|
||||
else {
|
||||
return { errorMsg: "specified file " + clientFileName + " not found" };
|
||||
}
|
||||
}
|
||||
|
||||
for (const rootFilename of projectOptions.files) {
|
||||
|
@ -1232,8 +1237,12 @@ namespace ts.server {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (programSize <= maxProgramSize) {
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
if (projectOptions.compilerOptions.disableSizeLimit === true) {
|
||||
const info = this.openFile(rootFilename, /*openedByClient*/ false);
|
||||
project.addRoot(info);
|
||||
}
|
||||
else if (programSize <= maxProgramSize) {
|
||||
const info = this.openFile(rootFilename, /*openedByClient*/ false);
|
||||
project.addRoot(info);
|
||||
if (!hasTypeScriptFileExtension(rootFilename)) {
|
||||
|
@ -1241,11 +1250,11 @@ namespace ts.server {
|
|||
}
|
||||
}
|
||||
else {
|
||||
return { errorMsg: "specified file " + rootFilename + " not found" };
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
return { errorMsg: "specified file " + rootFilename + " not found" };
|
||||
}
|
||||
}
|
||||
project.finishGraph();
|
||||
|
|
Loading…
Reference in a new issue