-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Speed up TypeScript projects #5903
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
😞 AppVeyor failed with:
I'm assuming that it is not related to this PR. |
That error actually occurs on purpose and is caught. :-) |
@Timer I'm not sure if I understand. AppVeyor is failing as test is NOT expecting that it should fail on purpose. |
Hm, it should be running this code: create-react-app/tasks/e2e-simple.sh Lines 218 to 237 in 81c0cd4
Ensuring the build fails but tests continue: Is this not working correctly? |
Deploy preview for gallant-davinci-8f9bd9 failed. Built with commit 75400fd https://app.netlify.com/sites/gallant-davinci-8f9bd9/deploys/5c06a1e2e470852f41aa6c16 |
TypeScript formatter now supports messages from TSLint. (@ianschmitz Should make master...ianschmitz:tslint easier) |
|
Not sure how to fix the failing checks as AppVeyor is failing due to 60 minutes limit for this repo and Netlify details just redirects to the 404. Anyway, I think that PR is ready for a review. |
Appveyor has been broken for a while so don't worry about that. And Netlify is just to preview docs changes. |
I'm taking a short break from open source to finish my project so hopefully another person can review this |
Hey @deftomat. Thanks for the PR! It's looking really good so far. I'm hoping I'll have time to give it a spin this weekend. |
We need to make sure this works with |
Yes, definitely. I just discovered that for me, it works for 80% of times with @mikew I really appreciate that you are trying to fix this but could you explain to us what needs to be changed and why. Just a information that your branch has a correct behavior is not really helpful. Anyway, I thing that we need to add more tests 🤔 |
I am using plain old What my changes do is notify the hot dev client that async type checking is happening, which tells it to not hide the error overlay after hot changes have been applied. This has a downside of not clearing the errors when everything has been fixed. So another message is sent when that happens to explicitly hide the error overlay. Those changes are in mikew@f0e1b1b and mikew@a32a163. The rest of the commits are less important but deal with handling console output better from the two log streams. |
@mikew What about this 321d960 ? Turns out that there is already the This actually makes sense as we are handling dev-server messages in an async way with no queue. Unfortunately, until now, this "issue" sleeping in CRA for a months didn't show up. (I'm "blaming" you @johnnyreilly 😉 You guys just make it too fast 👍) |
If it's really that fast now, should we add this async complexity? |
I'll take that! 😊 |
@Timer Well, we will never be sure that it is always that fast. As mentioned by @johnnyreilly, for him, it could still took 2 seconds in large project. I think that when we have an opportunity to be sure, that TypeScript will not slow down anyone, then I think we should do it. Also, after 2 months, it turns out that the added complexity is just 2 IFs in |
So does it work "perfectly now", or is there still an edge case? If this is ready, I can give it a test. |
I think that it finally works as expected. |
As @deftomat mentioned, it's not a lot of complexity. And it opens the door for these async errors / warnings for other plugins, which might be a win down the line. But yeah, the real gains are from using the incremental API, which works without
It's working as expected for me. |
I'd ❤️ this to be merged.... |
I'll give it another spin tomorrow night, and barring any glaring issues we will get it in. Thanks for your patience! |
Thanks everyone for your help! I gave it a spin with a couple of my projects and it seems to be working really nice. TypeScript is now super fast! I'll see if we can cut a release in the next day or two. 🎉 |
v2.1.4 is now out! |
As a lot of [people](https://hackernoon.com/why-i-no-longer-use-typescript-with-react-and-why-you-shouldnt-either-e744d27452b4) is complaining about TypeScript performance in CRA, I decided to enable `async` mode in TypeScript checker. These changes basically brings the JS compilation times to TS projects. So, recompilation took less than 1 second instead of 3 seconds in medium size project. The problem with async mode is that type-errors are reported after Webpack ends up recompilation as TypeScript could be slower than Babel. PR allows to emit files compiled by Babel immediately and then wait for TS and show type errors in terminal later. Also, if there was no compilation errors and any type error occurs, we trigger a hot-reload with new errors to show error overlay in browser. Also, I wanted to start a discussion about `skipLibCheck: false` option in default `tsconfig.json`. This makes recompilations really slow and we should consider to set it to `true` or at least give users a big warning to let them know that it could be really slow. The following video is showing the updated workflow with a forced 2.5 second delay for type-check to give you an idea how it works. ![nov-26-2018 15-47-01](https://user-images.githubusercontent.com/5549148/49021284-9446fe80-f192-11e8-952b-8f83d77d5fbc.gif) I'm pretty sure that PR needs some polishing and improvements but it should works as it is. Especially a "hack" with reloading the browser after type-check looks ugly to me. cc @brunolemos as he is an initiator of an original TypeScript PR. Should fix facebook#5820
This reverts commit 5ce09db.
Hey @johnnyreilly. Yes that's correct we've temporarily reverted this PR. I mistakenly published The best short term solution was to publish a newer patch version to revert these changes so downstream consumers of |
Great - thanks for clarifying! |
My day today: Typescript compiling slooooow..... Typescript compiling fast!!!.... Typescript compiling slooooow. |
This reverts commit 544a594.
So when is this PR gonna be merged into master again :( |
@jakobthomasson See #6406 for any progress |
As a lot of people is complaining about TypeScript performance in CRA, I decided to enable
async
mode in TypeScript checker.These changes basically brings the JS compilation times to TS projects. So, recompilation took less than 1 second instead of 3 seconds in medium size project.
The problem with async mode is that type-errors are reported after Webpack ends up recompilation as TypeScript could be slower than Babel. PR allows to emit files compiled by Babel immediately and then wait for TS and show type errors in terminal later. Also, if there was no compilation errors and any type error occurs, we trigger a hot-reload with new errors to show error overlay in browser.
Also, I wanted to start a discussion about
skipLibCheck: false
option in defaulttsconfig.json
. This makes recompilations really slow and we should consider to set it totrue
or at least give users a big warning to let them know that it could be really slow.The following video is showing the updated workflow with a forced 2.5 second delay for type-check to give you an idea how it works.
I'm pretty sure that PR needs some polishing and improvements but it should works as it is. Especially a "hack" with reloading the browser after type-check looks ugly to me.
cc @brunolemos as he is an initiator of an original TypeScript PR.
Should fix #5820