After updating a bunch of dependencies in my project, I tested it in dev mode with
webdev serve, and it worked fine. So I compiled it with
webdev build and released it, only to find out that this time, things broke:
Uncaught TypeError: Instance of 'eD': type 'eD' is not a subtype of type 'minified:cV'
This is not very useful. So I checked the webdev doc at https://dart.dev/tools/webdev to see if there were some better compile mode. Something like "use human-readable names". As of writing, there is not. However the page says that it relies on dart2js. The doc for dart2js at https://dart.dev/tools/dart2js does give more options as to how to compile. I could for example use less destructive optimizations. It also mentions source maps. I wonder why webdev doesn't allow to generate source maps... So I looked online for a way to do it. I found this post: https://stackoverflow.com/a/53954487/10358301. It says that if you put this in a
build.yaml file, it'll leave the maps:
targets: $default: builders: build_web_compilers|dart_source_cleanup: release_options: enabled: false
I tried and it sure enough, it left a map file! Btw, this config is impossible to guess, so someone filed a ticket to surface the option better in webdev: https://github.com/dart-lang/build/issues/1779
Upon loading the webapp in Chrome, the debugger tool notifies me that a map was found. However the stack traces are still obfuscated! After digging around some more, I found this issue: https://github.com/dart-lang/build/issues/2377. It was open 7 months ago, reporting that source maps don't work with dart2js. Ugh.
Running it again and stopping the debugger on exceptions, I got to see the local state. One variable was of type
GeolocationPosition. So I figured it was related to
window.navigator.geolocation. It seems related to https://github.com/dart-lang/sdk/issues/32592. The issue mentions ddc and dart2js. ddc is short for
dartdevc (https://dart.dev/tools/dartdevc), it is the compiler used for development by
webdev serve, while
dart2js is the compiler used by
webdev build. The ticket says things work fine in
dart2js but not
ddc. My issue is the opposite.
Unless I stop using geolocation entirely, I'm stuck for now. Things I could do next, but won't because I don't want to spend more time on this:
- Try the minimal https://github.com/dart-archive/dart-samples/tree/master/html5/web/geolocation/trip_meter. File a bug to https://github.com/dart-lang/.
- Try compiling using
dart2jswith the less destructive methods.
- Serve the devel output from
webdev servein prod.