You should take a look at Angular's official documentation on modules and singleton services and more specifically the forRoot method.
The idea would be to create a module that declares your component. This module would need a forRoot() method, which gives ability to pass parameters when importing it in your application module (or any other module).
This question is really broad but the code would look like this (it's an idea and not fully functional):
Your library's module:
@NgModule({...})
export class LibraryModule {
static forRoot(service: MyService): ModuleWithProviders {
return {
ngModule: LibraryModule,
providers: [
{provide: MyService, useClass: service}
]
};
}
}
Your application module that use your library module:
import { LibraryModule } from './library/my-module.module';
import { MyService } from './services/my-service.service';
@NgModule({
imports: [
LibraryModule.forRoot(MyService)
],
})
You can have a look at some existing libraries that use this technique. Angular's own router library expect the routes as a param of the forRoot() method.
package.jsonyou can just import them as normal service.