@hyperfrontend/builder/presets

presets

Predicate factories for the IsWorkspacePackagePredicate slot on BuildConfig.

byPrefix(scope) returns a predicate that matches every package whose name starts with the supplied scope (e.g., byPrefix('@hyperfrontend/')). Use this when every workspace package shares a single scope. byNames(names[]) returns a predicate that matches an explicit list of names; reach for it when the workspace exposes packages under heterogeneous scopes or unscoped names that a prefix can't capture. Both factories return stable closures suitable for direct assignment to BuildConfig.isWorkspacePackage, opting the build into workspace-aware bundling and dependency-filtering behavior without hand-rolling the predicate.

API Reference

ƒ Functions

§function

byNames(names: string[]): IsWorkspacePackagePredicate

Builds an IsWorkspacePackagePredicate that matches an exact list of package names.
Use this preset when the workspace exposes packages under heterogeneous scopes (or unscoped names) and a single string prefix can't capture them all.

Parameters

NameTypeDescription
§names
string[]
Exact package names to treat as workspace-internal.

Returns

IsWorkspacePackagePredicate
Predicate returning true when the supplied name appears in names.

Example

Tagging an explicit set of workspace packages

const isWorkspacePackage = byNames(['@hyperfrontend/logging', 'internal-utils'])
isWorkspacePackage('internal-utils')         // => true
isWorkspacePackage('rollup')                 // => false
§function

byPrefix(scope: string): IsWorkspacePackagePredicate

Builds an IsWorkspacePackagePredicate that matches every package whose name starts with the supplied scope.
The scope is treated as a literal string prefix — pass the full scope including the trailing slash ('@hyperfrontend/') when matching scoped packages so the predicate doesn't accidentally treat @hyperfrontend-foo/x as a workspace package.

Parameters

NameTypeDescription
§scope
string
Literal prefix to match against package names.

Returns

IsWorkspacePackagePredicate
Predicate returning true when the supplied name starts with scope.

Example

Matching every workspace package by scope

const isWorkspacePackage = byPrefix('@hyperfrontend/')
isWorkspacePackage('@hyperfrontend/logging') // => true
isWorkspacePackage('rollup')                 // => false