Angular Prod Build Specific Bugs

jengfad

Jennifer Fadriquela

Posted on November 20, 2020

Angular Prod Build Specific Bugs

I recently upgraded our project to Angular 10 from version 8. Below is a piece of code that went buggy:

@ViewChild('searchTextBox', { read: false }) searchTextBox: ElementRef;
Enter fullscreen mode Exit fullscreen mode

This was working in v8 but not in v10.

The fix is to assign the expected type to 'read' property.

@ViewChild('searchTextBox', { read: ElementRef }) searchTextBox: ElementRef;
Enter fullscreen mode Exit fullscreen mode

As I am debugging this in v10, I noticed that the error is not reproducible when running ng serve but will appear if you run ng serve --prod.

Lesson Learned: Always do a sanity test in prod build. Note that prod build is not debuggable and takes a while to build.

💖 💪 🙅 🚩
jengfad
Jennifer Fadriquela

Posted on November 20, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related