-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Expose incremental Compile-on-Save builder API #17493
Comments
Exciting!! cc @piotr-oles @basarat @blakeembrey @HerringtonDarkholme @MortenHoustonLudvigsen It sounds like the addition of this will make for simpler build tools. Put simply, I figure certain tools will need to do less work with this is in place. Perhaps it would be useful for people to list "things their tools do" which, with the addition of this functionality, they think they won't need to anymore. If we cover that we will hopefully ensure that what lands will work in the way that everyone hopes. @jbrantly - I know you're less involved with ts-loader these days but whenever you pitch in your insights are really useful. If you could get a moment to comment on this I think it would be really valuable for everyone. (Obviously no worries if you can't) |
Will this be an api that has both sync and async variants? Additionally, this sounds awesome so far. I think this lets both @johnnyreilly and @s-panferov remove the soon-to-be deprecated accessing of 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 💯 |
Hi @TheLarkInn,
Do you have a link you could share to this please Sean? I hadn't heard this was happening and would like to read up on it. Thanks!
As an aside, you can use ts-loader with happypack right now. It essentially works by flipping ts-loader into transpile mode and preventing reporting of errors to webpack in the way that ts-loader normally does. (Type checking is moved into another process via a plugin.) The reason I mention that is the preventing of reporting to webpack etc is I suspect where we make use of |
To answer the question about sync vs async, I don't think we will have an async API since the compiler runs synchronously. Otherwise, something that would be helpful for @sheetalkamat to know is what sort of API you all expect to be able to use. Do we have users who need to be able to query for only new diagnostics from files, or is it whole-program errors every time? Currently the stripped down design is something like the following
With that, a callback could potentially always just query the program for when it needs new diagnostics, or needs to emit those specific files. It could be that consumers are responsible for caching diagnostics themselves. |
@DanielRosenwasser for additions/removals would one diff the prior program source files to the program passed to the callback? |
@krisselden The changedFiles is list of addition/removed/changed files name list. |
My feeling is that having "whole-program errors every time" is simpler from a consumption perspective. Less scope for getting things wrong, less work to do (selfish I know!) Looking at the API, I'm assuming the idea is you'd call the callback with changed files and then query for diagnostics immediately after? And this would be fine as the API is sync not async? Obviously you're only at design stages right now but if you have a chance, I'd love to see some simple code examples of how you would expect this API to be used. Personally, I find it easier to think about things when I see examples of how something plugs together (and also I've found that when I take things out of the abstract to the practical it shows up considerations I hadn't pondered.) 🌻 |
Also I guess this is #9282, sorry @alexeagle. |
I'd also like to see a usage example for the proposed |
This is interesting. Could you provide some more details on what features this compile-on-save API exposes? Is it a "read-only" API that simply informs external services of TypeScript's dependency model, or can it also be used to inject other tasks into the dependency graph? Something like the latter would be pretty useful for doing codegen. |
With the current Compiler API, a custom |
It will be great if command line interface of # Compile and run tests
tsc -p tests --outDir tests-out && mocha tests-out Now this command has two disadvantages:
|
@ikokostya there are projects like ts-watch that allows you to do watch + trigger onSuccess. |
is the builder API still on track for 2.7? |
@ikokostya for now you can use tsc-watch to re-run a task on successful build |
Should be fixed by #20234 |
In #10879, @sheetalkamat is working on bringing the same logic in the language server to Compile-on-Save. We would like to expose that as an API so that other build tools (e.g. Webpack loaders, gulp plugins, Broccoli plugins) and editors (any editor using TS Server) can get:
Some prior work that motivated the scenarios here can be seen on PR #3687 by @dbaeumer.
We'd like to elicit feedback from others in the community. Some folks that immediately come to mind are @TheLarkInn @johnnyreilly @jbrantly @s-panferov @mattbierner @jrieken @dbaeumer @alexeagle @chuckjaz @ivogabe and @krisselden (Forgive me if I excluded anyone, that's already a decent number of people 😄).
The text was updated successfully, but these errors were encountered: