From d614be4747d54b8544d8208c5dcd4d928f30326f Mon Sep 17 00:00:00 2001 From: jhodgkin Date: Sun, 12 Jul 2026 23:04:52 -0600 Subject: [PATCH] fix: mac-oui-lookup ESM/CJS interop crash on startup Named import of a CommonJS module's export crashed the whole process at boot (SyntaxError, not caught by tsc since it's a runtime module resolution behavior, not a type error). Verified by actually running the built output with node this time instead of trusting tsc alone. Co-Authored-By: Claude Sonnet 5 --- apps/api/src/routes/devices.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/devices.ts b/apps/api/src/routes/devices.ts index bb9e71b..157e2df 100644 --- a/apps/api/src/routes/devices.ts +++ b/apps/api/src/routes/devices.ts @@ -1,6 +1,11 @@ import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify"; import type Database from "better-sqlite3"; -import { getVendor } from "mac-oui-lookup"; +// mac-oui-lookup is CommonJS; Node's ESM interop doesn't reliably expose its +// named exports (crashed the whole process on startup with +// "Named export 'getVendor' not found" despite working fine under +// require()) -- import the default and destructure instead. +import macOuiLookup from "mac-oui-lookup"; +const { getVendor } = macOuiLookup; import { getRecentDevices, setDeviceLabel, clearDeviceLabel, type DeviceRow } from "../db/index.js"; async function requireAuth(req: FastifyRequest, reply: FastifyReply) {