angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build should raise a warning if a private component member is referenced in the template, as --prod will fail

Open williamBurgeson opened this issue 9 years ago • 3 comments

See my very quick and simple github repo https://github.com/williamBurgeson/ng-cli-pub-priv

To reproduce the issue, download it, run ng build, and then ng build --prod, and you will see that ng build produces no warning, whereas ng build --prod fails completely

As you will see from the history, I just did ng new XXXXX --routing, and then added a private "message" field to the app component, and referenced it in the template {{message}}

It would be much nicer if things like this which fail ng build --prod would at least raise a warning in dev, with wording to the effect that "This would fail in ng build --prod with standard configuration" - given that I'm sure many devs like me will not be running ng build --prod that often, you can end up having to trawl back through your repo commit history to go back and fix errors like this whereas if you had been warned straight away it will save time in the long run

williamBurgeson avatar Sep 14 '17 17:09 williamBurgeson

This is because ng build does not use AOT (which performs that type checking, including property scope) where ng build --prod does use AOT and therefore shows the error.

You can use aot without prod by doing ng build --aot to get the feedback you desire.

The team is working to improve AOT performance to make it the default way to build apps all the time.

Brocco avatar Sep 22 '17 15:09 Brocco

Thanks for this clarification - am I correct in thinking that angular 5 would effectively "fix" this, given the default is aot?

Given that during the last year we seem to be moving more from the system.js model to the angular/cli (webpack) model, it feel a bit "noisy" to have to supply the --aot switch.

williamBurgeson avatar Sep 23 '17 14:09 williamBurgeson

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.