Next.js Discord

Discord Forum

How to configure packages/db properly with turborepo

Answered
Anay-208 posted this in #help-forum
Open in Discord
Avatar
So I currently have a turborepo app, with:
- apps/web
- packages/db

Now, I want to create a alias @package/db.
In tsconfig.json
I tried to use references for it, but It just didn't work.
If I just use paths, I m unsure if it'll be efficient solution, as I want to use:
- a index.ts on development
- a compiled version of it i.e. dist/index.js on prod

I need help configuring it properly.

I'll send the files, following this message
Answered by joulev
@package/db is the package name, not an alias. so you treat it like any external packages:

* @package/db listed as a dependency in package.json
* no need of any tsconfig absolute path shenangians
* you can still import from @package/db the same way you would import from, say, @t3-oss/env-nextjs

a sample turborepo monorepo: https://github.com/CS3219-AY2425S1/cs3219-ay2425s1-project-g37
View full answer

4 Replies

Avatar
@package/db is the package name, not an alias. so you treat it like any external packages:

* @package/db listed as a dependency in package.json
* no need of any tsconfig absolute path shenangians
* you can still import from @package/db the same way you would import from, say, @t3-oss/env-nextjs

a sample turborepo monorepo: https://github.com/CS3219-AY2425S1/cs3219-ay2425s1-project-g37
Answer
Avatar
It should get compiled to javascript during nextjs build time, right?
Avatar
it depends if you want to have a dist/index.js or not. i wouldn't want.

if you want then build it inside @package/db in a build script. but if your apps are written in typescript i would just use typescript directly, no need to compile to js.