DEV Community

Jennifer Fadriquela
Jennifer Fadriquela

Posted on

1 1

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.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay