I've had following react native monorepo structure for a while now
/app
package.json
/firebase
/functions
tsconfig.json
package.json
/types
package.json
/ios
/android
tsconfig.json
ios
and android
folders are respective native code, so we don't really care about them, just included here for nore complete example.
Actual projects are:
app
- app logic
firebase/functions
- backend logic
types
- interfaces of models and stores
each has package.json
file with name attribute like @MyCompany/app
. This is done for yarn workspaces and allows me to easily import things between projects.
Thus far it was good and now typescript 3 came out and I want to see if there is a way to clean this up?
At the moment I have 2 tsconfig
files, I believe I can somehow merge them into one?
Also, is there a way for me to define multiple .d.ts
files instead of my types
filder and make my model and store interfaces avaliable globally across projects somehow?
If I use typescript 3, do I need to keep yarn workspaces? These projects are not published anywhere, but deployed to different targets
Monorepos enable you to put all of your apps for a project in a single repository, share code between them, and more! And while this is not a new concept, modern tooling makes it easy to get one setup. In this article, I'll show you how you can setup a monorepo for a Node project using pnpm and TypeScript.
Lerna is a tool for managing JavaScript projects with multiple packages. Lerna manages monorepos, which can hold projects containing multiple packages within itself. Monorepos can be challenging to manage because sequential builds and publishing individual packages take a long time.
At the moment I have 2 tsconfig files, I believe I can somehow merge them into one?
You can't specify separate compilation targets from a single tsconfig
file I believe, but if you want to lower the amount of repetition across files you can define a master tsconfig.json
containing common configurations at the root of your project and have your project-specific tsconfig.json
s extend from the master.
is there a way for me to define multiple .d.ts files instead of my types filder and make my model and store interfaces available globally across projects somehow?
Yes you can certainly define as many .d.ts
files as you like anywhere you like and include them either in a tsconfig.json
or ad hoc per file using a triple-slash directive:
.d.ts
filepath as the argument.tsconfig
. If you use the "files"
or "include"
arrays to specify compiler inputs, simply add the relevant .d.ts
files to the list. If you use only the "exclude"
array, then make sure you don't exclude your .d.ts
files.You'll likely want to keep yarn workspaces around as TS 3.0 has no tooling that can replace workspaces.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With