While using Angular CLI compiler, it generates source-maps (.map files) that allow debugging of the original TypeScript code in Chrome developer tools. This feature works seamlessly when developing locally with the JIT compiler/ng serve.
However, upon building a preview version for my web-server using the AOT compiler/ng build, I encounter an issue where I cannot debug the code even though all map files are present in the dist directory. The root cause being that ng build fails to export the source code .ts files to the dist folder.
The question arises - what is the purpose of having source-maps if the actual source code is missing?
Is there a way to ensure that the relevant source code (.ts) is exported to dist during ng build? Are there any CLI parameters or settings in angular.json that can facilitate this?
UPDATE
After understanding the rationale behind source-maps without source files (refer to comments), it appears that they are intended for debugging the source code on your local file system. Chrome enables adding mappings to local files for this purpose. Nevertheless, I am still seeking a method to include the original source code with my application due to various reasons:
I have encountered issues with Chrome's "add folder to workspace" functionality such as unrecognized files, ignored breakpoints, and crashes.
It might be suggested to utilize the IDE's debugger to circumvent these challenges. However, configuring WebStorm for debugging TypeScript files while attaching a Chrome debugger remains elusive. Debugging TypeScript in WebStorm is feasible with Node.js or JavaScript-Debug configurations but not with the "Attach Node.js/Chrome" debug setup, which is essential for debugging the app on a mobile device.
Moreover, other developers should have the ability to debug the application regardless of the branch or code base they are working on.
Initially, I suspected misconfigured settings causing this dilemma. But now that I grasp the purpose of Angular’s source-maps, I wonder if there exists a workaround to provide the source files. For instance, angular.json supports defining asset rules; however, attempts to leverage them for this objective proved unsuccessful.