Skip to content

Commit

Permalink
add debugger keyword trick
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Aug 12, 2018
1 parent 0cf15cf commit 6198cff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions _posts/debug-jsreport-in-vscode.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{{{
"title" : "Debug jsreport in vscode",
"date" : "08-08-2018 11:30"
Expand Down Expand Up @@ -64,8 +65,16 @@ Open the "data/templates/Invoice/helpers.js" and put the following line at the e
//# sourceURL=data/templates/Invoice/helpers.js
```

This change should again trigger the reload and render in the studio. However the breakpoints in "helpers.js` still won't get hit.
Then add to the desired place of a helper the keyword `debugger`.
```js
function now() {
debugger;
return new Date().toLocaleDateString()
}
```

This change should again trigger the reload and render in the studio. The vscode should start the helper debugging at the `debugger` line.

You need to open debug menu in vscode. Select "loaded scripts" pane, open "<node_internals>/data/templates/Invoice/helpers.js" and put the breakpoint there. Now make a small change like add a whitespace to the original "helpers.js" file. The jsreport reloads and renders the file and this time the breakpoint will get hit.
The debugging experience can be additionally improved by enabling the interactive vscode breakpoints. To make it working you need to open debug menu in vscode. Select "loaded scripts" pane, open "<node_internals>/data/templates/Invoice/helpers.js" and put the breakpoint there. Now make a small change like add a whitespace to the original "helpers.js" file. The jsreport reloads and renders the file and this time the breakpoint will get hit.

![vscode-debug](/img/blog/vscode-debug.png)

0 comments on commit 6198cff

Please sign in to comment.