Can't Build in Turborepo with tsup

sorry for tagging you @bekacru why i can't build my better-auth client with tsup? i have already set declaration: false. here is the auth.ts
import { db } from '@repo/db';
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { username } from 'better-auth/plugins';

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg',
}),
emailAndPassword: {
enabled: true,
},
plugins: [username()],
});
import { db } from '@repo/db';
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { username } from 'better-auth/plugins';

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg',
}),
emailAndPassword: {
enabled: true,
},
plugins: [username()],
});
and the tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"composite": false,
"declaration": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
},
"include": ["**/*.ts", "**/*.tsx", ".eslintrc.cjs"],
"exclude": ["dist", "node_modules"]
}
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"composite": false,
"declaration": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
},
"include": ["**/*.ts", "**/*.tsx", ".eslintrc.cjs"],
"exclude": ["dist", "node_modules"]
}
No description
17 Replies
Imam
ImamOP3mo ago
i'll give the link of my repo if you want to see @bekacru...
bekacru
bekacru3mo ago
hey will take a look 🙂
Imam
ImamOP3mo ago
wait a second pls
bekacru
bekacru3mo ago
hmm?
Imam
ImamOP3mo ago
GitHub
GitHub - mamlzy/cms-hono
Contribute to mamlzy/cms-hono development by creating an account on GitHub.
Imam
ImamOP3mo ago
you can run pnpm i then pnpm dev and see the @repo/auth tab
Imam
ImamOP3mo ago
No description
Imam
ImamOP3mo ago
sorry to keep you waiting, i was clean up my experiment code, trying to fix this issue
bekacru
bekacru3mo ago
try 1.1.3-beta.8 you may not even need to use tsup
Imam
ImamOP3mo ago
i'll try this first
Imam
ImamOP3mo ago
still have the errors, even on 1.1.3-beta.8
No description
Imam
ImamOP3mo ago
the errors:
CJS Build start
CJS dist/server/index.js 1.47 KB
CJS dist/client/index.js 1.41 KB
CJS dist/server/index.js.map 752.00 B
CJS dist/client/index.js.map 648.00 B
CJS ⚡️ Build success in 10ms
ESM dist/server/index.mjs 415.00 B
ESM dist/client/index.mjs 399.00 B
ESM dist/server/index.mjs.map 723.00 B
ESM dist/client/index.mjs.map 612.00 B
ESM ⚡️ Build success in 10ms
CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@better-fetch/fetch'. This is likely not portable. A type annotation is necessary.
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.

DTS Build start
DTS Build failed
Error: error occurred in dts build
at Worker.<anonymous> (/home/mamlzy/Desktop/code/experiment/hono-turborepo/node_modules/.pnpm/tsup@8.3.5_jiti@1.21.7_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/dist/index.js:1541:26)
at Worker.emit (node:events:524:28)
at MessagePort.<anonymous> (node:internal/worker:267:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
RollupError: [plugin dts] src/client/index.ts: Failed to compile. Check the logs above.
CJS Build start
CJS dist/server/index.js 1.47 KB
CJS dist/client/index.js 1.41 KB
CJS dist/server/index.js.map 752.00 B
CJS dist/client/index.js.map 648.00 B
CJS ⚡️ Build success in 10ms
ESM dist/server/index.mjs 415.00 B
ESM dist/client/index.mjs 399.00 B
ESM dist/server/index.mjs.map 723.00 B
ESM dist/client/index.mjs.map 612.00 B
ESM ⚡️ Build success in 10ms
CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@better-fetch/fetch'. This is likely not portable. A type annotation is necessary.
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.

DTS Build start
DTS Build failed
Error: error occurred in dts build
at Worker.<anonymous> (/home/mamlzy/Desktop/code/experiment/hono-turborepo/node_modules/.pnpm/tsup@8.3.5_jiti@1.21.7_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/dist/index.js:1541:26)
at Worker.emit (node:events:524:28)
at MessagePort.<anonymous> (node:internal/worker:267:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
RollupError: [plugin dts] src/client/index.ts: Failed to compile. Check the logs above.
In my country, it’s already late at night, so I have to sleep. I’ll continue tomorrow! I hope you don’t get tired of helping me. By the way, thanks for your work! @bekacru hi @bekacru i have updated to version 1.1.3. Now, the only error is with the undici-types. Here is the current error for client auth:
error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
and for the server auth error is from zod:
error TS2742: The inferred type of 'auth' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.
error TS2742: The inferred type of 'auth' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.
The full errors:
ESM Build start
CJS Build start
ESM dist/client/index.mjs 399.00 B
ESM dist/server/index.mjs 415.00 B
ESM dist/client/index.mjs.map 612.00 B
ESM dist/server/index.mjs.map 723.00 B
ESM ⚡️ Build success in 9ms
CJS dist/server/index.js 1.47 KB
CJS dist/client/index.js 1.41 KB
CJS dist/server/index.js.map 752.00 B
CJS dist/client/index.js.map 648.00 B
CJS ⚡️ Build success in 9ms
CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
src/server/index.ts(6,14): error TS2742: The inferred type of 'auth' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.
src/server/index.ts(6,14): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.

DTS Build start
DTS Build failed
Error: error occurred in dts build
at Worker.<anonymous> (/home/mamlzy/Desktop/code/experiment/hono-turborepo/node_modules/.pnpm/tsup@8.3.5_jiti@1.21.7_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/dist/index.js:1541:26)
at Worker.emit (node:events:524:28)
at MessagePort.<anonymous> (node:internal/worker:267:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
ESM Build start
CJS Build start
ESM dist/client/index.mjs 399.00 B
ESM dist/server/index.mjs 415.00 B
ESM dist/client/index.mjs.map 612.00 B
ESM dist/server/index.mjs.map 723.00 B
ESM ⚡️ Build success in 9ms
CJS dist/server/index.js 1.47 KB
CJS dist/client/index.js 1.41 KB
CJS dist/server/index.js.map 752.00 B
CJS dist/client/index.js.map 648.00 B
CJS ⚡️ Build success in 9ms
CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
src/server/index.ts(6,14): error TS2742: The inferred type of 'auth' cannot be named without a reference to '.pnpm/[email protected]/node_modules/zod'. This is likely not portable. A type annotation is necessary.
src/server/index.ts(6,14): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.

DTS Build start
DTS Build failed
Error: error occurred in dts build
at Worker.<anonymous> (/home/mamlzy/Desktop/code/experiment/hono-turborepo/node_modules/.pnpm/tsup@8.3.5_jiti@1.21.7_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/dist/index.js:1541:26)
at Worker.emit (node:events:524:28)
at MessagePort.<anonymous> (node:internal/worker:267:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
src/client/index.ts(4,14): error TS2742: The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
bekacru
bekacru3mo ago
try 1.1.3
Imam
ImamOP3mo ago
i will that errors is from version 1.1.3 tho you can check my repo
Imam
ImamOP3mo ago
No description
bekacru
bekacru3mo ago
update to 1.1.4-beta.1 and add this to your tsconfig
"lib": [
"es2022",
"dom",
"dom.iterable"
],
"lib": [
"es2022",
"dom",
"dom.iterable"
],
Imam
ImamOP3mo ago
it solved, you can mark it as Solved, thank you for helping me 🙂

Did you find this page helpful?