Skip to content

Commit f1e0038

Browse files
committed
fix(admin): avoid ~/modules/shared barrel in server-only router
The `~/modules/shared` barrel re-exports `useZodForm`, which imports `useForm` from `react-hook-form`. Next.js picks the server build (`react-server.esm.mjs`) for RSC / route handlers, and that build does not expose `useForm` — so the indirect import chain `adminStats.ts → shared barrel → useZodForm → react-hook-form` makes `next build` fail on any server code that reaches the barrel. Switch to a direct import from `~/modules/shared/nafSections` for the two constants we actually need (DOMINANT_NAF_SECTIONS + OTHER_NAF_SEGMENT) and document the trade-off inline so the next server consumer doesn't re-hit the same trap.
1 parent 438cfc9 commit f1e0038

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/app/src/server/api/routers/adminStats.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ import {
2323
getMultiYearGapTrendSchema,
2424
} from "~/modules/admin/stats";
2525
import { COMPANY_SIZE_RANGES } from "~/modules/domain";
26-
import { DOMINANT_NAF_SECTIONS, OTHER_NAF_SEGMENT } from "~/modules/shared";
26+
// Server-only router: import the constants directly from the internal file
27+
// instead of the `~/modules/shared` barrel, which also re-exports the
28+
// `useZodForm` client hook. The barrel pulls `react-hook-form`, and its
29+
// server build (`react-server.esm.mjs`) does not export `useForm`, so
30+
// indirect imports from server code break `next build`.
31+
import {
32+
DOMINANT_NAF_SECTIONS,
33+
OTHER_NAF_SEGMENT,
34+
} from "~/modules/shared/nafSections";
2735
import { adminProcedure, createTRPCRouter } from "~/server/api/trpc";
2836
import type { DB } from "~/server/db";
2937
import { companies, declarations } from "~/server/db/schema";

0 commit comments

Comments
 (0)