Skip to content

Commit

Permalink
fix: Use correct stage for adding assets during compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonWallsten committed Apr 19, 2021
1 parent b6c2e77 commit 4816d1a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/instances.ts
Expand Up @@ -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;
});
}
);
};

Expand Down

0 comments on commit 4816d1a

Please sign in to comment.