How to implement polymer error tracking?

Is there a way to track errors in Polymer?

The problem is that, apparently, vulcanization and polishing processes cannot provide any source maps (please correct me if I am wrong). This means that even if I catch the exception in the vulcanized java script code using the global window.onerror function, I cannot display it back and find the actual location of the error in the source files.

Any solutions / workarounds would be highly appreciated.

+5
source share
1 answer

Here is my idea of ​​what can be done. Please provide your ideas and solutions. This solution has not been verified.

according to https://github.com/PolymerLabs/polybuild the 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 

order:
1) vulcanization produces one html-formatted file.
2) polyclean uses uglifyjs internaly and does some cleanup
3) crisper is used to separate already quenched and mini js from html

as far as I know, uglifyjs does not work with html files as input, so polyclean manually cuts parts of the js code ', puts it through uglifyjs and inserts it back (I hope I understand how polyclean works correctly). Therefore, creating source maps is useless in this context. my idea is to reorder the polyclean and crisper and change the polyclean to allow the use of external options for uglifyjs2:

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

So, first you will have an html file and a formatted js file, and only then can you use uglifyjs2 (a call from polyclean or standalone?) With the -source-map and -source-map-include-sources options. Now you can track your mistakes using the created source map, which already contains a formatted copy of the js file created in step 2.

0
source

Source: https://habr.com/ru/post/1241121/


All Articles