refactor(flags): extract framework-agnostic shared/ module (1/3)#412
Draft
dferber90 wants to merge 1 commit into
Draft
refactor(flags): extract framework-agnostic shared/ module (1/3)#412dferber90 wants to merge 1 commit into
dferber90 wants to merge 1 commit into
Conversation
Both flags/next and flags/sveltekit implemented the same flag pipeline twice and had drifted. This lifts the parts that are framework-agnostic (or trivially so) into src/shared/, with each framework keeping thin wrappers for its differences. Zero public API change — the generated .d.ts for flags, flags/next and flags/sveltekit are byte-identical. - shared/seal.ts: sealHeaders/sealCookies/transformToHeaders (was duplicated in next/evaluate.ts and sveltekit/index.ts) - shared/overrides.ts: readOverrides + memoized decrypt; SvelteKit now gets the override memoization Next already had. Removes next/overrides.ts. - shared/precompute.ts: combine/serialize/deserialize/generatePermutations + getPrecomputed core. Frameworks keep wrappers for secret defaulting and the getPrecomputed(flag) vs getPrecomputed(key) signatures. - shared/discovery.ts: shared authorize -> 401-or-data -> version-header control flow behind createFlagsDiscoveryEndpoint. Named "shared" rather than "core" to avoid confusion with the separate @vercel/flags-core package. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR 1 of 3 · base:
mainBoth
flags/nextandflags/sveltekitimplemented the same flag pipeline twice and had drifted. This first layer lifts the parts that are framework-agnostic (or trivially so) intosrc/shared/, with each framework keeping thin wrappers for its differences.Zero public API change — the generated
.d.tsforflags,flags/nextandflags/sveltekitare byte-identical tomain.shared/seal.ts—sealHeaders/sealCookies/transformToHeaders(was duplicated innext/evaluate.tsandsveltekit/index.ts)shared/overrides.ts—readOverrides+ memoized decrypt; SvelteKit now gets the override memoization Next already had. Removesnext/overrides.ts.shared/precompute.ts—combine/serialize/deserialize/generatePermutations+getPrecomputedcoreshared/discovery.ts— shared authorize → 401-or-data → version-header control flowNamed
sharedrather thancoreto avoid confusion with the separate@vercel/flags-corepackage.Verification
112/112 tests pass unchanged · type-check · biome ·
attwall green · public.d.tsdiff empty ·@flags-sdk/vercelstill builds.🤖 Generated with Claude Code