-
Notifications
You must be signed in to change notification settings - Fork 124
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
Discontinue the use of TypeScript project references #1934
Discontinue the use of TypeScript project references #1934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm 👍
Tested: checkout branch / individual commits
Committing / amending dosen't seem to trigger this too which is nice.
There is one case that we have not yet addressed: cleaning before automatic rebuild. To tackle this, we may need to consider two things:
Hmm this sounds quite complicated to tackle for the returns, although definitely nice to have.
I think having the checkout hook at least would be sufficient for now, since the risk comes more so from checking out others' commits. (a developer should be conscious of what files he/she deletes =P)
Relevant: microsoft/TypeScript#16057
There are some third party solutions listed in it but imo they might be a little heavy as additional file watching solutions ("best" fix would still come from the ts team)
Wdyt? @ryoarmanda @jonahtanjz
(tldr I think its not a huge pain point, at least not right now)
Sorry for the late comment! It seems like performing a git checkout via UI (in my case, using vscode's git integration) does not trigger the clean-up script from git-hook and will result in an unexpected error like this: On top of that, it seems like even if running git checkout via the command line will trigger the clean script, the error still persists May I check if this is the intended behavior? It feels pretty unwieldy in terms of development experience... is there any workaround/fixes possible? |
I think it's possible to add the build script |
👀😢 No, I only tested these though
The error seems like another issue ⬇️
For this PR, the clean script only does exactly that (clean things up), without rebuilding the backend files (which causes your error).
We can certainly add it in. Though, it comes at a slight cost (much longer checkout time). I'm personally ok with it as I like to "get most things ready" before performing git operations. Another option is this: #1877 (comment) While it dosen't solve the issue, setting up some standard npm commands (instead of But, it also risks "burning" / slowing your system due to running I think we pick one or both of these and see how things go first, revert if its too slow. Wdyt? @jonahtanjz @tlylt |
update: just tried vscode's source control tab (checking out another commit in particular), the clean script successfully runs. which operation did you try? @tlylt |
Yup, I think this should work.
My "use cases" are that
My personal take is that usually if I want to checkout to a branch, I would typically want to run markbind serve/build. Then in any case I would need to accept the wait time (either done during checkout or invoked manually). I think the last point that I want to call out is the error (see #1934 (comment)) is not exactly easy to understand/trace, some documentation/caution is perhaps required to help newcomers. |
Hmm I usually use the UI on the left sidebar. But this works for me too. Just tried checkout > existing branch + create new branch. Are you checking out to a commit before this PR? (4fd2061) If so it won't work, I think that's by design of the git hooks.
Agreed (likewise here)
But not so much for just checking-out branches. e.g. This also runs when you do But again I don't really run into this sort of situations often. Maybe @jonahtanjz has a different experience.
Yes, I think we can add in a picture of the error + meaning here https://markbind-master.netlify.app/devguide/workflow#editing-backend-features. |
Sorry, yup it works behind the scene. I didn't see any logs in the terminal and was mistaking it as not running. I guess the "error" is exactly the proof that it works because the clean-up removed the built .js files. Thanks for the clarification!
Ah TIL... because I only use the UI to discard the changes, I am not aware that we use git checkout to discard files as well. |
I mostly use checkout for changing branches/commits and rarely use to remove files. We could add the build script into the git hook for now but it may become slower as we migrate more of our backend to Typescript. Another alternative we can explore is using |
At the moment, I am also inclined to put If it happens that the build takes more time than desired (currently it takes some few seconds), or you would like to do some I also found out that the post-checkout script actually receives some parameters (ref, emphasis mine):
This opens up a possibility to do things differently when |
This looks good, I think minimally we could just look for: Though pointing out it would still fail in some edge cases like So I suppose the frontend dev workflow (or if you just want to do a quick test / edit for the backend) might be something like this:
I realised one downside for this added convenience is that it feels a little like "magic" 🎁. As a newcomer, you might wonder why "step 2 just works when I just checkout a branch, yet
Another less invasive, slightly more understadable option to this ⏫ (tsc-watch), and also building the backend in git hooks might be simply to combine the above 2 steps into one npm script (no tsc-watch which we can consider later):
I've been thinking about adding these scripts for a while (irregardless of git hooks) as it removes the need to do
Would this remove the need for building the backend files via git hooks? (though to be clear the current clear.js script is still important as discussed in #1921) We can also go with adding both in one go, and see how things turn out. Though my personal preference is to add these incrementally as needed if we feel the scripts are sufficient for now. For developing the cli app continuously (e.g. something more substantial like the versioning pr), then one of these 2 options https://markbind-master.netlify.app/devguide/workflow#editing-backend-features. |
Fwiw this is how tsc-watch would fit in in my mind:
If you like to save files every few seconds, and would prefer the process to be separate, then it'd be
|
What is the purpose of this pull request?
Resolves #1921 (follow-up to #1921 (comment))
As discontinuing project references would mean we cannot do
tsc --build --clean
anymore, this PR includes the substitute to the manual clean script and an automatic invocation of it as well.Overview of changes:
scripts/clean.js
to clean compiled TypeScript files including those that have their TypeScript sources deleted prior cleaning (for brevity, I'm calling this the "rogue" compiled files in the discussions below)clean
to run the above script.githooks/post-checkout
that runsnpm run clean
when triggeredinstall:hooks
that runs a Git command to reference.githooks
as the hooks providerinstall
that runsinstall:hooks
, which is automatically triggered whennpm install
/npm ci
has successfully installed the packagestsconfig.json
and packagecore/tsconfig.json
accordinglyAnything you'd like to highlight / discuss:
clean.js
, I addedwalk-sync
to the dependency of rootpackage.json
. This is the first package that does that, so I want to make sure that we are okay in this.tsconfig.tsbuildinfo
can be deleted manually. They do not have an impact to the build process nowtsc-watch
for the--onCompilationStarted
functionality that can run the cleaning script before the build.Testing instructions:
Proposed commit message: (wrap lines at 72 characters)
Discontinue the use of TypeScript project references
Checklist: ☑️