diff --git a/src/instances.ts b/src/instances.ts index 6b4fcc76f..9d0e7a934 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -313,11 +313,19 @@ function addAssetHooks(loader: WebpackLoaderContext, instance: TSInstance) { instance.configFilePath ); - const makeAssetsCallback = (compilation: webpack.Compilation) => { - compilation.hooks.afterProcessAssets.tap('ts-loader', () => - cachedMakeAfterCompile(compilation, () => { - return null; - }) + // compilation is actually of type webpack.Compilation, but afterProcessAssets + // only exists in webpack5 and at the time of writing ts-loader is built using webpack4 + const makeAssetsCallback = (compilation: any) => { + compilation.hooks.processAssets.tap( + { + name: 'ts-loader', + stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, + }, + (_assets: webpack.Asset[]) => { + cachedMakeAfterCompile(compilation, () => { + return null; + }); + } ); };