How to configure packages/db properly with turborepo
Answered
Anay-208 posted this in #help-forum
Anay-208OP
So I currently have a turborepo app, with:
- apps/web
- packages/db
Now, I want to create a alias
In
I tried to use references for it, but It just didn't work.
If I just use
- a index.ts on development
- a compiled version of it i.e.
I need help configuring it properly.
I'll send the files, following this message
- 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 prodI 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
4 Replies
@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
Anay-208OP
It should get compiled to javascript during nextjs build time, right?
it depends if you want to have a
if you want then build it inside
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.