Angular-cli: ng build --prod --watch compiles app state before the save

Created on 1 Mar 2017  Â·  12Comments  Â·  Source: angular/angular-cli

Description:

While running a build watch with the '--prod' or '--aot' options, the results to dist seem to be one save behind. Meaning, if I make a change and save, the change is detected and the project builds, however the results are the state of the app before the change. If I make another change, like adding a new line to a file, the change is detected and the project built, with the results of the previous save but not capturing the new lines added.

_Note: This issue goes away if the '--prod' or '--aot' options are not used._

OS?

Windows 10

Versions.

@angular/cli: 1.0.0-beta.30
node: 6.9.5
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.30
@angular/compiler-cli: 2.4.8

Repro steps.

ng new test-app
ng build --prod --watch
or
ng build --aot --watch
or
ng build --prod --aot --watch

The log given by the failure.

None

easy (hours) 1 (urgent) inconvenient bufix

Most helpful comment

I investigated a bit more and this doesn't seem to happen on all changes.

I can reproduce when changing a component template, but not when changing the component itself (changes are immediately reflected in this case).

So this seems related to the child compilers we use.

All 12 comments

After solving issue #5138 this problem went away. My guess is I somehow had multiple versions of angular-cli installed that were conflicting with each other.

Correction, I'm still experiencing this issue on another computer after following the same steps I used to solve #5138 . I found that if I make a change to the index file, I can see the change take immediate effect in the dist folder. However, a change to a component does not show up, and is always one save behind.

Same here, build -w --aot outputs first compilation result correctly, but then every next rebuild is one save behind (I have to make 2 changes & saves to see result of first change). Doesn't happen without --aot / --prod.

Can confirm this also happens on ng serve --aot. Looking into it.

Possibly related, but I can't see the issue fixed by it: https://github.com/angular/angular-cli/pull/4009

I investigated a bit more and this doesn't seem to happen on all changes.

I can reproduce when changing a component template, but not when changing the component itself (changes are immediately reflected in this case).

So this seems related to the child compilers we use.

FYI - I might have had this same issue. Apparently I had another ng build process running in the background. when I killed that the issue got resolved.

@filipesilva @bklik I am also experiencing this issue...
(My current workflow is to always CTRL+S twice)

I noticed on @bklik's version output that they are running node: 6.9.5. My local version of node is 6.9.5 and wondering if that could have anything to do with this?

Unfortunately, I can only installed "approved" versions of node at work :-1: so I cannot update my node at this time.

OS: Ubuntu 16.04.
Command: "ng build --watch -prod -oh none --aot true".
My save .css .html file is to always CTRL+S twice. (loading build is so long)

I noticed the same / similar problem myself.

What I observed

  1. serve in the browser: npm start -- -o -aot
  2. change a component ts file such that it breaks the compile

    • for me, I changed a component property referenced in the template to private

    • as expected, webpack complains with the message "wepack: Failed to compile"

  3. change the component ts file such that it fixes the compile failure, and press save

    • webpack runs but still complains with the message "wepack: Failed to compile"

  4. without make any further changes, press save again

    • this time webpack builds successfully

You can reproduce this problem in the following repo (generated using the cli): https://github.com/christianacca/rxjs-err-async-pipe/commit/c9909e48c6443bc9026d994e9aac2b74e22b16e3

Try changing ticks$ to private

My environment

  • Windows 10 anniversary edition
  • Visual Studio Code 1.11.2
  • node 6.9.2
  • angular 4.1.0
  • angular cli 1.0.1

I am seeing the same problem. Change are always one save behind. The behavior is only experienced when using --aot or --prod. Other developers with the same project get the same problem. I see the same problem with the repo that @christianacca linked above.

My environment

  • Windows 10 Enterprise Creators Update
  • WebStorm or Visual Studio 2015
  • @angular/cli: 1.3.0
  • node: 6.10.3
  • @angular/common: 4.3.3
  • @angular/compiler-cli: 4.3.3

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._

Was this page helpful?
0 / 5 - 0 ratings