Building blocks
Targets
Targets define what goes into generated datafiles.
A target can represent an app, platform, microservice, microfrontend, or any other runtime artifact shape.
Defining Targets#
Create target files in the targets directory:
description: Web app datafileOnly description is required.
If no extra information is provided, the target will include all features.
Generated datafile will be available at datafiles/featurevisor-web.json for this target. If you have environments configured, the datafile will be available at datafiles/production/featurevisor-web.json for the production environment.
Tags#
Target tag selects features matching one tag:
description: Web apptag: webUse tags when a target needs a multi-tag selector:
description: Mobile appstags: or: - ios - androidSupported shapes:
tag: "web"tags: ["web"]tags: { or: ["web", "mobile"] }tags: { and: ["web", "checkout"] }
tag and tags are mutually exclusive. If both are omitted, the target includes all non-archived features.
Features#
Use includeFeatures and excludeFeatures to select features by key. Patterns use glob-like * wildcard matching. A single * can match any number of characters. Empty patterns, surrounding spaces, and repeated ** wildcards are rejected.
description: Checkout datafileincludeFeatures: - checkout* - shared.navigationexcludeFeatures: - checkout.internal*Exclusions take precedence over inclusions. If includeFeatures is omitted, all features are candidates. To state that explicitly, * can be used directly:
description: All featuresincludeFeatures: "*"Feature and tag selectors are combined with AND semantics. A feature must match both selectors to be included:
description: Web checkout featurestag: webincludeFeatures: - checkout*In this example, a checkout feature without the web tag is not included, even though its key matches checkout*.
Tag arrays and and or or tag groups must contain at least one tag.
Context#
Target context represents values known at build time. Featurevisor applies this context while building the target datafile and removes redundant rules or segments where possible.
description: Chrome userstag: webcontext: browser: chromeBuild Output#
npx featurevisor build writes one datafile per target and environment:
datafiles/staging/featurevisor-web.jsondatafiles/production/featurevisor-web.jsonProjects without environments write directly under datafiles:
datafiles/featurevisor-web.jsonNested target files keep their directory structure:
targets/apps/admin.ymldatafiles/apps/featurevisor-admin.jsonTesting#
Feature assertions can optionally choose a target:
feature: checkoutassertions: - target: web environment: production at: 50 context: userId: "123" expectedToBeEnabled: trueThe test runner builds target datafiles in memory automatically.
CLI selection#
Targets can be selected optionally in commands that build, inspect, test, or evaluate datafiles:
$ npx featurevisor build --target=web --target=mobile$ npx featurevisor test --target=web --target=mobile$ npx featurevisor evaluate --target=web --feature=checkout --context='{"userId":"123"}'$ npx featurevisor benchmark --target=web --feature=checkout --context='{"userId":"123"}' --n=1000$ npx featurevisor assess-distribution --target=web --feature=checkout --context='{}' --populateUuid=userId --n=1000$ npx featurevisor list --features --target=web --target=mobile$ npx featurevisor info --target=web --target=mobile--target is repeatable. Runtime commands process each selected target datafile independently. Without --target, these commands keep their regular project-wide behavior. Normal builds build every target, while build --json and build --print accept at most one target.

