2

I am using a third party plugin which calls scripts using RequireJS. I want to debug e.g. setting breakpoints in those scripts but they didn't show up in the script tab of Chrome's developer tools.

Is there anyway for me to perform the debugging in chrome?

Quincy
  • 4,393
  • 3
  • 26
  • 40

1 Answers1

0

The only difficulty in debugging modules loaded with RequireJS is that if a module is loaded only if conditions X happens and this condition does not exist when the application is first loaded, you have to wait until the condition occurs before you can put breakpoints on the module's code.

For instance if you want to debug the function bar in module foo and foo is loaded like this:

if (X) {
    require(["foo"], function (foo) {
        foo.bar();
    });
}

You'd have to trigger condition X before you can start adding breakpoints inside foo.bar. Most likely, you'd want to put a breakpoint at the location of the foo.bar() call so that you have the opportunity to add a breakpoint inside foo.bar.

This is true in Chrome and Firefox, and probably in other browsers that offer debugging facilities.

Louis
  • 146,715
  • 28
  • 274
  • 320