There is a way to use the Chrome Dev Tools with ES6 modules, if you use VSCode and the Javascript Debugger for Chrome. I had some trouble to get it to work, but it was worth it.
https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
The VSCode debugger launches a new chrome window which is connected to the VSCode debugger. You can also use Chrome Dev Tools (F12) in this window as usual. It works with ES6 modules and you can set breakpoints, use the console, inspect variables, etc...
In case you have trouble to set up the debugger, this is how it worked for me:
- Go to the VSCode Debug Window (
CTRL+SHIFT+D
) -> select Add Configuration
from dropdown -> Select Chrome Launch
or Chrome Launch Legacy
to change "launch.json"
my launch.json:
{
"name": "Launch Chrome Legacy",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5000/auth/login",
"webRoot": "${workspaceFolder}",
"sourceMaps": true
},
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:5000/auth/login",
"webRoot": "${workspaceFolder}",
"sourceMaps": true
},
The key was to use "sourceMaps": true
and "url": "http://localhost:5000/auth/login"
instead of http://localhost:5000/blog"
, which is the page I actually want to debug. However, when the Debugger opens the new chrome window, my page was redirected to /auth/login
, so I had to use this url.
- You can try to disable the Preview Version of the new debugger and use the
Legacy
version instead:
Turn off Debug › JavaScript: Use Preview
in the VSCode settings.
- Then Run
Launch Chrome Legacy
from the Debug Window in VSCode
- To set breakpoints in VSCode, open the javascript module from
Loaded Scripts