From 1ae7a46bf46f5025acfa006effd083ac16f3fac4 Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Mon, 19 Oct 2020 16:30:34 +0100 Subject: [PATCH 1/4] Replace afterCompile to stop webpack 5 warning --- src/instances.ts | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/src/instances.ts b/src/instances.ts index 95ac680e2..eedde15de 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -341,10 +341,26 @@ export function initializeInstance( instance.transformers = getCustomTransformers(program); // Setup watch run for solution building if (instance.solutionBuilderHost) { - loader._compiler.hooks.afterCompile.tapAsync( - 'ts-loader', - makeAfterCompile(instance, instance.configFilePath) - ); + if (loader._compilation.hooks.afterProcessAssets) { + // afterProcessAssets does not exist in webpack4 + loader._compilation.hooks.afterProcessAssets.tap( + 'ts-loader', + (_: any) => { + makeAfterCompile(instance, instance.configFilePath)( + loader._compilation, + () => { + return null; + } + ); + } + ); + } else { + // adding assets in afterCompile is depracated in webpack 5 + loader._compiler.hooks.afterCompile.tapAsync( + 'ts-loader', + makeAfterCompile(instance, instance.configFilePath) + ); + } loader._compiler.hooks.watchRun.tapAsync( 'ts-loader', makeWatchRun(instance, loader) @@ -391,11 +407,27 @@ export function initializeInstance( instance.languageService!.getProgram() ); } + if (loader._compilation.hooks.afterProcessAssets) { + // afterProcessAssets does not exist in webpack4 + loader._compilation.hooks.afterProcessAssets.tap( + 'ts-loader', + (_: any) => { + makeAfterCompile(instance, instance.configFilePath)( + loader._compilation, + () => { + return null; + } + ); + } + ); + } else { + // adding assets in afterCompile is depracated in webpack 5 + loader._compiler.hooks.afterCompile.tapAsync( + 'ts-loader', + makeAfterCompile(instance, instance.configFilePath) + ); + } - loader._compiler.hooks.afterCompile.tapAsync( - 'ts-loader', - makeAfterCompile(instance, instance.configFilePath) - ); loader._compiler.hooks.watchRun.tapAsync( 'ts-loader', makeWatchRun(instance, loader) From c3119240cf8db3ac4d51610e04219bec4c3f9fe9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 19 Oct 2020 20:56:17 +0100 Subject: [PATCH 2/4] Update src/instances.ts --- src/instances.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/instances.ts b/src/instances.ts index eedde15de..189905b38 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -355,7 +355,7 @@ export function initializeInstance( } ); } else { - // adding assets in afterCompile is depracated in webpack 5 + // adding assets in afterCompile is deprecated in webpack 5 loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', makeAfterCompile(instance, instance.configFilePath) From 1d1714d8eec7e50bdde10c03ca47dc6b0bb055aa Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 19 Oct 2020 20:58:35 +0100 Subject: [PATCH 3/4] Update src/instances.ts --- src/instances.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/instances.ts b/src/instances.ts index 189905b38..769e023f3 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -421,7 +421,7 @@ export function initializeInstance( } ); } else { - // adding assets in afterCompile is depracated in webpack 5 + // adding assets in afterCompile is deprecated in webpack 5 loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', makeAfterCompile(instance, instance.configFilePath) From 6222124b1639c136e974fff2b618c0affb0fa6fa Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Mon, 19 Oct 2020 22:23:57 +0100 Subject: [PATCH 4/4] Updated Changelog and bump version --- CHANGELOG.md | 3 +++ package.json | 2 +- src/instances.ts | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2e9697fa..d803cb168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v8.0.6 +* [Fixed further deprecation warning on webpack@5](https://github.com/TypeStrong/ts-loader/issues/1196) - thanks @appzuka + ## v8.0.5 * [Fixed deprecation warnings on webpack@5](https://github.com/TypeStrong/ts-loader/issues/1194) - thanks @sanex3339 diff --git a/package.json b/package.json index bceb649e4..96cfa1195 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "8.0.5", + "version": "8.0.6", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", diff --git a/src/instances.ts b/src/instances.ts index eedde15de..769e023f3 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -355,7 +355,7 @@ export function initializeInstance( } ); } else { - // adding assets in afterCompile is depracated in webpack 5 + // adding assets in afterCompile is deprecated in webpack 5 loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', makeAfterCompile(instance, instance.configFilePath) @@ -421,7 +421,7 @@ export function initializeInstance( } ); } else { - // adding assets in afterCompile is depracated in webpack 5 + // adding assets in afterCompile is deprecated in webpack 5 loader._compiler.hooks.afterCompile.tapAsync( 'ts-loader', makeAfterCompile(instance, instance.configFilePath)