0

I successfully packed my npm module with ng-packagr

And its working fine. The problem is, i don't seem to be able to import from any folder beneath the root folder. That is

import { ButtonModule } from "my-components/button/";

Throws the error

Module not found : Error Can't resolve "my-components/button"

But

import { ButtonModule } from "my-components";

Works fine. Please what am i missing ? Any help would be appreciated.

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116
  • ng-packagr uses `public_api.ts` to export all the public tokens / interfaces to the outside world (by default). This is why it is available from my-components. Question is why would you want to point to a particular folder / path? – smnbbrv Feb 27 '19 at 09:15
  • @smnbbrv i have a bunch of components that a buyild as a library. However, when i rely on th eroot import , the whole components get bundle along in my projects instead of just the component i intend to use. – Nuru Salihu Feb 27 '19 at 09:21
  • if you use angular cli (or webpack with properly configured tree shaking) then it is not the problem, in the production build they will be all cut off – smnbbrv Feb 27 '19 at 09:32
  • @smnbbrv i am using angular-cli now. But it have the above error when i try accessing the folders . – Nuru Salihu Feb 27 '19 at 09:35
  • @smnbbrv Do you have any idea how i can break them into indvidual built in angular-cli ? I mean how i can achieve what i want with angular-cli ? – Nuru Salihu Feb 27 '19 at 10:00
  • again, **you should not** access folders. Angular-CLI will automatically clean all unused code when you do the production build. You are doing obsolete work. Just use `import { ButtonModule } from "my-components";` and this **is** a correct way (unless you try to avoid AoT etc, but I think this is not the case) – smnbbrv Feb 27 '19 at 13:00

0 Answers0