How to make vsCode be aware of deep dependency import for the autocompletion?

Viewed 226

I've created multiple angular libraries which let me create website faster with bunch of components, eg: sidenav, cards, ...

I've created a "super library" that import all of them so I could just use npm i myWebsiteBundle to have every dependencies downloaded at once.

I've whiteListed every plugin like this in my ng-package.json file

  "whitelistedNonPeerDependencies": [
    "@myName/sidenav-conponent",
    "@myName/card-component",
  ]

But now, When I want to import it in eg. app.module.ts the vsCode import autocompletion wont find the module.


import { SidenavComponentModule } from '@myName/card-component' // <-- Have to be typed manually

imports: [
  SidenavComponentModule // <-- No suggestion
]

I know, it's recommended to download each package separately, but for my case it have to be implemented like this

Does somebody already have faced the same problem and did found a solution to it?

Edit

I did then tried to export the library inside the public-api.ts file

 export { SidenavComponentModule } from '@myName/card-component'

The autocompletion did show up, but it then failed to import the correct element.

1 Answers

You need to export the components, modules, services, etc from the library.
my-lib.ts

   // Public API Surface
    export * from './lib/my-lib.service';
    export * from './lib/my-lib.component';
    export * from './lib/my-lib.module';

    // AllowedNonPeerDependencies
    export { SidenavComponentModule } from '@myName/card-component'
Related