[attest] Getting `requested module ... does not provide an export` error for my bench script

Hi 👋 I'm having TS performance issues in my project. I think the offender is mainly tRPC with Zod and Drizzle, but I wanted to analyze a bit more before changing too much of my code. So I set up a very basic bench.ts script to check how long the tRPC appRouter would take to instantiate.
import { dateCoerce } from 'utils/zod/common';
import { appRouter } from '@/app/api/trpc/server/router';
import { bench } from '@ark/attest';

bench('single-quoted', () => {
const router = appRouter;
}).types([0, 'instantiations']);
import { dateCoerce } from 'utils/zod/common';
import { appRouter } from '@/app/api/trpc/server/router';
import { bench } from '@ark/attest';

bench('single-quoted', () => {
const router = appRouter;
}).types([0, 'instantiations']);
However, I'm receiving the following error:
/app/src/_modules/db/types.ts:1
import { dateCoerce } from 'utils/zod/common';
^

SyntaxError: The requested module 'utils/zod/common' does not provide an export named 'dateCoerce'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:177:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:260:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
/app/src/_modules/db/types.ts:1
import { dateCoerce } from 'utils/zod/common';
^

SyntaxError: The requested module 'utils/zod/common' does not provide an export named 'dateCoerce'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:177:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:260:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:543:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
where utils/zod/common is monorepo typescript package, that holds some utility functions. It's declared inside my package.json
"utils": "workspace:*",
"utils": "workspace:*",
I'm using pnpm (without hoisting). But there are on type errors for VS Code if I open the bench.ts file. How can I resolve this error?
1 Reply
ssalbdivad
ssalbdivad•3w ago
That looks like a runtime error on the import. Are you running bench.ts the same way you'd run any other TS script? There's no special bench runner, so I don't think this is related to attest (e.g. try just deleting all the attest logic and just console logging that import)

Did you find this page helpful?