Fork me on GitHub
#clojurescript
<
2019-05-10
>
cjohansen08:05:10

I generated a source map for my advanced compiled production build and put it in production. However, it's not fully working - the browser recognizes the source map, and stack traces now include the right file names and line numbers, but the symbols/names are still mangled. Also, when I click on a file location, the source is empty. Any pointers?

dnolen09:05:31

@christian767 the original sources can't be resolved - that's all

dnolen09:05:47

you've either put them in the wrong place, or you didn't deploy them

cjohansen09:05:15

ah, so the sources need to go out as well

cjohansen09:05:32

I thought all the required information was embedded in the sourcemap

cjohansen09:05:51

will deploying the sources help the browser resolve the names as well?

dnolen10:05:01

no source map just does mapping

dnolen10:05:34

you can't magically embed all that source 🙂

thheller10:05:18

well you could include sourcesContent in the source map

cjohansen10:05:26

I guess 🙂 Well, copying the sources over solved the navigation, but the symbols on the left are still garbled

thheller10:05:11

@christian767 if you are debugging :advanced issues setting :pseudo-names true is very helpful since it makes the names actually somewhat readable

cjohansen10:05:09

Ok, thanks. I'll try that. I expected that source maps would know to translate PZ to taoensse.timbre/log, but that's perhaps hoping for too much?

thheller10:05:38

that might just be a limitation of the browser not doing that translation

thheller10:05:51

the source map in theory contains all that info

thheller10:05:18

but doing that translation is quite costly so browser probably just don't do it at that level

cjohansen10:05:48

yes, I thought that info was in the source map

thheller10:05:56

:advanced also changes the code in pretty dramatic ways .. so it might just not be possible to map it back

thheller10:05:32

for debugging use :pseudo-names (with or without source maps)

cjohansen10:05:16

does that affect build size dramatically?

thheller10:05:30

definitely don't deploy that. only use it for debugging.

cjohansen10:05:04

I'm trying to improve insight into production faults 🙂

cjohansen10:05:52

thanks for your input @thheller @dnolen! Much appreciated

cjohansen10:05:10

btw, does anyone know of tools for parsing source maps on the JVM? Something like this, just for the JVM: https://github.com/mozilla/source-map/

thheller10:05:10

yeah, there is something in the closure compiler for that. its just not well documented. see https://clojureverse.org/t/server-side-decoding-of-javascript-sourcemaps/1591/3?u=thheller

cjohansen10:05:15

@thheller where does com.google.debugging.sourcemap come from? com.google.javascript/closure-compiler-unshaded?

cjohansen10:05:37

you don't also happen to know where to look for stack trace parsing utilities in closure?

thheller10:05:05

there aren't any since each browser has its own format

thheller10:05:19

there are some utils in CLJS

cjohansen10:05:31

I would've thought they had a decent cross-browser implementation in closure

cjohansen10:05:00

ooh, it works on the JVM too, awesome

thheller10:05:07

there might be .. just not anything I'm aware of 🙂

cjohansen10:05:45

very helpful, you've saved me/us loads of time today

carkh13:05:53

that screams monad to me, but afaik monads are not the clojure way, so what would be the clojure way ?