Questions tagged [angular-library]

Angular library is a means for building general solutions that can be adapted for re-use in different apps. They also can be published and shared as npm packages.

Angular library is a means for building general solutions that can be adapted for re-use in different apps. They also can be published and shared as npm packages. https://angular.io/guide/libraries

629 questions
106
votes
4 answers

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

I upgraded all my angular library to angular 9.0.0 using ng update and when I try to build them I got below error. Error: Unsupported private class SomeComponent. This class is visible to consumers via SomeModule -> SomeComponent, but is not…
Aniruddha Das
  • 20,520
  • 23
  • 96
  • 132
65
votes
3 answers

Include assets when building angular library

I am building a library which contains a custom icon font. However, when I build my library using ng build --prod, the assets folder is not included in the build, which means icons do not show up when using the production build. I've…
61
votes
5 answers

How to add global style to angular 6/7 library

I was trying to add global styles in the same way like in angular app, but it totally does not work. My libraries' name is example-lib, so I added styles.css to /projects/example-lib/. I added styles in main angular.json file: ... "example-lib": { …
Jaroslaw K.
  • 5,224
  • 2
  • 39
  • 65
50
votes
8 answers

BrowserslistError: Unknown version 67 of android

I have created one angular library using angular 8 and CLI 8. I am trying to build the library, but I am getting the error. ng build I have gone through some questions posted related to this error, most of them say remove node_modules…
Kaustubh Khare
  • 3,280
  • 2
  • 32
  • 48
50
votes
6 answers

'rootDir' is expected to contain all source files

I have an Angular CLI workspace containing two library projects, foo and bar. When I build the second of the two libraries, foo, the build fails with the following error: error TS6059: File '/code/projects/bar/src/lib/types.ts' is not under …
Sam Herrmann
  • 6,293
  • 4
  • 31
  • 50
47
votes
10 answers

angular 9 library publish error "Trying to publish a package that has been compiled by Ivy"

I migrated my angular 8.x.x project to angular 9.x.x and when I try to publish my library, it fails with below error npm ERR! @candiman/website@9.0.0 prepublishOnly: node --eval "console.error('ERROR: Trying to publish a package that has been…
Aniruddha Das
  • 20,520
  • 23
  • 96
  • 132
32
votes
2 answers

How to have absolute import paths in a library project?

I have a library with a workspace containing two projects, one for the library itself and one for a test application. ├── projects    ├── midi-app    └── midi-lib In the workspace tsconfig.json file I configured some @app and @lib paths: "paths":…
Stephane
  • 11,836
  • 25
  • 112
  • 175
32
votes
3 answers

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

I'm a little confused as to how im supposed to reference external npm packages in my library angular6 project. We have an internal scss library I'd like to use to style my reusable components in my library. How do i go about importing…
cobolstinks
  • 6,801
  • 16
  • 68
  • 97
26
votes
1 answer

Include "assets" in your angular 6 library

It has been weeks now, that I search for a solution. I created (with ng generate library) a library with the UI in for new webprojects here at work... in fact every component in that "template library" has the ViewEncapsulation.None set... I know…
Michael Bruyninckx
  • 738
  • 1
  • 8
  • 16
23
votes
5 answers

Keeping version numbers in sync in angular library project package.json files

When building an Angular Library application, is there an automated way to keep the root level package.json and the library application's package.json (e.g. under projects/my-library) file versions in sync when using npm version commands? When I use…
mindparse
  • 6,115
  • 27
  • 90
  • 191
22
votes
4 answers

Configuration 'production' could not be found in project 'my-lib'

I am building a library with Angular 6.1.0 ng new lib-demo ng generate library my-lib All the articles advise running the build for the library with a --prod flag like so: ng build my-lib --prod However, this throws an error Configuration…
Himanshu Arora
  • 2,368
  • 3
  • 22
  • 33
21
votes
2 answers

StackBlitz ngcc failed to run on my npm library with Ivy enabled

I have published an Angular 10 library to npm and it works fine in a local Angular 10 project with Ivy enabled but if I try and use it on StackBlitz I have to disable Ivy. https://stackblitz.com/edit/angular-ivy-tapxx5?file=tsconfig.json but working…
Adrian Brand
  • 20,384
  • 4
  • 39
  • 60
19
votes
2 answers

Add Angular Material to a custom library

I want to write my own library and reuse it in other projects, so I created a new app and generated a library there: ng new lib-collection cd lib-collection ng g library first-lib --prefix va How to add Angular Material to my library? I wanted to…
vorant94
  • 423
  • 1
  • 5
  • 16
18
votes
3 answers

angular-cli library create secondary entry point

I am trying to create what I believe is called a secondary entry point into my angular npm package. I want the following two entry points @scope/data-service @scope/data-service/models Using the angular-cli to generate the base package generates…
JoAMoS
  • 1,459
  • 3
  • 18
  • 27
18
votes
5 answers

Error encountered in metadata generated for exported symbol when constructing an angular 6 library

I'm getting the following error while performing 'ng build' from my library. I'm using Angular 6 at the moment, but I believe this error is not version…
Rafael Augusto
  • 777
  • 5
  • 14
  • 28
1
2 3
41 42