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
Angular Build --watch caches initial version of files in a symlinked folder. Subsequent changes are not reflected until full rebuild #23896
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
Angular 12
Description
Hi Team,
We are having issues with Angular not loading changes of symlinked files. It appears to build the first time and cache the output. Changing the file shows Angular rebuilding but it uses the old version. You have to kill ng build and start again.
Our project is in single Git repository. It consists of an Angular 14 front end and a Node backed API using NestJS. We also have model folder that contains shared DTO's and utilities.
The simplified folder structure is as follows -
/
angularapp
libs/
model (symlink of /model)
nodeapp
libs/
model (symlink of /model)
model
We have been using the structure since Angular 2 and I believe it worked up until you switch to WebPack 5.
Minimal Reproduction
Create an Angular Project
Create a folder outside the project called model
Symlink the folder inside the Angular project eg - /angularapp/model
Add files to the model folder.
Do a build in watch mode
Change the contents of a file in the model folder
Wait for watcher to finish build
Refresh the browser and the change will not be visible
Cancel the watch build
Build again
Refresh the browser and the change will be visible.
I tried to replicate the above and what I noticed is that when modifying the linked file there is no rebuild. So apart from the suggested changed above, I also modified watchOptions to include "followSymlinks": true and now symlink changes are picked up.
Activity
alan-agius4 commentedon Sep 12, 2022
Can you try to enable
preserveSymlinks?"build": { "builder": "@angular-devkit/build-angular:browser", "options": { + "preserveSymlinks": true,More info: https://angular.io/cli/build
thaoula commentedon Sep 12, 2022
Hi @alan-agius4,
We already have this turned on -
Just wondering if this WebPack 5 issue is the root cause -
webpack/webpack#15100
Regards,
Tarek
alan-agius4 commentedon Sep 12, 2022
@thaoula, indeed it does look like the root cause. Can you try to apply the suggested patch in the comments and verify if that works?
node_modules/@angular-devkit/build-angular/src/webpack/configs/common.js
thaoula commentedon Sep 12, 2022
Hi @alan-agius4,
Is this correct? It did not seem to work.
Steps:
Regards,
Tarek
alan-agius4 commentedon Sep 12, 2022
Based on the comments in webpack/webpack#15100 (comment), yes that should be a workaround for this issue.
Not sure if you need to delete the cache (
rm -rf .angular/cache)thaoula commentedon Sep 12, 2022
Let me try and delete the cache now
thaoula commentedon Sep 12, 2022
Hi @alan-agius4,
I have tried deleting the cache and did not make any difference unfortunately.
It seems other people also see this above settings not working
alan-agius4 commentedon Sep 12, 2022
I tried to replicate the above and what I noticed is that when modifying the linked file there is no rebuild. So apart from the suggested changed above, I also modified
watchOptionsto include"followSymlinks": trueand now symlink changes are picked up.thaoula commentedon Sep 12, 2022
Hi @alan-agius4,
This combination seems to resolve the issue.
thaoula commentedon Sep 12, 2022
Let my try hash, instead of timestamp, again to make sure I am not going crazy :)
thaoula commentedon Sep 12, 2022
Hash works fine in combination with the watchOptions.followSymlinks
thaoula commentedon Sep 12, 2022
Should I advise my team to make the above changes to common.js file or just wait for a new version of Angular CLI?
alan-agius4 commentedon Sep 12, 2022
You can patch the
node_modulesuntil it has been fixed and released.thaoula commentedon Sep 12, 2022
Thanks for your help :)
angular-automatic-lock-bot commentedon Oct 15, 2022
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.