2

We try to create a components library. These components are mainly wrappers around ng-lightning components.

We generated the lib project using Angular CLI.

The fact is we encounter errors when building the lib: Cannot determine the module for class NglBadge in /testApp/node_modules/ng-lightning/badges/badge.d.ts!

This error occurs for every single component of ng-lightning.

Here is how we imported ng-lightning in our library module:

import { NgModule } from '@angular/core';
import { SomeLibComponent } from './some-lib.component';

import { NglModule } from 'ng-lightning/ng-lightning';

@NgModule({
  imports: [
    NglModule.forRoot(),
  ],
  declarations: [SomeLibComponent],
  exports: [SomeLibComponent]
})
export class SomeLibModule { }

There is SomeLibComponent:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'lib-some-lib',
  template: `
    <ngl-badge type="default">Default</ngl-badge>
  `,
  styles: []
})
export class SomeLibComponent {

  constructor() { }

}

What can I do from our library side to be able to use ng-lightning in our components?

It seems like an AOT error but I cannot find a way to use some third party library components/modules within our lib without triggering errors.

Here is a repro repository. It's quite difficult to put it on stackblitz or other since they doesn't offer the lib build.

https://github.com/blackholegalaxy/lightning-lib-error/blob/master/projects/some-lib/src

BlackHoleGalaxy
  • 9,160
  • 17
  • 59
  • 103
  • Pointing to a github repo is not what I would call an MVCE. Also, your repo is a simple empty angular app. – Deblaton Jean-Philippe May 28 '18 at 20:02
  • Hi! This repo is not empty the lib is there with proper import. I can extract some part of the code in the question though. Creating a repro is not quite easy since stackblitz or other doesn't actually offer the option to build an angular CLI lib. – BlackHoleGalaxy May 28 '18 at 20:08
  • My bad, I thought it would have been in src. I did not know angular 6 provided a new way to create libraries. Did you use this way : https://github.com/angular/angular-cli/wiki/stories-create-library ? – Deblaton Jean-Philippe May 28 '18 at 20:12
  • Yes I did exactly the recommended Angular CLI way. The fact is importing ngLightning module triggers this (I guess) AOT error when building the library using `ng build some-lib` (which does build the lib and not the project itself) – BlackHoleGalaxy May 28 '18 at 20:13
  • I think you need ng-lightning into your peer dependancies – Deblaton Jean-Philippe May 28 '18 at 20:16
  • I tried to add in in peer dependencies, dependencies, in the lib, and in the app without more success. – BlackHoleGalaxy May 28 '18 at 20:18

0 Answers0