When you have serveral highly coupled projects which you want to organize them together, you can consider a monorepo.
Yarn (1.x) provide the works...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for the nice article. Wondering if you also have experience of implementing hot reload with TS composite approach? For the context, I am particularly interested at NextJS hot reload when shared module (aka package or workspace) updated. Thanks in advance.
I'm not working with NextJS before, but I don't think they going to support this.
github.com/vercel/next.js/issues/8708
Great article. Can you please help me with this error:
Could not find a declaration file for module '@my-organisation/common'
. I followed your article to the teeth but can't seem to find a solution to this issue.You can check the node_modules folder first to make sure
@my-organisation/common
existed. Somehow after yarn install / update some packages just "disappear". If so, you can do ayarn install --force
to force yarn install again.In my case I checked an exist inside the
node_modules
, but without thedist
folder.shared package tsconfig.json:
and shared package.json:
Do you know why this can happen? Thanks!
@t7yang I updated your example from typescript 3.8.3 to 4.9.5 and is not working either. Do you know how to fix it for TypeScript v.4.9.5?
have you run the
build
cmd? you need to build at least once to generate thedist
folder. the final solution is run thetsc
in yourshared
folder.Thanks!
For those that get an issue with
Cannot find module "shared" or its corresponding type declarations
when it is not yet built when you try to build the backend... I had this in my base config:"lib": ["es6", "es2015"],
. Changing it to"lib": ["ESNext"],
fixed the issue.This is my go-to, quick guide to setting up TypeScript in a monorepo. Thank you
Do you have insights on how to dockerize / deploy such a monorepo? How would you setup the docker files?
You can reference to this article xfor.medium.com/yarn-workspaces-an...
Great read man! Might also be worth mentioning here that projectReferences are a thing - helps speed up building too.
Sounds pro! Thanks. In the following article, I consider the same topic, but from the aliases issue perspective: webman.pro/blog/how-to-setup-types....
Thanks for the article! Wondering why you didn't need to add the "shared" package as a dependency in the package.json of "backend"?
That because the "node module resolution rule".
node will keep finding upward until found or failed.