What are some techniques for troubleshooting an Angular Library that has been connected locally using `npm link`?

Seeking a setup that allows me to connect an Angular library on my development machine using npm link while utilizing breakpoints.

My current setup involves running

ng build --watch --configuration development
in the library and then linking the dist/library-name folder to my Angular 15 application. This works well for hot reload; any changes made in the library automatically trigger a reload of the running application.

The structure of my library component closely resembles the provided template:

@Component({
    selector: 'lib-mfe-sel',
    template: ` <p>mfe-sel works!!!!!!</p> `,
    styles: [],
})
export class MfeSelComponent implements OnInit {
    ngOnInit(): void {
        console.log('Component initialized.');
    }
}

For testing purposes, I have created an instance and manually invoked the ngOnInit method in my application component.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  ngOnInit(): void {
    const component = new MfeSelComponent()
    component.ngOnInit();
  }
  title = 'test-15';
}

When attempting to use Visual Studio Codes' Go To Definition, it correctly navigates to the source file. However, setting breakpoints results in an Unbound Breakpoint. Setting a breakpoint at component.ngOnInit(); and trying to Step Into leads to landing in the vendor.js file.

Despite having properly generated all source maps in my library, debugging seems to be impossible. Any thoughts or ideas on why this may be the case?

Answer №1

My mistake was a result of not thoroughly reading the documentation. I needed to update

projects: {
  app: {
    architect: {
      build: {
        configurations: {
          development: {
            "sourceMap": true
          }
        }
      }
    }
  }
}

to

projects: {
  app: {
    architect: {
      build: {
        configurations: {
          development: {
            "scripts": true,
            "styles": true,
            "hidden": false,
            "vendor": true
          },
        }
      }
    }
  }
}

I found myself in the vendor.js file because I forgot to use ng serve --host=127.0.0.1 instead of just ng serve.

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

Choosing the specific columns to be shown in the Kendo Angular grid

Will there be an interface available in the grid for users to select which columns are displayed, or is this a feature that will be introduced in the upcoming September release? ...

Error Alert: Missing Provider for FormGroup!

I have been working on an Angular application and recently created a Dialog component to serve as a model pop-up for user registration. Below is the code for the component: import { Component, OnInit, Inject } from '@angular/core'; import {MatDi ...

Utilize [markdown links](https://www.markdownguide.org/basic-syntax/#

I have a lengthy text saved in a string and I am looking to swap out certain words in the text with a highlighted version or a markdown link that directs to a glossary page explaining those specific words. The words needing replacement are contained within ...

Encountering a crash when trying to create a form within a subscription in Angular 2 due to the formGroup being

I have data stored in my Firebase database that I want to use in a form using FormBuilder. Although it generally works fine, I often encounter errors saying formGroup expects a FormGroup instance. Please pass one in.. What confuses me is that the error oc ...

synchronize the exchange of information and events between two components

Just joined this platform and diving into Angular 7 coding, but already facing an issue. I've set up two components along with a service. The data is fetched by the service upon clicking a button in the searchbar component, and I aim to display it i ...

Efficiently convert Map keys into a Set in Javascript without the need to copy and rebuild the set

Even though I am capable of const set = new Set(map.keys()) I don't want to have to rebuild the set. Additionally, I prefer not to create a duplicate set for the return value. The function responsible for returning this set should also have the abili ...

Utilize useState and useEffect to efficiently sort through an item list based on its current state

I am currently working on an application where I have a list of items and I need to create a details page for each item when clicked. I am facing some challenges in implementing this functionality using useState, useEffect, and typescript. I have previousl ...

Why is the mappable Observable lost after using Angular 5's HttpClient?

Why is Angular 5 httpclient causing me to lose the observable after mapping? Am I overlooking something crucial in my code? The following is my code snippet: getRepos(org:string):Observable<any>{ let params = new HttpParams().set('org&ap ...

Problem arises with connecting data in the relationship between a parent and child

Hi there, I am new to Angular 6 and currently encountering an issue with data binding. I have set up a test project with a parent-child relationship for data binding in the heading, but unfortunately, it's not working as expected. Can anyone lend me a ...

How can you modify the encapsulation of a third-party component in an Angular application?

Utilizing AngularElements with native encapsulation allows bs4 components to be used in a bs3 project. For example: @Component({ selector: 'app-my-button', templateUrl: './my-button.component.html', encapsulation: ViewEncapsulati ...

Tips for resolving aliases in tsconfig.app.json when dealing with multiple source directories in WebStorm

When it comes to generating source files, I do things a bit differently and create some of them outside of the usual src directory. Here's how my structure looks: - project - generated - $ui-services some-other.service.ts - src - ...

Troubles with Angular2 template parser when parsing HTML fragment that is W3C validated

The online W3C validator successfully parses the following document: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test</title> </head&g ...

Encountering issues when attempting to compile in Angular due to a not assignable error while creating a new interface

Trying to create a new interface for my simple project but running into a compile error. Any ideas on what I did wrong? Here's the error message: C:/Users/vashon/Angular/Angular-GettingStarted-master/APM/src/app/products/product-list.component.ts (1 ...

Invoke a component's function in a different component

Upon clicking the button, I am trying to execute the 'exportHistoryToCSV' method within this component, which in turn calls a method from another component. However, I am encountering an error. @UntilDestroy() @Component({ selector: 'd ...

I am having trouble with updating an array in React useState. Every time I try to make changes, it keeps reverting back to the initial state. What could

My current task involves managing a state array called monthlyIncidents, which contains 12 numbers that need to be updated under certain conditions. I attempted to update the elements by copying the array, modifying the specific element, and then updating ...

Error with tsc rootDir due to Docker's installation of yarn in root directory

I am encountering a problem with my node project which serves a simple "hello world" server. Everything runs smoothly when I run it locally, but when I try to run it inside Docker, a /opt/yarn-v1.21.1 folder is created which leads to a rootDir error: erro ...

Error: Unable to execute this.threadData.pipe function - Unit Testing Angular 6 with JASMIN KARMA

Currently, I am in the process of writing unit test cases for an Angular 6 component. Despite achieving a code coverage of 65%, I have encountered an error within the following code snippet that has been quite bothersome to me. Specifically, I am unsure of ...

I'm currently working on building a fresh window with Tauri 1.2, combining the powers of Rust, React, and Typescript. However, I've encountered a few

Utilizing Tauri's WindowBuilder in Rust, I attempted to create a new window. Despite successfully generating a blank window, I encountered challenges: The inability to display any content on the window The failure to close the window Being relativel ...

How to update Angular Material table dynamically after CRUD operation without needing to reload the page

Hello, I am currently using Angular (v.9) along with ASP .NET Core Web API and EF Core (v 3.1) to perform CRUD operations. I have a region component form which is used as a dialog, you can view it https://i.stack.imgur.com/6w7hO.png The HTML code for the ...

Lazy-loading modules in SSR Angular 8 applications are currently unspecified

I am currently in the process of setting up my Angular 8 application to work with server-side rendering (SSR). However, I am encountering some undefined errors in webpack when running my application using ng serve, especially with lazy-loaded modules. Ever ...