Skip to content

Commit 5e08d5d

Browse files
authored
fix: Use correct stage for adding assets during compilation (#1286)
1 parent b6c2e77 commit 5e08d5d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v9.0.1
4+
5+
* [Use correct hook for emitting additional assets during compilation](https://github.com/TypeStrong/ts-loader/pull/1286) - thanks @jonwallsten
6+
37
## v9.0.0
48

59
Breaking changes:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "9.0.0",
3+
"version": "9.0.1",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist",

src/instances.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,16 @@ function addAssetHooks(loader: WebpackLoaderContext, instance: TSInstance) {
314314
);
315315

316316
const makeAssetsCallback = (compilation: webpack.Compilation) => {
317-
compilation.hooks.afterProcessAssets.tap('ts-loader', () =>
318-
cachedMakeAfterCompile(compilation, () => {
319-
return null;
320-
})
317+
compilation.hooks.processAssets.tap(
318+
{
319+
name: 'ts-loader',
320+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
321+
},
322+
() => {
323+
cachedMakeAfterCompile(compilation, () => {
324+
return null;
325+
});
326+
}
321327
);
322328
};
323329

@@ -327,10 +333,6 @@ function addAssetHooks(loader: WebpackLoaderContext, instance: TSInstance) {
327333

328334
// For future calls in watch mode we need to watch for a new compilation and add the hook
329335
loader._compiler.hooks.compilation.tap('ts-loader', makeAssetsCallback);
330-
331-
// It may be better to add assets at the processAssets stage (https://webpack.js.org/api/compilation-hooks/#processassets)
332-
// This requires Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, which does not exist in webpack4
333-
// Consider changing this when ts-loader is built using webpack5
334336
}
335337

336338
export function initializeInstance(

0 commit comments

Comments
 (0)