Debugging ES2017 async/await in VS Code using Source Maps
async/await
has been the most promising feature of ES2017. It allows you to write asynchronous code in more elegant way saving you from the hassles of callback. async/await
is supported from Node versions >= 8.5. However if you are writing JavaScript code targeting Node versions < 8.5, you need to set up a transpiler like Babel to convert your code compatible to your version of Node. To debug in this scenario, you need to make sure that Source Maps are generated and are linked in transpiled version generated by Babel. To do so, add following parameters in your .babelrc
file:
1
2
"sourceMaps": true,
"retainLines": true