-
Notifications
You must be signed in to change notification settings - Fork 121
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
Compiling is slow #7
Comments
To help debug can you provide the following:
PS: time for the following config (This should definitely be same as ts: {
dev: { // a particular target
src: ["main.ts"],
out: 'test.js'
}
} We are using it on a large project and have friends that use it as well and haven't experienced this so I am really interested in finding the root cause if its grunt-ts. Thanks. |
Thanks for the quick reply. I checked my Gruntfile and realized it created declaration and sourcemap files. api: {
src: ['src/main/webapp/admin2/api/js/main.ts'],
out: 'src/main/webapp/admin2/api/js/api.js',
options: {
sourcemap: true,
declaration: true
}
} So i added this to the tsc compiler, and here are the results: $ time tsc src/main/webapp/admin2/api/js/main.ts --out test.js --declaration --sourcemap
real 0m6.549s
user 0m6.219s
sys 0m0.373s
$ time grunt ts:api
Running "ts:api" (ts) task
Compiling.
Success: 10.48s for 1 typescript files
Done, without errors.
real 0m11.043s
user 0m15.950s
sys 0m5.109s
Even though i added declaration and sourcemap to tsc, it seems like grunt-ts uses significantly more time. I also noted that the grunt-ts is very variable, going from between 10 secs and upwards to 15. 11-12 being the most common. tsc however stays about the same, with very little variance (even when adding declaration and sourcemaps). |
I can add that its about 14000 lines of typescript in 302 files. |
Make sure you are using the latest version of grunt-ts. Check your package.json, make sure it reads TypeScript 0.9.0 had performance issues which were fixed and grunt-ts was upgraded accordingly quite a while back. PS: we are on around 180 files and it takes about 5s, and so does tsc. If you look at the source code all |
I was actually running 1.1.8, but i switched to 1.3.0 and did npm install. The compile times stayed the same though. |
which version of nodejs are you using? |
v0.9.3 |
After further investigation:
You can see that grunt-ts takes +1 seconds (for generating reference.ts + loader.js files) and grunt itself takes +1 seconds to warm up and run the task but I don't see why it should take twice the time. I don't have a solution for your case I am afraid |
I am on node |
I have been trying to figure this out, so i took a walk around the office to check their compile times. A coworker with a newer computer compiled the same files in 3.7 sec with tsc and about 4.6 sec with grunt-ts. It seems like the grunt overhead takes exponentially more time with slower hardware. |
@ljl: I have the same issue. Did you find a way to speed things up? |
I am facing similiar issues using
It seems that a single hello world ts file takes ~4-5 seconds to compile when using the suggested arguments from the readme file - has anyone had any luck with this? :) |
@basarat I think it could be ShellJS on windows that is slowing things down. I was browsing their code to see how they can https://github.com/arturadib/shelljs/blob/master/src/exec.js#L63-L68
The implementation they do to run synchronous is very icky. Maybe |
I think we would be better off using grunt.util.spawn since it keeps our dependencies slimmer and on a more supported library. @basarat Any major features that ShellJS gives us that grunt.util.spawn doesn't have? |
Agreed, thanks for pointing it out!
not at all. Just used for convenience. |
@tschoartschi @AlanFoster @ljl due to @Bartvds's excellent work : #64 it should be faster now. Let us know if you experience differences between running Use grunt-ts 1.7.1 |
Great job @Bartvds - I've really noticed a huge speed increase with 1.7.1; The experience is definitely much improved now :) |
@AlanFoster Thanks, glad it helped. And a tip for power users: because there is no crappy ShellJS anymore to clobber the CPU threads with nonsense you can run builds parallel again (using |
I don't have alot of issues, yet I don't like to wait for nothing. Could you please go a bit more into the details on this? Like are there some best practices / examples (using grunt-ts with grunt parallel or grunt concurrent (or which one is now the best to use?)? Also does somebody have some special flag and tricks in your tsconfig.json to speed things up? Thanks! |
Best bet for speed of compilation in development with TypeScript is to use built-in watch parameter with tsc or an editor that supports compile on save. Grunt is not optimized for these scenarios because it is based around doing everything from scratch on each build. Grunt is more for consistency than performance. |
Using grunt-ts, compiling takes almost twice as long as the tsc compiler.
The text was updated successfully, but these errors were encountered: