Scopes
Archived reference: scopes were replaced by targets in v3. This page preserves the earlier configuration and explains how to migrate it. Use targets for current projects.
What changed#
In earlier versions of Featurevisor, scopes were configured inside featurevisor.config.js to generate smaller and more optimized datafiles by:
- picking features belonging to one or more tags, and
- applying a partially known context to remove redundant rules and segments.
Each target now owns that responsibility. Instead of generating a datafile per tag and an extra datafile per scope, every datafile is produced from a target definition that lives in the targets directory.
The scopes key in featurevisor.config.js is obsolete. Featurevisor has ignored it since v3, so keeping it there will not build any additional datafiles. Migrate each old scope to a target file instead.
Mapping scopes to targets#
A scope used to be defined like this:
module.exports = { scopes: [ { name: 'browsers', tag: 'web', context: { platform: 'web' }, }, ],}The same intent is now expressed as a target file:
description: Web browserstag: webcontext: platform: webBoth tag and tags selectors carry over unchanged, including the or and and shapes for selecting multiple tags. The partially known context works exactly as before: Featurevisor applies it while building the target datafile and removes any rules or segments that are no longer relevant.
Testing#
The scope property in test assertions, and the --with-scopes CLI flag, are obsolete. Assertions now choose a target directly:
feature: showBannerassertions: - environment: production target: browsers at: 10 context: {} expectedToBeEnabled: trueThe test runner builds target datafiles in memory automatically, so no extra flag is needed.
Learn more#
- targets: define the datafiles your project builds
- Tags: group features so targets can select them
- Building datafiles: how datafiles are generated from targets

