Thursday, May 24, 2018

Install Chrome under WSL

Even though WSL on Windows 10 is great at giving engineers a 'Nix-like environment on a Windows machine to develop, build and test; I ran into an issue where my Karma tests were failing due to the inability to find a suitable browser to execute the test suite one. I found some help online to help with installing a Chrome directly under the WSL. Below are the steps i used:

# assumes you have ubuntu-desktop installed which includes stock libpulse
sudo add-apt-repository ppa:therealkenc/wsl-pulseaudio
sudo apt-get update && sudo apt-get upgrade
# Download the stable or development Chrome .deb package - dev if you want headless functionality
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt -f install # probably
wget https://github.com/therealkenc/libudev-stub/releases/download/v0.9.0/libudev-stub-0.9.0-WSL.deb
sudo dpkg -i libudev-stub-0.9.0-WSL.deb # doing this **last** is important
view raw install.sh hosted with ❤ by GitHub

Thursday, April 26, 2018

Debugging on WSL: Breakpoint ignored because generated code not found(source map problem?)


VSCode's support for debugging Typescript-based projects is really second to none in my opinion,  so much so that i made the switch from Atom.  Atom, though, is still is my goto editor for all my Terraform & other configuration-related projects.  Back to the topic at hand, debugging a React app on my Windows 10 machine with WSL enabled, my breakpoints were not triggered due to  'missing' source maps, even though the tsconfig.json had source maps generation enabled during transpilation.  I had followed the debug configuration setup described here.

Solution:
It turns out that running the application/debugging under the WSL,  this extra property is needed to be added to launch.json in order for the source maps to be found: sourceMapPathOverrides.
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug Project",
"url": "http://localhost:3000",
"sourceMaps": true,
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"/mnt/c/repos/path/to/project*": "${workspaceFolder}/*"
}
}
]
}
view raw launch.json hosted with ❤ by GitHub