Skip to content

Commit

Permalink
Replace afterCompile to stop webpack 5 warning (#1200)
Browse files Browse the repository at this point in the history
* Replace afterCompile to stop webpack 5 warning

* Update src/instances.ts

* Update src/instances.ts

* Updated Changelog and bump version

Co-authored-by: John Reilly <johnny_reilly@hotmail.com>
  • Loading branch information
appzuka and johnnyreilly authored Oct 20, 2020
1 parent 6d8d601 commit 0b4a86d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
48 changes: 40 additions & 8 deletions src/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 deprecated in webpack 5
loader._compiler.hooks.afterCompile.tapAsync(
'ts-loader',
makeAfterCompile(instance, instance.configFilePath)
);
}
loader._compiler.hooks.watchRun.tapAsync(
'ts-loader',
makeWatchRun(instance, loader)
Expand Down Expand Up @@ -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 deprecated 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)
Expand Down

0 comments on commit 0b4a86d

Please sign in to comment.