@hyperfrontend/builder/bundle/entries

entries

Entry-point discovery, resolution, and platform filtering primitives.

discoverEntries(projectRoot) scans <projectRoot>/src for the root index.ts plus every nested directory containing an index.ts, classifying the result into one of root, platform, feature, hybrid, or complex. resolveEntries(config, discovered) filters that list by the format-level entry and exclude patterns (exact subpaths or globs). getEntriesByPlatform(discovery, platform) and getSharedEntries(discovery) partition discovered entries by their platform hint for callers that target a specific runtime.

API Reference§

ƒ Functions

§function

discoverEntries(projectRoot: string): EntryPointDiscovery

Discovers every entry point exposed by a library project.
Scans <projectRoot>/src for the root index.ts plus every nested directory containing an index.ts. Recognized layouts include:
  • src/index.ts: root entry
  • src/browser/index.ts, src/node/index.ts: platform entries
  • src/<feature>/index.ts: feature entries
  • src/<platform>/<feature>/index.ts: nested entries (max depth 3)
Parameters
NameTypeDescription
§projectRoot
stringAbsolute path to the project root.
Returns
EntryPointDiscovery
Discovery result containing every entry point with its layout category.
Example

Discovering entries for a barrel library

const discovery = discoverEntries('/abs/path/to/libs/utils')
discovery.category   // => 'feature' | 'platform' | 'hybrid' | ...
discovery.entryPoints // => [{ exportPath: '.', ... }, ...]
§function

getEntriesByPlatform(discovery: EntryPointDiscovery, platform: EntryPointPlatform): EntryPoint[]

Returns the entry points belonging to the requested platform.
Parameters
NameTypeDescription
§discovery
EntryPointDiscoveryDiscovery result returned by discoverEntries.
§platform
EntryPointPlatformPlatform hint to filter on.
Returns
EntryPoint[]
Subset of discovery.entryPoints flagged with the matching platform.
Example

Retrieving browser entries

const browserEntries = getEntriesByPlatform(discovery, 'browser')
§function

getSharedEntries(discovery: EntryPointDiscovery): EntryPoint[]

Returns the entry points that have no platform hint (root and shared/feature entries).
Parameters
NameTypeDescription
§discovery
EntryPointDiscoveryDiscovery result returned by discoverEntries.
Returns
EntryPoint[]
Subset of discovery.entryPoints without a platform hint.
Example

Retrieving the shared / non-platform entries

const shared = getSharedEntries(discovery)
§function

resolveEntries(config: FormatEntryConfig, discoveredEntries: EntryPoint[]): EntryPoint[]

Filters discovered entry points using a FormatEntryConfig's entry and exclude patterns.
Patterns may be exact subpaths (./browser), globs (./browser/*), or arrays of either. When entry is omitted every discovered entry is considered, then exclude removes matches.
Parameters
NameTypeDescription
§config
FormatEntryConfigFormat-level entry configuration.
§discoveredEntries
EntryPoint[]Entry points returned by discoverEntries.
Returns
EntryPoint[]
Filtered entry points in their original order.
Example

Selecting only browser entries

resolveEntries({ entry: './browser/*' }, discovery.entryPoints)