Skip to content

feat: extract flag evaluation engine into @flaggly/engine package#3

Open
butttons wants to merge 2 commits into
mainfrom
feat/core-sdk
Open

feat: extract flag evaluation engine into @flaggly/engine package#3
butttons wants to merge 2 commits into
mainfrom
feat/core-sdk

Conversation

@butttons

Copy link
Copy Markdown
Owner

Summary

Extract the feature flag evaluation engine from the core worker into a standalone @flaggly/engine package. 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)

  • Add engine/engine.ts with all flag evaluation logic (JEXL rules, segments, rollouts, variants)
  • Add engine/types.ts with plain TypeScript types for flags, inputs, and results
  • Add engine/package.json with tsup build for ESM/CJS + declaration files
  • Add engine/tsconfig.engine.json mirroring the SDK build config

Workspace setup

  • Add pnpm-workspace.yaml for root, sdk, and engine
  • Add @flaggly/engine workspace:* dependency to root package.json
  • Add build:engine script for building the package

Core worker (src/)

  • Restore src/schema.ts to its original full Zod schemas
  • Update src/routes/api.ts to import evaluateFlag from @flaggly/engine
  • Update src/routes/admin.ts to use local schema.ts
  • Update src/routes/ui.tsx to use local schema.ts
  • Update src/storage.ts to use local schema.ts

Tests

  • Move src/__tests__/engine.spec.ts and example.spec.ts to engine/__tests__/
  • Update engine test imports to use ../types.ts
  • src/__tests__/storage.spec.ts continues testing storage layer against local schemas

butttons added 2 commits June 19, 2026 00:49
- 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
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