Debugging javascript code
Unit testing is the process of confirming code behaves as it should; debugging is the process of figuring out why it doesn’t. Before starting, use Ctrl + C to stop the build process and the unit-testing process. Once the processes have stopped, run the command shown in Listing 8.18 to start the webpack development server on its own. The debugger will be applied to the backend server, which will be started on its own, but relies on webpack to handle requests for client-side content.
Listing 8.18: Starting the webpack development server
npm run client
The next step is to configure the TypeScript compiler so that it generates source maps, as shown in Listing 8.19, which lets the debugger correlate the pure JavaScript being executed by Node.js with the TypeScript code written by the developer.
Listing 8.19: Enabling source maps in the tsconfig.json file in the src folder
{
"extends": "@tsconfig/node20/tsconfig...