| | |
| | | function provideCompilerOptionDiagnosticErrorsToWebpack(getCompilerOptionDiagnostics, compilation, instance, configFilePath) { |
| | | if (getCompilerOptionDiagnostics) { |
| | | const { languageService, loaderOptions, compiler, program } = instance; |
| | | const errors = utils_1.formatErrors(program === undefined |
| | | const errors = (0, utils_1.formatErrors)(program === undefined |
| | | ? languageService.getCompilerOptionsDiagnostics() |
| | | : program.getOptionsDiagnostics(), loaderOptions, instance.colors, compiler, { file: configFilePath || 'tsconfig.json' }, compilation.compiler.context); |
| | | compilation.errors.push(...errors); |
| | |
| | | else if (modifiedFiles !== null && |
| | | modifiedFiles !== undefined && |
| | | modifiedFiles.size) { |
| | | const reverseDependencyGraph = utils_1.populateReverseDependencyGraph(instance); |
| | | const reverseDependencyGraph = (0, utils_1.populateReverseDependencyGraph)(instance); |
| | | // check all modified files, and all dependants |
| | | for (const modifiedFileName of modifiedFiles.keys()) { |
| | | for (const fileName of utils_1.collectAllDependants(reverseDependencyGraph, modifiedFileName).keys()) { |
| | | for (const fileName of (0, utils_1.collectAllDependants)(reverseDependencyGraph, modifiedFileName).keys()) { |
| | | const fileToCheckForErrors = files.get(fileName) || otherFiles.get(fileName); |
| | | addFileToCheckForErrors(fileName, fileToCheckForErrors); |
| | | } |
| | |
| | | } |
| | | return filesToCheckForErrors; |
| | | function addFileToCheckForErrors(filePath, file) { |
| | | if (!utils_1.isReferencedFile(instance, filePath)) { |
| | | if (!(0, utils_1.isReferencedFile)(instance, filePath)) { |
| | | filesToCheckForErrors.set(filePath, file); |
| | | } |
| | | } |
| | |
| | | ? constants.dtsTsTsxJsJsxRegex |
| | | : constants.dtsTsTsxRegex; |
| | | // I’m pretty sure this will never be undefined here |
| | | const program = utils_1.ensureProgram(instance); |
| | | const program = (0, utils_1.ensureProgram)(instance); |
| | | for (const [filePath, { fileName }] of filesToCheckForErrors.entries()) { |
| | | if (fileName.match(filePathRegex) === null) { |
| | | continue; |
| | |
| | | associatedModules.forEach(module => { |
| | | removeModuleTSLoaderError(module, loaderOptions); |
| | | // append errors |
| | | const formattedErrors = utils_1.formatErrors(errors, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); |
| | | const formattedErrors = (0, utils_1.formatErrors)(errors, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); |
| | | formattedErrors.forEach(error => { |
| | | if (module.addError) { |
| | | module.addError(error); |
| | |
| | | } |
| | | else { |
| | | // otherwise it's a more generic error |
| | | const formattedErrors = utils_1.formatErrors(errors, loaderOptions, instance.colors, compiler, { file: fileName }, compilation.compiler.context); |
| | | const formattedErrors = (0, utils_1.formatErrors)(errors, loaderOptions, instance.colors, compiler, { file: fileName }, compilation.compiler.context); |
| | | compilation.errors.push(...formattedErrors); |
| | | } |
| | | } |
| | |
| | | associatedModules.forEach(module => { |
| | | removeModuleTSLoaderError(module, loaderOptions); |
| | | // append errors |
| | | const formattedErrors = utils_1.formatErrors(perFileDiagnostics, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); |
| | | const formattedErrors = (0, utils_1.formatErrors)(perFileDiagnostics, loaderOptions, instance.colors, compiler, { module }, compilation.compiler.context); |
| | | formattedErrors.forEach(error => { |
| | | if (module.addError) { |
| | | module.addError(error); |
| | |
| | | } |
| | | else { |
| | | // otherwise it's a more generic error |
| | | const formattedErrors = utils_1.formatErrors(perFileDiagnostics, loaderOptions, instance.colors, compiler, { file: path.resolve(perFileDiagnostics[0].file.fileName) }, compilation.compiler.context); |
| | | const formattedErrors = (0, utils_1.formatErrors)(perFileDiagnostics, loaderOptions, instance.colors, compiler, { file: path.resolve(perFileDiagnostics[0].file.fileName) }, compilation.compiler.context); |
| | | compilation.errors.push(...formattedErrors); |
| | | } |
| | | } |
| | | // Add global solution errors |
| | | compilation.errors.push(...utils_1.formatErrors(diagnostics.global, instance.loaderOptions, instance.colors, instance.compiler, { file: 'tsconfig.json' }, compilation.compiler.context)); |
| | | compilation.errors.push(...(0, utils_1.formatErrors)(diagnostics.global, instance.loaderOptions, instance.colors, instance.compiler, { file: 'tsconfig.json' }, compilation.compiler.context)); |
| | | } |
| | | /** |
| | | * gather all declaration files from TypeScript and output them to webpack |
| | |
| | | if (fileName.match(constants.tsTsxRegex) === null) { |
| | | continue; |
| | | } |
| | | addDeclarationFilesAsAsset(instances_1.getEmitOutput(instance, fileName), compilation); |
| | | addDeclarationFilesAsAsset((0, instances_1.getEmitOutput)(instance, fileName), compilation); |
| | | } |
| | | } |
| | | function addDeclarationFilesAsAsset(outputFiles, compilation, skipOutputFile) { |
| | |
| | | function provideTsBuildInfoFilesToWebpack(instance, compilation) { |
| | | if (instance.watchHost) { |
| | | // Ensure emit is complete |
| | | instances_1.getEmitFromWatchHost(instance); |
| | | (0, instances_1.getEmitFromWatchHost)(instance); |
| | | if (instance.watchHost.tsbuildinfo) { |
| | | outputFileToAsset(instance.watchHost.tsbuildinfo, compilation); |
| | | } |
| | |
| | | * the loader, we need to detect and remove any pre-existing errors. |
| | | */ |
| | | function removeCompilationTSLoaderErrors(compilation, loaderOptions) { |
| | | compilation.errors = compilation.errors.filter(error => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)); |
| | | compilation.errors = compilation.errors.filter(error => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)); |
| | | } |
| | | function removeModuleTSLoaderError(module, loaderOptions) { |
| | | /** |
| | |
| | | module.clearWarningsAndErrors(); |
| | | Array.from(warnings || []).forEach(warning => module.addWarning(warning)); |
| | | Array.from(errors || []) |
| | | .filter((error) => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)) |
| | | .filter((error) => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)) |
| | | .forEach(error => module.addError(error)); |
| | | } |
| | | else { |
| | | module.errors = module.errors.filter(error => error.loaderSource !== utils_1.tsLoaderSource(loaderOptions)); |
| | | module.errors = module.errors.filter(error => error.loaderSource !== (0, utils_1.tsLoaderSource)(loaderOptions)); |
| | | } |
| | | } |
| | | //# sourceMappingURL=after-compile.js.map |