Skip to content

Commit 4816d1a

Browse files
committed
fix: Use correct stage for adding assets during compilation
1 parent b6c2e77 commit 4816d1a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/instances.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,19 @@ function addAssetHooks(loader: WebpackLoaderContext, instance: TSInstance) {
313313
instance.configFilePath
314314
);
315315

316-
const makeAssetsCallback = (compilation: webpack.Compilation) => {
317-
compilation.hooks.afterProcessAssets.tap('ts-loader', () =>
318-
cachedMakeAfterCompile(compilation, () => {
319-
return null;
320-
})
316+
// compilation is actually of type webpack.Compilation, but afterProcessAssets
317+
// only exists in webpack5 and at the time of writing ts-loader is built using webpack4
318+
const makeAssetsCallback = (compilation: any) => {
319+
compilation.hooks.processAssets.tap(
320+
{
321+
name: 'ts-loader',
322+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
323+
},
324+
(_assets: webpack.Asset[]) => {
325+
cachedMakeAfterCompile(compilation, () => {
326+
return null;
327+
});
328+
}
321329
);
322330
};
323331

0 commit comments

Comments
 (0)