Open cldwalker opened 10 years ago
Yep - you'll need source maps enabled for this to work.
Basically :Debugger.scriptParsed is raised whenever that event is received from Chrome. That gets added to a map on the client (:scripts) which is indexed by filename - this will always be a .js file. If that file has sourcemaps another entry is added with the sourcemap filename (this will have the correct extension for the source file, eg. cljs). You can check what scripts are parsed by looking at the keys in your client, eg. (-> (@clients/by-id client-id :scripts keys). If your source filename isn't there and you have sourcemaps going something's not right.
There was a bug that is fixed in 0.0.2 that mean find-script would return nothing so just make sure you have that change.
Let me know how you go, I can try have a look later today
I've tried this with sourcemaps and it can find the script however when it tries to get the generated position it always returns nil so it doesn't work. I tried setting the location manually and it does set the breakpoint and stops on it so that part works. Just need to work out why generated-position always returns nil for the line number.
I'm also seeing generated-position return nil. I'm still not able to pick up my source-map and had to resort to manually loading my sourcemap, similar to this. The source map that wasn't automatically picked up is a standard one for plugins generated by LT. Do you have an example cljs repository with a source map I could try?
Hmm that one looks fine. I did have one at work but I'm at home for the weekend now... I'll put one up as soon as I get a chance but may not be until tomorrow.
I'm also not sure how useful the debugger will be for clojurescript - won't we just be dealing with the output of the closure compiler so all variable names will be different etc?
https://github.com/davecoates/game-of-life
Should just be able to open index.html and add breakpoint (eg. core.cljs in the tick function)
Ok with :optimizations :none I can see how it might be useful. Sometimes debugger seems to pause but no location is available (or it's being extracted incorrectly) but otherwise I can step through and inspect scope variable. Code eval does nothing currently
I'd like to add support for clojurescript. Locally I've enabled breakpoint behavior similar to other file types. However, I'm getting "Couldn't find script to set breakpoint in" because chrome/find-script returns nil. I'm assuming there are no cljs-based scripts because the ::script-parsed behavior hasn't kicked off properly for cljs. Where does the :Debugger.scriptParsed trigger get kicked off? I'm guessing I'll need to generate a source-map so the source-map library can consume it. If you have any tips or better yet a list of things I'll need to implement, I'm all ears.
Thanks for making LT's first full-fledged debugger!