Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
54 changes: 22 additions & 32 deletions src/after-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import {
*/
export function makeAfterCompile(
instance: TSInstance,
addAssets: boolean,
provideErrors: boolean,
configFilePath: string | undefined
) {
let getCompilerOptionDiagnostics = true;
Expand All @@ -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);
Expand All @@ -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;
Expand Down
11 changes: 1 addition & 10 deletions src/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down