Add @policyengine/ui-kit/legacy compatibility shim for design-system migration#28
Conversation
Mirrors the API surface of the deprecated @policyengine/design-system package so consumers can migrate via pure import-path rename: '@policyengine/design-system' → '@policyengine/ui-kit/legacy' '@policyengine/design-system/tokens' → '@policyengine/ui-kit/legacy/tokens' '@policyengine/design-system/tokens/colors' → '@policyengine/ui-kit/legacy/tokens/colors' '@policyengine/design-system/tokens/typography'→ '@policyengine/ui-kit/legacy/tokens/typography' '@policyengine/design-system/tokens/spacing' → '@policyengine/ui-kit/legacy/tokens/spacing' '@policyengine/design-system/charts' → '@policyengine/ui-kit/legacy/charts' Source files copied from policyengine-app-v2/packages/design-system, all exports carry @deprecated JSDoc pointing at the canonical ui-kit equivalents (palette, semanticFills, typography, namedSpacing, chartPalette). Original upstream tests (73 cases) ported into tests/legacy/ to catch behavior drift. Subpath exports added to package.json + Vite library entries + tsconfig include glob already covered by src/**/*. dist/ artifacts include both ESM and CJS plus .d.ts emit for each subpath. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Excellent work on this legacy compatibility shim. The approach is sound and the implementation is thorough.
What I reviewed
✅ Architecture: Vite multi-entry build config correctly mirrors all 6 subpath exports in package.json
✅ Deprecation: All legacy exports carry @deprecated JSDoc with migration guidance
✅ Tests: 292 total tests (219 existing + 73 ported from design-system)
✅ Documentation: Clear migration map in JSDoc and changelog entry
Issues found and fixed
Fixed a bug in getNiceTicks() where reversed domains (e.g., [100, 0]) would return an empty array. The function now normalizes domains by swapping min/max if needed. Added 8 comprehensive tests covering edge cases including reversed domains, negative ranges, very small ranges, and large values.
What looks good
- Package.json exports exactly match vite config entries
- All convenience exports (TEAL_PRIMARY, FONT_UI, etc.) maintained for givecalc compatibility
- Typography correctly consolidates all non-mono fonts to Inter
- Chart utilities include nice tick generation, currency/percent formatters, and Plotly config
- Test coverage is comprehensive across colors, typography, spacing, and charts
Minor notes (non-blocking)
formatCurrency(999999)returns "$1000K" instead of "$1.0M" (boundary case), but this is legacy behavior and fine for compatibility- No tests for
getNiceTickswere included originally (I added them) - The PR description mentions 73 ported tests, which is accurate
This PR achieves its goal perfectly: pure import-path migration with zero API changes required.
Summary
Mirrors the API surface of the deprecated
@policyengine/design-systempackage under@policyengine/ui-kit/legacy/*. Migrating consumers from design-system to ui-kit is now a pure import-path rename — no source code changes required.Migration map
@policyengine/design-system@policyengine/ui-kit/legacy@policyengine/design-system/tokens@policyengine/ui-kit/legacy/tokens@policyengine/design-system/tokens/colors@policyengine/ui-kit/legacy/tokens/colors@policyengine/design-system/tokens/typography@policyengine/ui-kit/legacy/tokens/typography@policyengine/design-system/tokens/spacing@policyengine/ui-kit/legacy/tokens/spacing@policyengine/design-system/charts@policyengine/ui-kit/legacy/chartsWhat's inside
policyengine-app-v2/packages/design-system/src/{tokens,charts}so values are identical.@deprecatedJSDoc pointing to the canonical ui-kit equivalent (palette,semanticFills,typography,namedSpacing,chartPalette,chartColors, etc.).tests/legacy/so any future drift will fail CI loudly..d.tsfor each subpath.package.jsonexports are added for all six paths.Why
Currently 18 PolicyEngine repos still consume
@policyengine/design-system(taxsim, uk-spring-statement-2026, cbo-baseline-tracker, missouri-transitional-benefits, housing-policy-dashboard, household-api-docs, uk-land-value-tax, policyengine-slides, impact-iran-war-living-standards, uc-uplift, policyengine-us-improvements-2026, policyengine-model, snap-bbce-repeal, nics-exemption-inactive-employees, senior-state-tax-breaks, working-Americans-tax-cut-act-, scotland-income-tax-reform, aspen-eitc-ctc). PerPolicyEngine/CLAUDE.md, ui-kit is the canonical design system; design-system is legacy. This shim lets us migrate every one of those repos with a single sed-replace per repo, no API rewrites.The plan: ship this as 0.8.0, then bulk-migrate consumers, then eventually delete
src/legacy/in a future major release once all consumers are off it.Test plan
bun run typecheckcleanbun run test— 26 files, 292 tests pass (was 219; +73 ported from design-system)bun run buildclean — verifieddist/legacy/,dist/legacy/tokens/,dist/legacy/charts/all emit ESM + CJS +.d.ts@deprecatedJSDoc🤖 Generated with Claude Code