Fixing `CastError: Instance of 'minified:aR<String, dynamic>': type 'minified:aR<String, dynamic>' is not a subtype of type 'minified:b0'`

After I updated my package dependencies on a project I had not run for a long time, I tested it in debug mode using webdev serve. Things ran fine! So I proceeded to deploy it to production with webdev build. This time, upon running I got a few exceptions, one of which was:

CastError: Instance of 'minified:aR<String, dynamic>': type 'minified:aR<String, dynamic>' is not a subtype of type 'minified:b0'

When I click the error, it expands to show more of the long stack trace:

At the bottom I can see that the error originates from auth.esm.js:

Clicking the file shows me the (compiled) source, but at the top of the file, I can see that it comes from Firebase:

After updating my dependencies to Firebase from 5.1.1 to the latest 7.9.3 according to https://firebase.google.com/docs/web/setup, the error disappeared!

The lesson here is that if I update the dependency to the firebase pub package, I should be mindful of updating the dependency to the JS library. Now the messages at https://pub.dev/packages/firebase#-changelog-tab- make sense. For example for version 7.0.0, it says:

Updated documented JS library from 6.6.1 of the JS API to 7.4.0.