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

add ability to have multiple tsc jobs running / watching for mono rep… #46

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

benfc1993
Copy link
Contributor

This allows for multiple watch processes to be running simultaniously.
It will only run one per tsconfig project. This will allow for mono repo projects to use watch across all sub repos. This does not change any existing functionality.

running TSC in an open buffer will find the nearest tsconfig file upwards. and if there is no process currently running against that project it will start one and log the job id. This can then be checked against on subsequent attempts to run tsc if it is in watch modAe.

I have also added a :TSCStop usrcmd to allow stopping all watching processes.

@dmmulroy
Copy link
Owner

Does this have any impact on users who don't enable the watch option? Is it also possible to run this in non-watch mode and have tsc.nvim find all of the monorepo projects and do a "one-shot" run on them?

@dmmulroy dmmulroy added the needs reporter action The issue or PR is waiting on action from the reporter/author label Mar 29, 2024
@benfc1993
Copy link
Contributor Author

Behaviour will not change for non watch users. It will still find the closest tsconfig when :TSC is run.

I like the idea of having this able to find all tsconfig files. As it could then run the job for each file found.

Would you want this to work for watch and non watch? So run :TSC in the root of a monorepo it should run for all tsconfigs no matter whether the watch flag is passed?

@dmmulroy dmmulroy removed the needs reporter action The issue or PR is waiting on action from the reporter/author label Mar 31, 2024
@dmmulroy
Copy link
Owner

Yeah I think that would be desirable behavior, maybe we use a monorepo flag in the config to enable rather it being the default (unless tsc itself does this by default and tsc.nvim just isn't handling it correctly)

@benfc1993
Copy link
Contributor Author

Unfortunately tsc cli doesn't handle mono repos natively, suggested and rejected a few years ago. I do have a solution in the works, I'll get this working then make sure it can be put behind a flag. It will automatically find your tsconfigs and run a process per. I need to do some benchmarking on larger codebases to validate this not being too heavy but as they run in separate processes I don't think it will be much more overhead than running one.

I'll get it committed as soon as I can.

@dmmulroy
Copy link
Owner

dmmulroy commented Apr 5, 2024

Thanks @benfc1993, super appreciate your thought, time, and contributions 💜🙏

@benfc1993
Copy link
Contributor Author

Okay so old behaviour is completely maintained, the new mono repo behaviour is behind the run_as_monorepo flag. I've listed the behaviour below to check you're good with the behaviours. I've limited the running tsc processes to 20, my machine was able to run more but I noticed a definite dip in performance after 20. However I can't imagine it being a real world consideration.

  • run_as_monorepo = false
    • auto start false | watch false
      • When :TSC is ran tsc will run once using the closest tsconfig searching upwards
        • if the cwd doesn't contain a tsconfig at the root the user will need to open a buffer for a file at the same level or below the tsconfig file ( This matches current behaviour )
    • auto start false | watch true
      • When :TSC is ran with tsc runs in watch mode using the closest tsconfig searching upwards.
        • if the cwd doesn't contain a tsconfig at the root the user will need to open a buffer for a file at the same level or below the tsconfig file ( This matches current behaviour )
      • if TSC is run in some other project in the same instance of nvim the other job will be stopped and a new one started relative to the currently open buffer
    • auto start true | watch true
      • When a buffer is opened to a ts file tsc will start using the closest tsconfig file searching upwards.
      • if a buffer is opened in the same instance of nvim but is part of another tsconfig project the original process will stop and a new one start for the buffers closest tsconfig file
  • run_as_repo = true
    • auto start false | watch false
      • When :TSC is ran in the nvim instance it will find all tsconfig instances and run a one time tsc job for each one
    • auto start false | watch true
      • When :TSC is ran a tsc process in watch mode is started for every tsconfig project in the CWD. Whenever a tsc process sends to stdout the errors will be updated
    • auto start true | watch true
      • When a ts buffer is opened the above is triggered

Let me know 👍

@dmmulroy
Copy link
Owner

dmmulroy commented Apr 8, 2024

Will take a look tonight or first thing tomorrow morning! Thanks for the being so thorough and detailed.

Copy link
Owner

@dmmulroy dmmulroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you so much @benfc1993 - can I buy you a coffee (venmo or something similar?0

@dmmulroy dmmulroy merged commit 2576637 into dmmulroy:main Apr 9, 2024
1 check passed
@benfc1993
Copy link
Contributor Author

I already have the best benefit of this great plugin. Thank you for all your work on making it to begin with.

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

Successfully merging this pull request may close these issues.

2 participants