Hi all,
ChromeTools provides a connection that uses the chrome remote debugging protocol to do live code evaluation, set watches and interact with the Chrome debugger. This can work a lot better than the browser script option as it actually tries to patch the existing code rather than just evaluating it again in global context (which means changes to code within anonymous functions can be changed and reflected without refreshing - particularly useful for CoffeeScript given it always wraps everything in a closure and every function is anonymous).
In terms of the debugger you can
- Set / remove breakpoints
- Normal debugger controls (pause, resume, step into / out / over)
- View stack trace
- View variables in current call frame
- Evaluate code on current call frame (uses whatever language your file is in - currently either Javascript or CoffeeScript)
- Supports source mapped files (currently just CoffeeScript)
In some cases evaluating code in LightTable doesn't really work well (or at all) due to preprocessors used (eg. SASS, Browserify etc). In these cases you can watch a directory with the generated files and any Javascript or CSS files that change within that directory will be sent in their entirety to Chrome. For CSS files it will try to remove the existing stylesheet and replace it, for Javascript it will try to replace the existing source (using Debugger.setScriptSource). I have mainly been using this for projects using Browserify and it works... mostly - for one particularly large project it often crashes the Chrome tab.
A few issues I'm aware of currently
- It sometimes seems to slow LightTable right down - it seems that Chrome sometimes starts sending lots of events through. I haven't worked this out yet and it doesn't always happen.
- Setting breakpoints often seems to be slightly inaccurate, particularly from source mapped files
Any feedback, bug reports etc welcome.
Cheers!
Dave