|
| 1 | +--- |
| 2 | +id: package-setup |
| 3 | +parent: tn-forms-v4 |
| 4 | +created: 2026-03-07T20:00:00Z |
| 5 | +priority: 1 |
| 6 | +status: not_started |
| 7 | +branch: feature/v4 |
| 8 | +--- |
| 9 | + |
| 10 | +# Package ships submodule architecture with separate entry points for core and react |
| 11 | + |
| 12 | +The `@thinknimble/tn-forms` package (v4) uses package.json `exports` field for subpath imports. Core utilities (Zod-only) are importable without React. React/Formik hooks are a separate entry point with their own peer deps. |
| 13 | + |
| 14 | +## Success Criteria |
| 15 | + |
| 16 | +- `package.json` version is `4.0.0-beta.1` |
| 17 | +- `package.json` `exports` field defines three entry points: |
| 18 | + - `"."` → `dist/index.js` (re-exports core + react) |
| 19 | + - `"./core"` → `dist/core/index.js` (Zod utilities only) |
| 20 | + - `"./react"` → `dist/react/index.js` (React + Formik hooks) |
| 21 | +- Source structure: |
| 22 | + - `src/core/` — all framework-agnostic utilities |
| 23 | + - `src/react/` — all React/Formik hooks |
| 24 | + - `src/index.ts` — barrel re-export of both |
| 25 | +- Peer dependencies: |
| 26 | + - `zod` — required by core |
| 27 | + - `formik`, `react`, `zod-formik-adapter` — required by react, marked as optional peers for core-only consumers |
| 28 | +- `peerDependenciesMeta` marks `formik`, `react`, and `zod-formik-adapter` as `optional: true` |
| 29 | +- Old v3 source files (`src/forms.ts`, `src/validators.ts`, `src/interfaces.ts`, `src/types.ts`, `src/utils.ts`, `src/custom-types/`) are removed |
| 30 | +- `email-validator`, `luxon`, `libphonenumber-js`, `@thinknimble/tn-utils`, `babel-loader`, `install` are removed from dependencies |
| 31 | +- `tsup` config builds all three entry points with correct output paths and declaration files |
| 32 | +- `import { createFormConfig } from '@thinknimble/tn-forms/core'` works without React installed |
| 33 | +- `import { useFormField } from '@thinknimble/tn-forms/react'` works when React + Formik are installed |
| 34 | +- `import { createFormConfig, useFormField } from '@thinknimble/tn-forms'` works as barrel import |
| 35 | +- TypeScript builds cleanly, all entry points have `.d.ts` files |
0 commit comments