Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clojurescript support #5

Open
cldwalker opened this issue Jul 3, 2014 · 7 comments
Open

Add clojurescript support #5

cldwalker opened this issue Jul 3, 2014 · 7 comments

Comments

@cldwalker
Copy link

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!

@davecoates
Copy link
Owner

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

@davecoates
Copy link
Owner

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.

@cldwalker
Copy link
Author

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?

@davecoates
Copy link
Owner

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.

@davecoates
Copy link
Owner

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?

@davecoates
Copy link
Owner

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)

@davecoates
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants