1

Having read Debug Components in an Org With LWS Enabled and various posts from the last couple of years on debugging problems, I still can't set a breakpoint in the JavaScript of my LWCs contained in a Digital Experience. My orgs do have "Lightning Web Security" enabled but there is no sign of the documented "lws" folder in the debug tools. I can set breakpoints elsewhere, but they do not trigger. I do have Lightning Components -> Debug Mode set for the Digital Experience user.

Please post if you have a reliable recipe for how to do this basic debugging or a link to a reliable recipe.

PS I notice in this Trailhead the step:

Turn off Lightning Web Security

As a temporary workaround to work with breakpoints, turn off Lightning Web Security.

  1. From Setup enter Session in the Quick Find box, and then select Session Settings.
  2. Under Lightning Web Security, uncheck the box for Use Lightning Web Security for Lightning web components.
  3. Click Save.

1 Answer 1

0

Digital Experiences aren't delivered the same way that the Lightning Experience/Lightning Web Runtime typically is. Instead, you get a massive bundle that contains the logic for all your components in compiled form. The only way to really debug this is to do a search for the component controller's class name (e.g. MyCustomComponent) using the Find All (Ctrl-Shift-F on Windows) in your browser's Developer Console. Use the "Pretty format" option to make this more legible (the {} in the Sources tab, located along the bottom bar).

Personally, in order to speed up development time, I create a scaffold that I can host inside Salesforce, which allows for a premier debugging experience. The only downside is that if the behavior is caused by a limitation of being a Digital Experience, you can't use that technique. For regular development and even most debugging, just running your component in Lightning Experience as a tab or inside a Aura App provides better mapping capability, although last time I was doing this, there was an off-by-one line mapping error that still made debugging more painful than it needed to be, since I couldn't set breakpoints on the correct lines.

Also, as a final strategy that works quite well is to use the debugger; statement. This statement will compile into your site, and will invoke the debugger in the paused state as long as the Developer Console is open. The only downside, of course, is having to continually publish to see your changes. I'd still recommend trying to debug in Lightning Experience to see if it's a DE-specific bug, or just a general typo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .