You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
esbuild: Application rebuilding after files wrongfully were detected as changed #25197
@wartab, this should not be any different from the default webpack based builder. When a file is saved, even if the contents did not change a rebuild is triggered.
It seems like I have been mislead by what the root cause of this is. I took the time to investigate what is happening and managed to find that this was all a side effect of having a JetBrains IDE open while doing my tests. All operations I described were either directly caused by the IDE or made the IDE react in a way I didn't expect.
Specifically the example I mentioned:
Pressing Ctrl + S in an unchanged file doesn't change the file I'm trying to save. However, it modifies the file in "./.idea/workspace.xml". Several events cause this file to be touched by the IDE.
So the issue is more that the esbuild version watches more/other files than the webpack version.
I can see that the naive way of not watching directories starting with a dot wouldn't work, as Webpack also watches those folders once those files are imported in source code.
I can confirm I am seeing this also, but it seems totally random 😕
I had VS Code opened and cleared the terminal so I could keep an eye on it.
All I did was click on my ".gitignore" file, just click it not change it, and I got "Changes detected. Rebuilding ...".
Then I cleared the terminal and tried clicking other files, couldn't repro it ... until I clicked angular.json. Then it rebuilt again.
package.json? No rebuild. Click some other files and then go back to package.json? Rebuild.
If I clear the terminal and try clicking these files again to repro, it won't rebuild.
No modifications were made to these files at all, it simply displayed them in the editor and this caused esbuild to trigger another rebuild.
Is there anything special about these particular files that I'm missing? But it gets stranger ...
Often it will rebuild when I switch away from, and then back to, the VS Code window. Sometimes. But not reproducable. It happened just now when I switched back to it, but when I tried it again it didn't rebuild the second time. Then, later in the day, I switched back to it and it rebuilt the project ... twice. One right after the other.
Next, I went to clear the terminal again, so I clicked the three dots to get to the "Clear Terminal" window.
Just clicking the three dots again caused it to rebuild. Just the opening of the menu.
I'd almost think it's seeing some external program making some changes to these files but it is happening clearly as a result of actions I am taking. The console will be clear and exactly the moment I select a file, rebuild. The exact moment I open a menu, rebuild. That can't be a coincidence.
it's quite annoying problem. sometimes it seems randomly rebuilding while viewing front end in the browser. thus triggering reload in the browser as well! Editor is vs code. seems like it changes cache or some config but angular esbuild treats it as file change in the project.
It does fix it, indeed. That said, and I realise it's a bit nitpicky, but that's not exactly the behaviour we had when not using esbuild, but I'm sure it doesn't affect the vast majority of projects:
Directories leading with a dot shouldn't be ignored if they are inside the src/ directory, in my opinion.
Regarding the nitpick: without esbuild, even outside the src/ directory, Angular tracks changes for files that are imported by TypeScript.
We ran into this issue with files in the project directory.
We integrated newrelic with the ssr express server. By default, newrelic writes to a log file newrelic_agent.log in the project root directory when it starts. (even when it's disabled)
With the webpack based bundler these changes are ignored. However, the esbuild builder picks them up and we end up in an endless loop of detecting changes and rebuilding.
Activity
alan-agius4 commentedon May 12, 2023
@wartab, this should not be any different from the default webpack based builder. When a file is saved, even if the contents did not change a rebuild is triggered.
wartab commentedon May 13, 2023
I just tested it again. I can confirm what I reported. The behaviour is different with esbuild.
wartab commentedon May 13, 2023
I'm not sure how to help out with this. It's pretty easy to replicate on my end, so if you can tell me how to proceed, let me know.
clydin commentedon May 15, 2023
As mentioned, the default Webpack-based builder also will rebuild if a file is altered but does not have any content changes.
The following steps can be used to demonstrate this:
ng build --watch. Output:touch src/main.ts. Output:As shown above, a rebuild is performed even though no input content is actually changed.
wartab commentedon May 15, 2023
It seems like I have been mislead by what the root cause of this is. I took the time to investigate what is happening and managed to find that this was all a side effect of having a JetBrains IDE open while doing my tests. All operations I described were either directly caused by the IDE or made the IDE react in a way I didn't expect.
Specifically the example I mentioned:
Pressing Ctrl + S in an unchanged file doesn't change the file I'm trying to save. However, it modifies the file in "./.idea/workspace.xml". Several events cause this file to be touched by the IDE.
So the issue is more that the esbuild version watches more/other files than the webpack version.
I can see that the naive way of not watching directories starting with a dot wouldn't work, as Webpack also watches those folders once those files are imported in source code.
psarno commentedon May 31, 2023
I can confirm I am seeing this also, but it seems totally random 😕
I had VS Code opened and cleared the terminal so I could keep an eye on it.
All I did was click on my ".gitignore" file, just click it not change it, and I got "Changes detected. Rebuilding ...".
Then I cleared the terminal and tried clicking other files, couldn't repro it ... until I clicked angular.json. Then it rebuilt again.
package.json? No rebuild. Click some other files and then go back to package.json? Rebuild.
If I clear the terminal and try clicking these files again to repro, it won't rebuild.
No modifications were made to these files at all, it simply displayed them in the editor and this caused esbuild to trigger another rebuild.
Is there anything special about these particular files that I'm missing? But it gets stranger ...
Often it will rebuild when I switch away from, and then back to, the VS Code window. Sometimes. But not reproducable. It happened just now when I switched back to it, but when I tried it again it didn't rebuild the second time. Then, later in the day, I switched back to it and it rebuilt the project ... twice. One right after the other.
Next, I went to clear the terminal again, so I clicked the three dots to get to the "Clear Terminal" window.
Just clicking the three dots again caused it to rebuild. Just the opening of the menu.
I'd almost think it's seeing some external program making some changes to these files but it is happening clearly as a result of actions I am taking. The console will be clear and exactly the moment I select a file, rebuild. The exact moment I open a menu, rebuild. That can't be a coincidence.
d9j commentedon Jun 2, 2023
it's quite annoying problem. sometimes it seems randomly rebuilding while viewing front end in the browser. thus triggering reload in the browser as well! Editor is vs code. seems like it changes cache or some config but angular esbuild treats it as file change in the project.
leo6104 commentedon Jun 7, 2023
Might be related to 7155cbe
wartab commentedon Jun 8, 2023
It does fix it, indeed. That said, and I realise it's a bit nitpicky, but that's not exactly the behaviour we had when not using esbuild, but I'm sure it doesn't affect the vast majority of projects:
MarcoGlauser commentedon Aug 14, 2023
We ran into this issue with files in the project directory.
We integrated newrelic with the ssr express server. By default, newrelic writes to a log file newrelic_agent.log in the project root directory when it starts. (even when it's disabled)
With the webpack based bundler these changes are ignored. However, the esbuild builder picks them up and we end up in an endless loop of detecting changes and rebuilding.
clydin commentedon Oct 31, 2023
Addressed via #26182
angular-automatic-lock-bot commentedon Dec 1, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.