Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to TSC Batch Docs #30284

Open
2 of 4 tasks
A-EbrahimRSA opened this issue Mar 6, 2025 · 0 comments
Open
2 of 4 tasks

Improvement to TSC Batch Docs #30284

A-EbrahimRSA opened this issue Mar 6, 2025 · 0 comments

Comments

@A-EbrahimRSA
Copy link

A-EbrahimRSA commented Mar 6, 2025

Documentation issue

  • Reporting a typo
  • Reporting a documentation bug
  • Documentation improvement
  • Documentation feedback

I'm primarily referring the TSC batch mode functionality.
https://nx.dev/showcase/benchmarks/tsc-batch-mode

Additional context or description

First off, I commend all the maintainers & creators for such a great library. It has sped up and eased my work 100X if not more.
The context I'm working with is a typescript monorepo with roughly 50 packages within it. I've currently got caching enabled and this speeds up compile times considerably as well as run-many to execute the tsc transpilation. However I am looking to squeeze even more performance out of it by leverage typescript build mode.

I've been trying to implement tsc batch mode however the current docs on the pages seem to not offer enough info:
https://nx.dev/recipes/tips-n-tricks/enable-tsc-batch-mode
https://nx.dev/showcase/benchmarks/tsc-batch-mode

I do note that the above pages does list that executing tasks in batch mode is experimental, so in the interim I'm trying to test upgrading to the tsc-batch mode on a subset of packages to confirm it works. The respective project has 6 dependencies and takes roughly 20 seconds to run without caching.

I am unsure about the following when doing this change:

  1. Do I need to remove the tsc command from my package.json file? I see many of the examples don't have a tsc script command in their package.json file
  2. If I should keep it, do I need to update it with --build for the tsc compiler to use build mode. (I've found in my testing that this is needed)
  3. Do I need to update my .tsconfig file in each project to include the incremental:true and composite:true flags on each project's config file? I've seen this is also inconsistent between some examples. I've also found I needed to update it with the rootdir:"./src" setting since the composite setting changes how some paths are calculated.
  4. Previously, since I was using tasks, I just had a nx.json file at my root level. Do I now need a project.json within each projects' base directory?
  5. Do I need to change my caching settings to specify to include the .tsbuildinfo file? When I did manually define the cache output to include this I didn't see a noticeable difference between a cache with a .tsbuildinfo file and one without a .tsbuildinfo file.
  6. How do I verify that the batch mode is working as expected? With the above config of using tsc within the package.json scripts, I can pass a --verbose flag and see that each tsc call for each project is not recompiling. However the overall execution time is basically on par with not enabling batch mode and just using a run-many command on the relevant project.

Some examples I've used to try help myself:

Basically, I'm really confused on how to actually implement the TSC Batch mode alongside caching when coming from a NX Tasks centered approach. Maybe I'm really misunderstanding the docs but it seems somewhat light in terms of exact specifics on how to implement it. Currently, caching seems much easier to implement and the Batch mode has lots of caveats which makes it difficult to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant