-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Optimize tsc --w
using the CoS builder
#10879
Comments
This is a tricky problem as changes in one source file can produce errors in other source file such as renaming a function in one file, and not updating the other files to use the new name. So at the bare minimum, you need to re-evaluate error checking in the other source files in the project. In other cases, such as as changing the values of a const enum, you also have to re-emit as well. I recently wrote my own watch script using the language service API's and wound up writing both 'watch' and 'unsafewatch' tasks. The watch task does the recompilation ala tsc, and the unsafe version does the single file fast turnaround times like you are describing, at the expense of generating code that may or may not be broken. To do this correctly, I believe the language service API's would need to expose a way to query the interfile dependencies based on which symbols are used and where they are defined. I didn't see anything exposed in the API along those lines when I was working on this, but I think it could be a welcome addition. |
I think |
|
tsserver already knows how to do this correctly without a flag; we'll be moving the code from tsserver to tsc that can do this correctly for isolated modules |
@zhengbli we will need to move the builder logic into program perhaps, and allow it to be used for both compile on save, and --watch. |
also related #11229 |
I believe this is a really important issue that influences DX daily, hourly, minutely, and not secondly, but firstly. |
@zhengbli @mhegazy @RyanCavanaugh - Hi guys, just wondering if there was an ETA on this please? Compile times are killing me... |
can't look at so many peoples suffering here: {
"taskName": "quick transpile",
"suppressTaskName": true,
"showOutput": "always",
"command": "node"
"args": [
"./node_modules/typescript/bin/tsc --target YOUR_TARGET_HERE --module YOUR_MODULE_HERE --noResolve --rootDir YOUR_ROOT_HERE_IF_NEEDED --outDir YOUR_OUTPUT_FOLDER_HERE_IF_NEEDED ${relativeFile}"
]
}
{
"key": "ctrl+q",
"command": "workbench.action.tasks.runTask",
"args": "quick transpile",
"when": "editorTextFocus"
}, so what just happened? why do i see these errors in the output? no panic, we just transpiled the current file into JS ignoring all type checks, so we got our JS from TS lightning fast at the price of no gurantees of being correct assuming you know there were no errors enjoy |
There is now babel-preset-typescript, that mostly erases just the types. See: https://babeljs.io/blog/2017/09/12/planning-for-7.0 and https://github.com/babel/babel/tree/master/packages/babel-preset-typescript Has anyone tried it yet? How fast is it? |
The fix should be in |
Like @Aleksey-Bykov we have a similar solution leaning on everyone's experiences to make a gulp watch task Our typescript full compiles took around 18 seconds, incremental 15 seconds, but whatever visual studio 2015/2017 did it could produce the .js file in the time it took to refresh the browser. So we hooked up a watch to .ts files and compiled the single file.
Obviously any errors are not reported and it does its best, so a full compile is needed at some point, but for incremental changes we wanted a quick turn around as possible like we can achieve in VS2017. I will try out the changes to --w and see if it does what we need. Thanks |
@mhegazy and team - just to say, we upgraded today (now that the ImmutableJS type definitions have been fixed) and we're seeing some impressive speed improvements in Thank you very much! |
thanks for getting back to us on this. glad we could make it work better for you. The change was big, so i would not be surprised if there are issues. please feel free to reach out if you are running into any issues. |
We have switched to using it in production. Our watch builds are down from 14 seconds to 1-2 depending on how dependent the file is. Amazing work, looking forward to that api you say you will expose so other tools can use it too. Great Job. |
It would be great if one could run
tsc -w --eraseMode
(or something similar) that would allow to simply erase theTypeScript
annotations and hopefully generate js code quicklyRight now making tiny change in one file:
eg.
console.log('test1')
toconsole.log('test2')
triggers "recompilation" (even if incremental) - that takes some time and keeps getting slower as project grows
VScode already makes a great job with showing errors in a project - and I would be happy to have long (re)compilation with full errors to be part of build process - what I would prefer is ability to have 'instant' change reflection in generated js files
Related to: #10878
The text was updated successfully, but these errors were encountered: