feat(flags): share the evaluation pipeline + SvelteKit parity (2/3)#413
Draft
dferber90 wants to merge 1 commit into
Draft
feat(flags): share the evaluation pipeline + SvelteKit parity (2/3)#413dferber90 wants to merge 1 commit into
dferber90 wants to merge 1 commit into
Conversation
Lifts the per-request evaluation pipeline into src/shared/ and points both frameworks at it, so behavior is defined once. The Next-specific isInternalNextError check becomes an injected `isFrameworkError` hook on applyResult (Next passes it; SvelteKit defaults to none). - shared/evaluation.ts: evaluationCache (+ getUsedFlags accessor), getEntities + identify-args dedupe, and applyResult (cache -> override -> produce -> defaultValue/error -> report). - shared/flag-meta.ts: resolveAdapter, getDecide (with adapter validation), getIdentify, getOrigin. SvelteKit's flag() now runs through this pipeline. This is a behavior change that brings it to parity with Next — SvelteKit now: - falls back to defaultValue when decide throws or returns undefined - honors config.reportValue / adapter.config.reportValue - resolves adapter.origin (value or (key) => origin) - dedupes evaluation via the shared headers-keyed cache (replacing the per-store usedFlags/identifiers maps); createHandle's transformPageChunk reads used flags via getUsedFlags() - getProviderData emits defaultValue + declaredInCode Adds `defaultValue?` to the SvelteKit Flag type (additive) and 9 parity tests. Next's public .d.ts is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 2 of 3 · base:
shared/extraction(#412)Lifts the per-request evaluation pipeline into
src/shared/and points both frameworks at it, so behavior is defined once. The Next-specificisInternalNextErrorcheck becomes an injectedisFrameworkErrorhook onapplyResult.shared/evaluation.ts— headers-keyedevaluationCache(+getUsedFlags),getEntities+ identify-args dedupe, andapplyResult(cache → override → produce → defaultValue/error → report)shared/flag-meta.ts—resolveAdapter,getDecide(with adapter validation),getIdentify,getOriginBehavior change (version bump): SvelteKit's
flag()now runs through this pipeline, reaching parity with Next. SvelteKit now:defaultValuewhendecidethrows or returnsundefinedconfig.reportValue/adapter.config.reportValueadapter.origin(value or(key) => origin)usedFlags/identifiers);transformPageChunkreads used flags viagetUsedFlags()getProviderDataemitsdefaultValue+declaredInCodeAdds
defaultValue?to the SvelteKitFlagtype (additive) and 9 parity tests. Next's public.d.tsis unchanged.Verification
121/121 tests pass · type-check · biome ·
attwgreen ·next.d.tsbyte-identical ·@flags-sdk/vercelbuilds.🤖 Generated with Claude Code