So I've made a simple Angular library using CLI ng g library <library-name> and I'm trying to import a component from it's module. I'm importing components.module in my app module in the imports array, but I want to be able to import a components class from this module to another component, simply by writing:
import {MyComponent} from ...;
But I can't do that - my IDE is saying that this Module has no exported members with the name of my component, and when I open open it looks like this:
export declare class ComponentsModule {
}
and public_api.d.ts {
export * from './lib/components.service';
export * from './lib/components.component';
export * from './lib/components.module';
Also, here is the library-name.d.ts file:
/**
* Generated bundle index. Do not edit.
*/
export * from './public_api';
export { ApiErrorComponent as ɵa } from './lib/modals/api-error/api-error.component';
export { ConfirmationModalComponent as ɵb } from './lib/modals/confirmation- modal/confirmation-modal.component';
export { InfoModalComponent as ɵc } from './lib/modals/info-modal/info- modal.component';
My module source file before ng build:
import {NgModule} from '@angular/core';
import {ComponentsComponent} from './components.component';
import {ApiErrorComponent} from './modals/api-error/api-error.component';
import {ConfirmationModalComponent} from './modals/confirmation-modal/confirmation-modal.component';
import {InfoModalComponent} from './modals/info-modal/info-modal.component';
@NgModule({
imports: [],
declarations: [
ComponentsComponent,
ApiErrorComponent,
ConfirmationModalComponent,
InfoModalComponent,
],
exports: [
ComponentsComponent,
ApiErrorComponent,
ConfirmationModalComponent,
InfoModalComponent,
],
})
export class ComponentsModule {
}
Why doesn't it work and why I can't import any of these components? It was auto generated from Angular CLI using ng build library-name. In the package I also have few directiories beside "lib" - ems2015, esm5, fesm5, fesm2015 and bundles, but I thought that I will be able to just import my module and use any component from it wherever I like - but it look like they are private or something and the documentation on generating and building libraries using CLI is not so good.
Will apppreciate all the help.