Replace afterCompile to stop webpack 5 warning#1200
Merged
johnnyreilly merged 5 commits intoTypeStrong:masterfrom Oct 20, 2020
appzuka:master
Merged
Replace afterCompile to stop webpack 5 warning#1200johnnyreilly merged 5 commits intoTypeStrong:masterfrom appzuka:master
johnnyreilly merged 5 commits intoTypeStrong:masterfrom
appzuka:master
Conversation
| // afterProcessAssets does not exist in webpack4 | ||
| loader._compilation.hooks.afterProcessAssets.tap( | ||
| 'ts-loader', | ||
| (_: any) => { |
Member
There was a problem hiding this comment.
Do you happen to know what the type is here? Not that we're using it but I'm curious
Member
Author
There was a problem hiding this comment.
It is a list of the assets:
If I include the parameter there is a warning that it is unused, so I decided to include it as _:any
Member
|
This looks great @appzuka ! Thanks for your work 🌻❤️ Would you like to update the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the deprecation warning in webpack 5 as discussed in issue #1196. Writing assets such as declarations is moved to the afterProcessAssets hook of the compilation from the afterCompile hook of the compiler.
As the afterProcessAssets hook does not exist in webpack 4 to make ts-loader work for both webpack 4 and 5 it is necessary to execute different code depending on whether afterProcessAssets exists. This means that the new code is not tested at all by either the execution or comparison tests, which feels wrong. I'm not sure how to fix this until tests using webpack 5 are introduced, which feels like a major task.
I have tested this build with a small project using webpack 4 and webpack 5. If I introduce a deliberate error into the webpack 5 branch of the new code all the tests still pass although building the project with webpack 5 fails.