简体   繁体   中英

How to implement error tracking in a polymer?

Is there a way of error tracking in Polymer?

Problem is that apparently vulcanize and polybuild processes couldn't provide any source-maps (Please correct me if I'm wrong). That means that even if I will catch an exception in vulcanized java script code using global window.onerror function I will be not able to map it back and find an actual location of an error in a source files.

any solutions/workarounds would be highly appreciated.

Here is my idea of what could be done. Please provide your ideas and solutions aswell. This solution is not tested.

according to https://github.com/PolymerLabs/polybuild polybuild tool is the same as:

vulcanize --inline-css --inline-scripts --strip-comments index.html | polyclean | crisper --html index.build.html --js index.build.js

the order is:
1) vulcanize produces one html formatted file.
2) polyclean uses uglifyjs internaly and perform some cleaning
3) crisper is used to separate already uglyfied and minified js from html

as far as I know uglifyjs doesn't work with html files as input so polyclean manually cuts parts of js code', put it through uglifyjs and paste it back (I hope I understood correctly how polyclean works). That's why creating of source maps is useless in this context. my idea is to change the order of polyclean and crisper and modify polyclean to allow using external options for uglifyjs2:

new order:
1) vulcanize produces one html formatted file.
2) crisper is used to separate formatted js from html.
3) polyclean uses uglifyjs internaly and perform some cleaning (in this case we need to use on both js and html files)

So first you will have html file and formatted js file and only then you can use uglifyjs2(call from polyclean or standalone?) with --source-map and --source-map-include-sources options. Now you can keep tracking your errors using produced source-map which already contains formatted copy of js file produced in step #2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM