feat: extract flag evaluation engine into @flaggly/engine package#3
Open
butttons wants to merge 2 commits into
Open
feat: extract flag evaluation engine into @flaggly/engine package#3butttons wants to merge 2 commits into
butttons wants to merge 2 commits into
Conversation
- Move src/engine.ts and shared schema types into new engine/ workspace package - Create engine/package.json with tsup build matching sdk pattern - Set up pnpm workspaces for root, sdk, and engine - Update all src/ imports to use @flaggly/engine via workspace:* - Move engine tests into engine/__tests__/ and update import paths
- Remove engine/schema.ts and zod dependency from engine package - Add engine/types.ts with plain TypeScript types duplicated from schemas - Restore src/schema.ts to original full zod schemas - Update all src/ imports to use local schema.ts again - Engine package only exports evaluation logic + plain types - Add exports field to engine/package.json for proper module resolution
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.
Summary
Extract the feature flag evaluation engine from the core worker into a standalone
@flaggly/enginepackage. This makes the evaluation logic reusable by the SDK and other consumers without pulling in Hono, Cloudflare bindings, or server-side schemas.Changes
@flaggly/engine(new package)engine/engine.tswith all flag evaluation logic (JEXL rules, segments, rollouts, variants)engine/types.tswith plain TypeScript types for flags, inputs, and resultsengine/package.jsonwith tsup build for ESM/CJS + declaration filesengine/tsconfig.engine.jsonmirroring the SDK build configWorkspace setup
pnpm-workspace.yamlfor root,sdk, andengine@flaggly/engine workspace:*dependency to rootpackage.jsonbuild:enginescript for building the packageCore worker (
src/)src/schema.tsto its original full Zod schemassrc/routes/api.tsto importevaluateFlagfrom@flaggly/enginesrc/routes/admin.tsto use localschema.tssrc/routes/ui.tsxto use localschema.tssrc/storage.tsto use localschema.tsTests
src/__tests__/engine.spec.tsandexample.spec.tstoengine/__tests__/../types.tssrc/__tests__/storage.spec.tscontinues testing storage layer against local schemas