-
-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace afterCompile to stop webpack 5 warning #1200
Conversation
// afterProcessAssets does not exist in webpack4 | ||
loader._compilation.hooks.afterProcessAssets.tap( | ||
'ts-loader', | ||
(_: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you happen to know what the type is here? Not that we're using it but I'm curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
This looks great @appzuka ! Thanks for your work 🌻❤️ Would you like to update the |
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.