How to have absolute import paths in a library project?

The paths mapping you establish in your tsconfig.json is purely a compile-time mapping. It has no effect on the code generated by the TypeScript compiler. Which is why you have a failure at run time. That’s something that has been reported to the TypeScript project, suggesting that tsc should automatically translate module paths in emitted … Read more

What is the proper way to use a dependent npm package in angular 6 library project?

It looks like adding the package name to a “whitelistedNonPeerDependencies” collection in the ng-package.json file will resolve this build issue. I’m still not sure what the best practice is here though. Should we create angular libraries that have dependancies on other npm packages or is it best to only have peerDependancies? ng-package.json file: { “$schema”: … Read more

‘rootDir’ is expected to contain all source files

This looks like the problem that is occurring due to the import types which was introduced in TypeScript 2.9. When emitted these are not being rewired properly see line 3. dist/bar/lib/bar.component.d.ts(5,11): export declare class BarComponent implements OnInit { private barService; list: import(“projects/bar/src/lib/types”).Item[]; constructor(barService: BarService); ngOnInit(): void; } In the above emitted dts, list: import(“projects/bar/src/lib/types”).Item[]; should … Read more

BrowserslistError: Unknown version 67 of android

The thing that solved it for me was running npx browserslist –update-db in project root. This made changes to package-lock.json updating versions of caniuse-lite. To give some context, I landed on this question because I was getting this error: Compiling TypeScript sources through ngc ERROR: Unknown version 80 of android An unhandled exception occurred: Unknown … Read more

Include assets when building angular library

As already said, angular library now support assets since the v9.x of angular. But it isn’t well explained on their website. To make it work you’ll have to: Add an assets folder at the root of your library project Add “assets”: [“./assets”], into the ng-package.json file of the library { “$schema”: “../../node_modules/ng-packagr/ng-package.schema.json”, “dest”: “../../dist/icon”, “assets”: … Read more

How to add global style to angular 6/7 library

I have a workaround for this. Just create the root component of your library without view encapsulation and all its styles will be then global. my-library.component.ts import { Component, OnInit, ViewEncapsulation } from ‘@angular/core’; @Component({ selector: ‘lib-my-library’, templateUrl: ‘./my-library.component.html’, styleUrls: [‘./my-library.component.scss’], encapsulation: ViewEncapsulation.None }) export class MyLibraryComponent implements OnInit { constructor() { } ngOnInit() { … Read more

This class is visible to consumers via SomeModule -> SomeComponent, but is not exported from the top-level library entrypoint

This error happens if any component is exported in NgModuleand not included in your public_api.ts, Angular 9 will throw an error now. This error was not coming in Angular 8 but after upgrading to Angular 9 it started showing. If you exported any service, module or component, etc in NgModule make sure to include them … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)