diff --git a/CHANGELOG.md b/CHANGELOG.md index af8bb0446..fe811fa87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v8.0.16 +* [Re-Fixed missing errors in watch mode in webpack5](https://github.com/TypeStrong/ts-loader/issues/1204) - thanks @appzuka + ## v8.0.15 * [Update definition files in watch mode in webpack@5](https://github.com/TypeStrong/ts-loader/pull/1249) - thanks @appzuka,@JonWallsten,@alexander-akait * [Add afterDeclarations to getCustomTransformers in README.md](https://github.com/TypeStrong/ts-loader/pull/1248) - thanks @appzuka diff --git a/package.json b/package.json index 90b5ff1f3..2b31163b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.15", + "version": "8.0.16", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/after-compile.ts b/src/after-compile.ts index 7cc284a08..03fa8543a 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -29,8 +29,6 @@ import { */ export function makeAfterCompile( instance: TSInstance, - addAssets: boolean, - provideErrors: boolean, configFilePath: string | undefined ) { let getCompilerOptionDiagnostics = true; @@ -47,22 +45,18 @@ export function makeAfterCompile( } if (instance.loaderOptions.transpileOnly) { - if (addAssets) { - provideAssetsFromSolutionBuilderHost(instance, compilation); - } + provideAssetsFromSolutionBuilderHost(instance, compilation); callback(); return; } removeCompilationTSLoaderErrors(compilation, instance.loaderOptions); - if (provideErrors) { - provideCompilerOptionDiagnosticErrorsToWebpack( - getCompilerOptionDiagnostics, - compilation, - instance, - configFilePath - ); - } + provideCompilerOptionDiagnosticErrorsToWebpack( + getCompilerOptionDiagnostics, + compilation, + instance, + configFilePath + ); getCompilerOptionDiagnostics = false; const modules = determineModules(compilation, instance); @@ -74,25 +68,21 @@ export function makeAfterCompile( checkAllFilesForErrors = false; const filesWithErrors: TSFiles = new Map(); - if (provideErrors) { - provideErrorsToWebpack( - filesToCheckForErrors, - filesWithErrors, - compilation, - modules, - instance - ); - provideSolutionErrorsToWebpack(compilation, modules, instance); - } - if (addAssets) { - provideDeclarationFilesToWebpack( - filesToCheckForErrors, - instance, - compilation - ); - provideTsBuildInfoFilesToWebpack(instance, compilation); - provideAssetsFromSolutionBuilderHost(instance, compilation); - } + provideErrorsToWebpack( + filesToCheckForErrors, + filesWithErrors, + compilation, + modules, + instance + ); + provideSolutionErrorsToWebpack(compilation, modules, instance); + provideDeclarationFilesToWebpack( + filesToCheckForErrors, + instance, + compilation + ); + provideTsBuildInfoFilesToWebpack(instance, compilation); + provideAssetsFromSolutionBuilderHost(instance, compilation); instance.filesWithErrors = filesWithErrors; instance.modifiedFiles = undefined; diff --git a/src/instances.ts b/src/instances.ts index ad5ddf0a9..3d7c299c5 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -323,26 +323,17 @@ const addAssetHooks = !!webpack.version!.match(/^4.*/) // add makeAfterCompile with addAssets = true to emit assets and report errors loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', - makeAfterCompile(instance, true, true, instance.configFilePath) + makeAfterCompile(instance, instance.configFilePath) ); } : (loader: webpack.loader.LoaderContext, instance: TSInstance) => { // We must be running under webpack 5+ - // Add makeAfterCompile with addAssets = false to suppress emitting assets - // during the afterCompile stage. Errors will be still be reported to webpack - loader._compiler.hooks.afterCompile.tapAsync( - 'ts-loader', - makeAfterCompile(instance, false, true, instance.configFilePath) - ); - // makeAfterCompile is a closure. It returns a function which closes over the variable checkAllFilesForErrors // We need to get the function once and then reuse it, otherwise it will be recreated each time // and all files will always be checked. const cachedMakeAfterCompile = makeAfterCompile( instance, - true, - false, instance.configFilePath );