-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Webpack 5 watch not failing on error #1204
Comments
Found it high priority |
Thanks for the detailed report - I can't dig into this myself right now, but you'll help anyone that comes after and I'd encourage you to dig into this also. One thing that occurs to me is that it looks like you're running webpack with watch but https://webpack.js.org/configuration/mode/ Not sure if it's definitely relevant but I thought I'd share |
Ah yes you're right, I forgot to specify |
Interesting - I wonder if this is linked to the work @sanex3339 did around deprecation warnings: #1195 (this PR was specifically related to the adding of errors to webpack) @appzuka has also done some work on deprecation warnings but I don't think that's related #1200 If anyone would like to investigate that would be greatly appreciated. |
This seems to be caused by my change to stop the deprecation warnings when declarations is true #1200. Calling makeAfterCompile during the afterCompile hook causes warnings as it is no longer allowed to add assets (such as declarations) at this stage. But calling it in the afterProcessAssets hook fails to add errors when in watch mode. I'm thinking that the solution may be to split makeAfterCompile into 2 parts, separating out the calls which add assets and those which don't (such as reporting errors to webpack). I'll try to submit a PR as soon as I have time. |
Thanks to @appzuka's fine work this should be resolved with https://github.com/TypeStrong/ts-loader/releases/tag/v8.0.10 |
Thanks for your efforts guys! Highly appreciated. Works as expected in 8.0.10 👍 |
I guess this issue can be closed now. |
This looks like its been reintroduced. I'm getting this exact behavior on these versions webpack 5.21.2 |
@dl748, I can verify the problem and have a solution. I have already changed this section of code a few times and each change I make has unexpected consequences so I have gone back to understand why this has happened and whether changing it again will break something else. Originally, declaration file and errors were emitted during the compiler.afterCompile hook. In webpack5 it is no longer allowed to emit assets in the afterCompile hook so I moved this to the compilation.afterProcessAssets hook. But then as reported here errors were not emitted in watch mode. So I made the change here which is to emit errors during the compiler.afterCompile hook but to emit declaration files in the loader._compilation.afterProcessAssets hook. But then it was reported that declaration files are not emitted in subsequent runs during watch mode. This was traced to loader._compilation not being persistent so we need to use a compilation hook to get the compilation so we can add the afterProcessAssets hook. With hindsight, this was also the cause of errors not being emitted in the previous step and would have been a better solution. But now I have broken error reporting again. I can see this is because when we emit the declaration files the list of files to check for errors is reset, so when we check whether there are any errors in the afterCompile stage no files are checked. If I change the code so that errors and declaration files are emitted at the compiler.afterProcessAssets stage everything seems to work correctly for both errors and declaration files for both normal and watch builds. I'll raise a PR for this change. |
Will have to wait for the npm module release, unable to build v8.0.16
|
ts-loader@8.0.16 from npmjs.com is working as expected @appzuka @johnnyreilly |
@appzuka @johnnyreilly Here's the second confirm that upgrading from ts-loader@8.0.15 to ts-loader@8.0.16 fixed this issue (kudos to ncu). |
Still seems to be happening? But could be nodemon plugin as well that is just restarting the server...
|
Bug report
What is the current behavior?
When I start webpack in watch mode it does not fail on a TypeScript error.
If the current behavior is a bug, please provide the steps to reproduce.
$ yarn install
$ yarn bundle --watch
src/index.ts
that should lead to a TypeScript error:What is the expected behavior?
I expect webpack to fail when trying to bundle my files when typescript/ts-loader detects an error. This worked fine so far when I was using webpack 4.44.2 but since I upgraded to webpack 5.3.2 this problem occurs. Interestingly this only happens when changing files after I started the watch process. When I add the failing code snippet before starting the watch process it fails as expected with the according error message:
Other relevant information:
webpack version: 5.3.2
Node.js version: 14.14.0
Operating System: Windows 10 1909 (also reproducible on macOS 10.15 Catalina)
Additional tools: webpack-cli 4.1.0, ts-loader 8.0.7, typescript: 4.0.5
This issue was moved from webpack/webpack#11889 by @evilebottnawi. Original issue was by @oliverschwendener.
The text was updated successfully, but these errors were encountered: