DEV Community

loading...

Angular Prod Build Specific Bugs

jengfad profile image Jennifer Fadriquela ・1 min read

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.

Discussion (0)

pic
Editor guide