Navigating the process of debugging TypeScript code after it has been webpacked in Visual Studio

I've configured webpack with ts-loader to transpile and bundle my various TypeScript files. Below are the configurations I am using:

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "module": "es2015",
    "lib": [ "dom", "es2015", "es2016" ],
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "preserveConstEnums": true,
    "skipLibCheck": true
  },
  "include": [
    "node_modules/@types/**/*.d.ts",
    "src/**/*.ts"
  ]
}

webpack.config.js

var path = require('path');

module.exports = {
    context: path.join(__dirname, 'src'),
    entry: { 
        app: './app'
    },
    output: {
        path: path.join(__dirname, 'dist/'),
        filename: '[name].bundle.js'
    },
    resolve: {
        extensions: ['.js','.ts']
    },
    module: {
        loaders: [{
            test: /\.ts$/,
            loaders: ['ts-loader'],
            exclude: /(node_modules|bower_components)/
        }]
    },
    devtool: 'inline-source-map'
};

My project structure consists of the following folders:

/src
/dist

In the src folder, I store my .ts files along with pre-webpack js and .map files generated by the typescript compiler through ts-loader. The dist folder contains the bundled javascript files produced by webpack. These webpacked files are referenced in my HTML pages. However, when running the project in VS and trying to set breakpoints in the original .ts files, I encounter an issue where it says "The breakpoint will not currently be hit. No symbols have been loaded for this document." How can I ensure that the source maps work correctly so I can debug in my original TypeScript code?

UPDATE: Debugging TypeScript in Visual Studio works fine with IE or Chrome without webpack. The issue arises only when webpack is involved.

Answer №1

If you're working with the angular cli, simply execute ng serve, navigate to localhost:4200 in your browser, and analyze the page. Locate webpack/src/fileyouneedtodebug, set a breakpoint, and then refresh the page.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am seeking assistance with generating a printed list from the database

Struggling for two full days to successfully print a simple list from the database. Take a look at the current state of the code: function CategoriesTable() { const [isLoading, setLoading] = useState(true); let item_list = []; let print_list; useEffect(( ...

Having trouble deploying React app on Github pages using npm run deploy

Unfortunately, I encountered an issue while trying to deploy my Color Recognition App in React JS on GitHub pages. The app uses Webpack as a bundler. System Configuration: Webpack Environment: OS: Windows 10 Node: 8.12.0 Yarn: Not Found npm: 6.4.1 Watchma ...

Ways to troubleshoot issues that arise when updating the node version

After upgrading my version, I encountered a serious error. I developed a program a few years ago using version 18.x. Now that I have upgraded node.js, I am facing some errors. Below are the error messages: ERROR in ./app/assets/scss/styles.scss (./node_mo ...

How do I retrieve a nested object element based on the value of a specific field in Mongoose?

Below is the teamModelSchema schema that I am working with. var teamMemberModelSchema = new mongoose.Schema({ "email": { "type": String, "required": true, "min": 5, "max": 20 }, "name": { "type": String ...

How can the `!` operator be utilized in MikroORM Typescript entities?

How can I declare a key in a JS object with an ! before the colon? MikroORM syntax for class @Entity() export class Post { // Using @PrimaryKey() decorator to designate primary key @PrimaryKey() id!: number; @Property({ type: "date", de ...

Essential typing techniques required for manipulating data retrieved from GraphQL

My headless CMS is responsible for generating all types in my GraphQL schema. Upon querying, I receive a result that contains an array which I can manipulate. However, when attempting to use filter, map, or find methods on the returned array, an error me ...

Exploring the process of defining and authenticating an array of objects utilizing cuid as the key and ensuring the object contains designated properties

I have a customized data set that requires validation: { "name": "Some unique name", "blocks": [ {"cj5458hyl0001zss42td3waww": { "quantity": 9, "rate": 356.77, ...

What is the most efficient way to transmit an HTML document element from a client to a server in Node JS

I am attempting to capture a snapshot of my client-side document object and send it to the Node.js server. However, when I try to convert it into a string using: JSON.stringify(document.documentElement) I encounter an issue where it becomes an empty obje ...

Retrieve the document _id by utilizing a callback function

I'm trying to retrieve the _id of an inserted document in MongoDB using a callback function in nodejs (expressJS), but I'm encountering this error: AssignmentDB.save is not a function Below is my code. Can anyone assist me with retrieving the ...

Dealing with mistakes in an Angular service

I've been grappling with error handling in Angular. I attempted to handle errors within a service, but I'm uncertain if that's the correct approach. @Injectable({ providedIn: 'root', }) export class CaseListService { public con ...

Automatically updating scrollbar for nanoscrolling

Having a nanoscroller on a data table, I encountered an issue where the scroll bar of the nanoscroller does not update when searching for data. I attempted to run a script on the input field change event, but it did not work as expected. $('input[typ ...

Utilizing JavaScript to bring JSON image data to the forefront on the front-end

In my quest to utilize JavaScript and read values from a JSON file, I aim to showcase the image keys on the front-end. To provide clarity, here's an excerpt from the JSON dataset: { "products": {"asin": "B000FJZQQY", "related": {"also_bought": ...

Is there a way to execute code after completion of all threads?

I've developed a multi-threaded web crawler that downloads a website and stores it in a database, however, this process takes around 4 minutes. In an attempt to speed up the crawling process, I implemented the node.js cluster module. Yet, I'm fac ...

I am looking to remove the drop down icon if there are no child data present in Angular 4

Is there a way to dynamically show or hide the drop-down icon depending on whether there is child data present in Angular 4? I am using rowGroup: true to group parent and child elements together. I need the drop-down icon to be hidden when there are no ch ...

Guide on setting up a route in Next.js

Recently, I developed a simple feature that enables users to switch between languages on a webpage by adding the language code directly after the URL - i18n-next. Here's a snippet of how it functions: const [languages, ] = React.useState([{ langua ...

The challenge of incorporating Laravel, Vue, and JavaScript into a Blade template

It may seem like a silly question, but I am struggling to find a solution. My goal is to load a Vue component and JS file into a blade view. When I include the following: <script src="{{ asset('js/app.js') }}"></script> <script sr ...

performing a request to Axios API with the inclusion of ${item} within the URL

I am having trouble with calling axios in Vuetify due to backticks and ${} within the URL. I believe I need to convert it into JSON format, but my attempts have been unsuccessful. Could you please provide an explanation? Here is the code snippet. Whenever ...

What could be causing my TSC to constantly crash whenever I try to utilize MUI props?

Currently in the process of converting a JavaScript project using Next.js and Material UI to TypeScript. This is a snippet of code from one of my components. Whenever I include Props as an intersection type along with MUI's BoxProps, the TypeScript c ...

Angular component unable to retrieve array data from Angular service

I've developed an Angular service that serves as a middleman for fetching data from a database. Here's the code: export class WebService { constructor(private http: Http, private datePipe: DatePipe) { this.getStatsbyDate(this.datePipe.transf ...

Using Angular's flex-layout directive alongside the ngFor directive

I am a beginner when it comes to flex-layout and I'm currently facing an issue that I need help with. Here is the problem I am encountering: https://github.com/angular/flex-layout This is my ngFor loop: <div fxLayout.xs="column"> <country ...