Skip to content

v5: the 'use flags' directive and the manifest of the flags - #653

Open
dferber90 wants to merge 3 commits into
standardfrom
use-flags-manifest
Open

dferber90 wants to merge 3 commits into
standardfrom
use-flags-manifest

Conversation

@dferber90

Copy link
Copy Markdown
Collaborator

The next iteration of v5 on standard, ported from standard-north-star: the 'use flags' directive and the manifest of the flags.

What it does

  • 'use flags': a module which starts with this directive exports only flags. Other exports make the manifest fail with a clear error.
  • flags/manifest: createManifest(modules) and validateFlagsManifest. The manifest uses the format of north-star (version: 1, sources, definitions sorted by key, declaredInCode, declarations). It reads only the exports and evaluates no flag.
  • flags/tooling: hasUseFlagsDirective, findFlagsModules (a scan of the project) and writeManifestFromBuild (imports the built chunks in a child process).
  • @flags-sdk/next:
    • The route app/.well-known/flags/manifest.json/route.ts with export { GET } from '@flags-sdk/next/manifest'.
    • A Turbopack loader of withFlags puts the imports of all flags modules into the route. It adds the project as a context dependency, so a new flags module shows up in next dev without a restart.
    • next build writes .next/flags-manifest.json in runAfterProductionCompile. In production, the route returns 404.
  • @flags-sdk/sveltekit:
    • flags() serves /.well-known/flags/manifest.json in vite dev.
    • After the server build, it writes .svelte-kit/output/server/flags-manifest.json: each flags module becomes its own chunk, and a child process imports the chunks.

Changes from north-star

  • No self-registration of the flags modules, because there are no sources yet. The directive only marks the modules for the manifest.
  • The flags of flag() have no type. The manifest takes it from defaultValue, or from options when all options have the same type. Otherwise the flag has no type, so type is optional in this format.
  • sources is always {}.
  • No flags manifest CLI.
  • No @flags-sdk/vite package: the SvelteKit plugin does it itself.
  • withFlags is typed with T extends object, like on north-star. Before, next.config.ts of tests/next-16 failed the type check of next build because there are two copies of next in the store. This already failed on standard.

Tests

  • Unit tests: flags 306, @flags-sdk/next 25, @flags-sdk/sveltekit 15. Types and attw pass.
  • tests/next-16:
    • Playwright 8/8, with a new spec for the dev route.
    • Manual checks: next build writes the manifest, and next start returns 404 for the route. In dev, a flags module that is added or removed shows up in, or goes away from, the manifest.
    • precomputedFlags moved to precomputed-flags.ts, because flags.tsx now has 'use flags'.
  • tests/sveltekit-e2e: a new spec for the dev manifest passes. vite build writes the file.
    • precomputed/page.spec.ts "client-side navigation, new visitor" fails, but it also fails 3 of 3 times on standard without this PR. It passes on some runs with a warm Vite cache.
  • Release dry run: flags@5.0.0-standard.1, @flags-sdk/next@0.1.0-standard.1, @flags-sdk/sveltekit@0.1.0-standard.1.

🤖 Generated with Claude Code

dferber90 and others added 3 commits November 27, 2026 12:27
A module which starts with 'use flags' exports only flags. flags/manifest
creates the manifest of the flags from the exports of these modules, and
flags/tooling has the functions for build plugins: the check of the
directive, the scan of the project, and the writer of flags-manifest.json
after a build.

Co-Authored-By: Claude <noreply@anthropic.com>
The route @flags-sdk/next/manifest returns the manifest in next dev. A
loader of withFlags puts the imports of the modules with 'use flags' into
it. next build writes the manifest into .next/flags-manifest.json. The
types of withFlags accept a next version other than the one of this
package.

Co-Authored-By: Claude <noreply@anthropic.com>
flags() serves the manifest at /.well-known/flags/manifest.json in vite
dev, and writes it into the server output after vite build.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-dev Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-growthbook Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-openfeature Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-posthog Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-reflag Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-snippets Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-statsig Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
shirt-shop Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC
shirt-shop-api Ready Ready Preview, v0 Nov 27, 2026 10:28am UTC

This branch was successfully deployed

14 active deployments
Preview – flags-sdk-dev — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-playground — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-vercel — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-reflag — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – shirt-shop — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-launchdarkly — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-openfeature — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-posthog — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-growthbook — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-statsig — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – flags-sdk-flagsmith — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
Preview – shirt-shop-api — 0a49a867 Deployed Nov 27, 2026 by vercel[bot]
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.

1 participant