ts-reset icon indicating copy to clipboard operation
ts-reset copied to clipboard

Add monorepo instructions to the README

Open RhysSullivan opened this issue 2 years ago • 5 comments

Just setup ts-reset for my monorepo and found this was the most painless way to do it, updated the README to reflect how I set this up for my monorepo, this allows you to only install it once into the root package json

RhysSullivan avatar Feb 23 '23 23:02 RhysSullivan

Thanks for this solution, I just tested it and it works :)

One question though: Why is it necessary to have the reset.d.ts file inside the root? I try to avoid adding files to the package root in general to keep it more tidy. When adding a reset.d.ts file inside the package, typescript doesn't care for it. Even if I include it explicitly in the tsconfig (like with the package root file) and I have a hard time to understand it.

Edit 1 Here is a nice thread about the different ways of importing it: https://github.com/total-typescript/ts-reset/issues/30

After trying out more things I actually ended up including the reset.d.ts file in the package root tsconfig.json with "files": ["./reset.d.ts"]. With this I have the types in all our packages, cause each package has it's own tsconfig.json which extends from this package root tsconfig.json.

Edit 2

Setting it globally on the root tsconfig.json in files didn't work out, as this deactivates the automatic detection of *.d.ts files that are in the monorepo. I now switched to the solution to add a src/global.d.ts file within every package (most packages already had this even) and just added there the import '@total-typescript/ts-reset';. So in most cases, no extra file.

feedm3 avatar Mar 10 '23 12:03 feedm3

Somehow can't get it to work with Nx devtools

Tried al the above (and more) Only solution working for now is adding: import '@total-typescript/ts-reset'; to my apps/my-app/src/main.ts file (when using Angular)

the-ult avatar May 25 '23 15:05 the-ult

Edit 1 Here is a nice thread about the different ways of importing it: #30

After trying out more things I actually ended up including the reset.d.ts file in the package root tsconfig.json with "files": ["./reset.d.ts"]. With this I have the types in all our packages, cause each package has it's own tsconfig.json which extends from this package root tsconfig.json.

This did work for me across all apps and packages. In my root tsconfig: "files": ["./reset.d.ts"]

  • Extending the root config on each package.
  • Turborepo

MendyLanda avatar Jul 19 '23 13:07 MendyLanda

After playing around with some different solutions for the monorepo implementation, I also found this to be the cleanest way to make it work.

nkeil avatar Sep 09 '23 23:09 nkeil

Needed an instruction and this one worked

FleetAdmiralJakob avatar Jan 04 '24 20:01 FleetAdmiralJakob

I'm not sure about this one. It seems like the ideal solution would:

  1. Be portable. Wherever you move the packages/apps, it should not require any changes from the dev to keep ts-reset working.
  2. Not rely on implicit dependencies. With your method, it's unclear which app/package relies on the installation of ts-reset in the root of the app. This means it'll hang around like a bad smell even if all your packages migrate away from it.

I think what we should recommend is that each package/app should have a globals.ts file which imports ts-reset. In other words, exactly the same as when the package is not in a monorepo.

apps/my-app/globals.ts // ts-reset in here
packages/my-package/globals.ts // ts-reset in here

This makes each package portable, and the dependencies are clear.

mattpocock avatar May 27 '24 16:05 mattpocock