Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart to JS: How to debug the generated Javascript errors

Currently, the Javascript generated by dart2Js converter is very unintuitive to debug and doesn't produce intelligible error messages.

Is there a specific way that people use to debug Javascript code generated by dart?

I would like to get to the Dart line that is responsible for the error.

Also it would be great to see core dump and stack frames in terms of Dart code.

like image 308
Ravi Teja Gudapati Avatar asked Sep 02 '14 13:09

Ravi Teja Gudapati


1 Answers

At first ensure that you build with pub build --mode=debug.
This prevents minification and tree shaking.

Ensure that source maps are activated in Chrome devtools.
(DevTools settings - General - Sources - Enable JavaScript source maps).

Launch the application and debug.
The Chrome debugger should now show Dart source code when stepping through.

Polymer.dart

There seems to be an issue that the script used by default doesn't reference source maps How make pub build to use source maps on dart polymer projects

like image 161
Günter Zöchbauer Avatar answered Sep 29 '22 05:09

Günter Zöchbauer