Skip to content

feat: extract feature flags into @gleanwork/docusaurus-plugin-feature-flags#416

Draft
steve-calvert-glean wants to merge 3 commits into
mainfrom
feat/extract-feature-flags-plugin
Draft

feat: extract feature flags into @gleanwork/docusaurus-plugin-feature-flags#416
steve-calvert-glean wants to merge 3 commits into
mainfrom
feat/extract-feature-flags-plugin

Conversation

@steve-calvert-glean
Copy link
Copy Markdown
Contributor

Summary

  • Extracts the bespoke feature flag system from the site into a reusable internal Docusaurus plugin package (@gleanwork/docusaurus-plugin-feature-flags), so the new glean-docs site can share the same implementation without duplication
  • Plugin follows the hybrid plugin+theme pattern (same as docusaurus-theme-glean): getThemePath() auto-registers FeatureFlag, DocSidebarItems, and FeatureFlagsProvider as @theme/* components
  • Adds a withFeatureFlags() config wrapper that replaces two IIFEs in docusaurus.config.ts for cleaner build-time flag injection and navbar filtering

What moved where

Source Destination
src/lib/featureFlags.ts packages/.../src/lib/featureFlags.ts
src/lib/featureFlagTypes.ts packages/.../src/lib/featureFlagTypes.ts
src/lib/featureFlags.test.ts packages/.../src/lib/featureFlags.test.ts
src/utils/buildTimeFlags.ts packages/.../src/build/buildTimeFlags.ts
src/utils/filtering.ts packages/.../src/build/filtering.ts
src/components/FeatureFlag.tsx packages/.../src/theme/FeatureFlag/index.tsx
src/theme/DocSidebarItems/index.tsx packages/.../src/theme/DocSidebarItems/index.tsx
Feature flag logic in Root.tsx packages/.../src/theme/FeatureFlagsProvider/index.tsx
FeatureFlagsContext in Root.tsx packages/.../src/theme/FeatureFlagsProvider/context.ts

Test Plan

  • pnpm test — 46 tests pass (all feature flag evaluation tests run from new package location)
  • pnpm build — full production build succeeds with build-time navbar filtering and __BUILD_FLAGS__ injection working
  • pnpm start — verify runtime: flags load from /api/feature-flags, <FeatureFlag> MDX component shows/hides content, sidebar filtering works, URL overrides (?ff_flagname=true) and localStorage caching function correctly

🤖 Generated with Claude Code

@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner March 21, 2026 23:43
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
glean-developer-site Error Error Apr 23, 2026 1:42am

Request Review

steve-calvert-glean and others added 3 commits April 22, 2026 18:40
…-flags

Moves the bespoke feature flag system out of the site and into a reusable
internal Docusaurus plugin/theme package so the new glean-docs site can
share the same implementation without duplication.

Changes:
- Create packages/docusaurus-plugin-feature-flags/ as a hybrid plugin+theme
  package following the docusaurus-theme-glean pattern
- Move core evaluation logic (featureFlags.ts, featureFlagTypes.ts, tests)
  from src/lib/ into the package's src/lib/
- Move build-time utilities (buildTimeFlags.ts, filtering.ts) from src/utils/
  into the package's src/build/
- Extract FeatureFlagsProvider and its React context from Root.tsx into
  src/theme/FeatureFlagsProvider/, registered automatically via getThemePath()
- Move FeatureFlag component and DocSidebarItems theme override into the package
- Add withFeatureFlags() config wrapper replacing two IIFEs in docusaurus.config.ts
- Update site to consume the plugin via @theme/* aliases (SSR-safe) and
  workspace:* dependency
- Update test mock to reference new package context export path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean force-pushed the feat/extract-feature-flags-plugin branch from c700612 to 0148db1 Compare April 23, 2026 01:41
@steve-calvert-glean steve-calvert-glean marked this pull request as draft April 29, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants