question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running `ng build --watch` not always picking up some code changes

See original GitHub issue

When running ng build with --watch, which we do pretty regularly as we have either nodemon or pm2 running a node server that hosts our site as well as API, background workers, our whole server backend basically, we often find that many code changes are not properly detected by ng build and it will report unchanged chunks, rather than properly rebuilding those that have actually had changes to the code.

We have observed that if a template is then changed in the same chunk, that usually results in the build properly rebuilding that chunk. Sometimes total removal of code from a file, to force an error, then restoration of it, will force proper rebuilding of a chunk.

Versions

→ ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.6.7
Node: 8.9.4
OS: darwin x64
Angular: 4.4.6
... common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router, tsc-wrapped

@angular/cli: 1.6.7
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.7
@schematics/angular: 0.1.17
typescript: 2.3.4
webpack: 3.10.0

Repro steps

  • Step 1: Make a code change to a model, service, NGRX state, etc.
  • Step 2: Save the changed file(s).
  • Step 3: Make a change to a template.
  • Step 4: Save the template.

Observed behavior

9 unchanged chunks
chunk {clients.module} clients.module.chunk.js, clients.module.chunk.js.map () 351 kB  [rendered]
Date: 2018-02-08T22:36:07.995Z - Hash: 72e9dc9abbe1980916c8 - Time: 1463ms           
10 unchanged chunks
Date: 2018-02-08T22:36:20.720Z - Hash: a9b0f4039ddc2b83dcb6 - Time: 982ms            
10 unchanged chunks
Date: 2018-02-08T22:36:23.728Z - Hash: 72e9dc9abbe1980916c8 - Time: 863ms            
10 unchanged chunks
Date: 2018-02-08T22:36:40.084Z - Hash: 31ddf5af1f9d07a7c892 - Time: 1113ms           
9 unchanged chunks
chunk {clients.module} clients.module.chunk.js, clients.module.chunk.js.map () 351 kB  [rendered]

Desired behavior

I would expect ng build to properly account for all changes made, to both code and templates, and the proper rebuilding of affected chunks.

Mention any other details that might be useful (optional)

This behavior is inconsistent, it does not always happen. It seems I encounter it most often with changes to models, properties in components, etc. This often leads to confusion when testing in the UI, and recent changes are not being applied. I have not been able to identify a specific scenario where it always occurs. Sometimes it seems like the code change may not actually matter, and the lack of rebuilding is immaterial…however upon testing again in the browser, the old issues remain, indicating the code change does indeed matter.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jristacommented, Feb 27, 2018

Just an update. Been having trouble reproducing the issue. I am not sure if it is due to our use of a fair number of lazy loaded modules or not. Once I am able to reproduce the issue I’ll share how.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - ng serve not detecting file changes automatically
Most of the times in Linux, ng serve or ng build --watch doesn't work if the directory doesn't have sufficient permissions.
Read more >
Angular: Watch Build for Changes - JavaScript in Plain English
As you make changes to a file, the watch recompiles and rebuilds the code. The dist/application-name directory is updated with the latest code....
Read more >
ng build does not detect changes? : r/angular - Reddit
Hey, I'm working on a couple of changes for an angular project and they're seemingly not going through. After saving the files in...
Read more >
Deployment - Angular
On the first terminal, run the ng build command in watch mode to compile the application to the dist folder. content_copy ng build...
Read more >
How to make angular app watch for changes in angular library ...
Create an angular application ... Now use any component from your library in the app. Run it. Make some changes to the library...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found