@elliemae/feature-toggle-library
v26.3.0
Published
EllieMae Encompass Web Feature Toggles
Readme
@elliemae/feature-toggle-library
A TypeScript library for managing feature toggles across Encompass Web applications and environments.
EllieMae Encompass Web Feature Toggles
Installation
pnpm add @elliemae/feature-toggle-libraryUsage
import {
isFeatureEnabled,
FEATURES,
ENVS,
} from '@elliemae/feature-toggle-library';
// Check if a feature is enabled (uses window.__env.domain automatically)
if (isFeatureEnabled(FEATURES.E_CONSENT)) {
console.log('E-Consent is enabled');
}
// Check for a specific environment
if (isFeatureEnabled(FEATURES.E_CONSENT, ENVS.QA)) {
console.log('E-Consent is enabled in QA');
}
// Using string literals (case-insensitive)
if (isFeatureEnabled('e_consent', 'prod')) {
console.log('E-Consent is enabled in PROD');
}API
isFeatureEnabled(feature, env?)
Check if a feature is enabled for a given environment.
| Parameter | Type | Description |
| --------- | -------- | ----------------------------------------------------------------------------- |
| feature | string | Feature name (case-insensitive) |
| env | string | Optional. Environment to check. Defaults to window.__env.domain or 'PROD' |
Returns: boolean - true if enabled, false if disabled
FEATURES
Object containing all available feature toggle names as constants.
FEATURES.E_CONSENT; // 'E_CONSENT'
FEATURES.ZZ_TEST_FT_1; // 'ZZ_TEST_FT_1'ENVS
Object containing all available environment names as constants.
ENVS.PROD; // 'PROD'
ENVS.QA; // 'QA'
ENVS.LOCALHOST; // 'LOCALHOST'UNDEFINED_FEATURE
Error message thrown when undefined is passed to isFeatureEnabled().
How It Works
- Source of truth:
data/feature-toggles.csvcontains all feature toggles and their environment states - Build time:
pnpm generateconverts CSV → JSON (lib/generated/feature-toggles.json) - Runtime:
isFeatureEnabled()reads the generated JSON to check feature states
The "Negative Storage" Pattern
Features are stored with a "NO means enabled" pattern:
- If
METADATA[FEATURE][ENV]istrue→ feature is DISABLED - If
METADATA[FEATURE][ENV]isfalseor missing → feature is ENABLED
This matches the legacy @elliemae/encw-feature-toggles behavior.
Development
Setup
pnpm installCommands
| Command | Description |
| --------------- | ---------------------------------------- |
| pnpm generate | Generate JSON from CSV |
| pnpm test | Run tests (auto-runs generate first) |
| pnpm build | Build library (auto-runs generate first) |
| pnpm lint | Lint code |
Adding/Updating Feature Toggles
- Edit
data/feature-toggles.xlsx - Export to
data/feature-toggles.csv - Run
pnpm testto verify - Commit and release
Migration from @elliemae/encw-feature-toggles
This library is a TypeScript rewrite of the legacy @elliemae/encw-feature-toggles package with:
- ✅ Same API (
isFeatureEnabled,FEATURES,ENVS) - ✅ Same behavior (negative storage pattern)
- ✅ TypeScript support with full type definitions
- ✅ Modern build outputs (ESM, CJS, UMD)
Drop-in replacement - just change the import:
- import { isFeatureEnabled, FEATURES } from '@elliemae/encw-feature-toggles';
+ import { isFeatureEnabled, FEATURES } from '@elliemae/feature-toggle-library';.
