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
and the
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()],
});
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"]
}

17 Replies
i'll give the link of my repo if you want to see @bekacru...
hey will take a look 🙂
wait a second pls
hmm?
GitHub
GitHub - mamlzy/cms-hono
Contribute to mamlzy/cms-hono development by creating an account on GitHub.
you can run
pnpm i
then pnpm dev
and see the @repo/auth
tab
sorry to keep you waiting, i was clean up my experiment code, trying to fix this issue
try
1.1.3-beta.8
you may not even need to use tsupi'll try this first
still have the errors, even on
1.1.3-beta.8

the errors:
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 and for the server
The full 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.
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.
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.
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.
try 1.1.3
i will
that errors is from version
1.1.3
tho
you can check my repo
update to
1.1.4-beta.1
and add this to your tsconfig
"lib": [
"es2022",
"dom",
"dom.iterable"
],
"lib": [
"es2022",
"dom",
"dom.iterable"
],
it solved, you can mark it as Solved, thank you for helping me 🙂