ts-reset
ts-reset copied to clipboard
Add monorepo instructions to the README
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
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.
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)
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.tsfile in the package roottsconfig.jsonwith"files": ["./reset.d.ts"]. With this I have the types in all our packages, cause each package has it's owntsconfig.jsonwhich extends from this package roottsconfig.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
After playing around with some different solutions for the monorepo implementation, I also found this to be the cleanest way to make it work.
Needed an instruction and this one worked
I'm not sure about this one. It seems like the ideal solution would:
- Be portable. Wherever you move the packages/apps, it should not require any changes from the dev to keep
ts-resetworking. - Not rely on implicit dependencies. With your method, it's unclear which app/package relies on the installation of
ts-resetin 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.