T
TanStack6mo ago
puzzled-coral

Monorepo import issues

We're currently creating a POC migrating a feature from Next.js to tanstack start. We're encountering issues with paths, e.g: Cannot resolve @repo/database. The TS compiler does not complain, since it's in package.json and installed, however, the app seems to fail. Also, it raises issues from within packages like @repo/ui which holds all the ui components. As an example, in button.tsx which is in @repo/ui we have an import to import { X } from '@repo/ui/x which is resolved just fine in Next.js, since it has the following path in tsconfig: "@repo/ui/*": ["./*"]. However, in tanstack start there seem to be issues.
10 Replies
puzzled-coral
puzzled-coralOP6mo ago
Might be useful
No description
foreign-sapphire
foreign-sapphire6mo ago
what's your app.config.ts?
puzzled-coral
puzzled-coralOP6mo ago
import { defineConfig } from '@tanstack/react-start/config'
import tsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
tsr: {
appDirectory: 'src',
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
],
},
})
import { defineConfig } from '@tanstack/react-start/config'
import tsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
tsr: {
appDirectory: 'src',
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
],
},
})
Ok so nevermind... You just told me enough haha. Needed to add ../../packages/ui/tsconfig.json to the array Thanks! However @Manuel Schiller , now I encounter some other issues. Trying to define a server function:
The inferred type of 'someRandomFn' cannot be named without a reference to '../../../../../node_modules/.pnpm/@tanstack+start-client-core@1.114.25/node_modules/@tanstack/start-client-core/dist/esm/createServerFn'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'someRandomFn' cannot be named without a reference to '../../../../../node_modules/.pnpm/@tanstack+start-client-core@1.114.25/node_modules/@tanstack/start-client-core/dist/esm/createServerFn'. This is likely not portable. A type annotation is necessary.ts(2742)
foreign-sapphire
foreign-sapphire6mo ago
needs more context ideally a complete example repository
like-gold
like-gold6mo ago
Im also interested in mono repo setup as I am trying to do something similar in pnpm
conventional-tan
conventional-tan6mo ago
I dont have this, why is that needed ?
puzzled-coral
puzzled-coralOP6mo ago
For me it didn’t resolve paths @stunaz that’s why i’ve added it
robust-apricot
robust-apricot6mo ago
Do you have any updates on this error? It seems to me that it is a communication conflict between ts and pnpm workspaces. I "solved" it disabling "sourceMap", "composite" and "declaration" from my ts.config. But I don't know if it is the best solution (probably is not)
puzzled-coral
puzzled-coralOP6mo ago
@Yam I didn’t have time to look more into it. But thanks for letting me know
conventional-tan
conventional-tan6mo ago
for me its working locally just fine without any config, but when deploying to vercel, i have this error
No description

Did you find this page helpful?