Public API and Entry Points
Design a clean library surface.
The Public API Surface
A library should expose only what consumers are meant to use. The public API is the curated set of exports; everything else stays internal. In Angular libraries this surface is defined by public-api.ts.
public-api.ts as a Barrel
public-api.ts re-exports the symbols you want consumers to access. If something is not exported here, it is effectively private, even if it exists in the source.
// projects/ui-kit/src/public-api.ts
export * from './lib/button/button.component';
export * from './lib/theme.service';
// internal helpers are intentionally NOT exportedAll lessons in this course
- Creating a Library with ng generate
- Public API and Entry Points
- Building with ng-packagr
- Publishing to npm