Ludomancer Posted October 16, 2016 Share Posted October 16, 2016 This is more of a questions really. Searched a bit around the issues, change-log and this forum but couldn't find an answer for it. I'm loading bunch of scripts dynamically via game.load.script. As expected I can't put brekapoints and debug those scripts. I'm aware of sourceURL solution, but couldn't get it working. Is there any way to put breakpoints and debug dynamically loaded scripts? Any help or information would be appreciated. Link to comment Share on other sites More sharing options...
samme Posted October 17, 2016 Share Posted October 17, 2016 As long as you can find the script in your browser's developer tools you should be able to add a breakpoint manually. Link to comment Share on other sites More sharing options...
Ludomancer Posted October 18, 2016 Author Share Posted October 18, 2016 7 hours ago, samme said: As long as you can find the script in your browser's developer tools you should be able to add a breakpoint manually. That I'm aware of. I looking for a way for browsers debugger to discover those files. Link to comment Share on other sites More sharing options...
in mono Posted October 18, 2016 Share Posted October 18, 2016 Use the debugger statement. Wherever you want a breakpoint, just put debugger; immediately before. This will work in Chrome and other Blink-based browsers (and also in Firefox I believe) as long as you have a dev tools open. If you want to temporarily disable it, right click on the line number where "debugger" appears and choose "Never pause here". Link to comment Share on other sites More sharing options...
mattstyles Posted October 18, 2016 Share Posted October 18, 2016 Completely agree with @in mono, using `debugger` is your easiest way to stop execution at a certain point, barring that there is always logging something, then clicking on it to find it in your source files and manually add a breakpoint. All modern browsers support this (breakpoints) but Chrome is the most advanced in this regard. 4 hours ago, Ludomancer said: I looking for a way for browsers debugger to discover those files. You mention files, do you have a build process? One that concatenates many files into one file to supply to the browser? If so, source maps are your friend, most build tools support building source maps, easiest is to append them to the end of your code bundle but you can also specify a separate file, add a small descriptor magic comment that tells the browser where to get the source map and then the browser will know how to build out the original source maps, usually mapping that to the bundle you have supplied. Many tools also include doing this even if your source is Typescript or ES2016/7, which is super amazing. Check out source maps and use a tool, don't write all that stuff yourself. Link to comment Share on other sites More sharing options...
Recommended Posts