ng-packagr / ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Making code shared between secondary entry points private(for internal use)

bwroblewski opened this issue · comments

Type of Issue

[ ] Feature Request

Description

I want to share code between secondary entry points of my component library. I also want the code to be only accessible from within these entry points.

One way to do that would be to create external folder and place the code there. The problem is that ng-packagr does not allow for imports outside of given secondary entrypoint. There is an error in console that says 'rootDir' is expected to contain all source files.

The other way would be to create secondary point for this shared code as well. But then it becomes accessible to anybody.

Describe the solution you'd like

The best solution would be enable one to create secondary entry points that are only accessible from within library across all its secondary entry points.

In this case, you can create a shared entry-point and mark the APIs are private through TSDOC or other conventions.

From ng-packagr view, is it really that hard to implement to have such private API? Angular for example have same format for libraries, but they can have private field (eg. platform-browser, where testing or animations are secondary entry points):

image

Having such a functionality will be better cause tsdoc or some conventions are just conventions that will not block private imports while having it private from "exports" point of view will not allow developers to import

If it is considered by ng-packagr as wrong practise, please explain why.
If not then maybe you can check if it will be possible to implement such a solution?

Having such functionality would be nice.

If it is considered by ng-packagr as wrong practice, please explain why.
If not, then maybe you can check if it will be possible to implement such a solution?"

With ng-packagr you can achieve the same thing that is implemented in the above displayed screenshot. Just create a private export file that is referenced in the index.ts. This is the same pattern that is used in the @angular/ packages.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.