I have a complicated workflow of TS compilation and I want to make my watchers faster (and still smarts). I currently have 3 different TS compilation that are executed when Grunt starts but also on watch changes.
grunt-ts
configuration:
https://gist.github.com/Vadorequest/f1fb95ab4bbc786f420b
grunt-watch
configuration:
https://gist.github.com/Vadorequest/eaa82c292a5d3e1ee51f
It currently works. But it takes too much time to recompile every file each time a change is made in any TS file that belong to a set of files. I'm looking for a way to compile only what needs to be compiled, in a smart way. (Meaning that if A.ts inherits of B.ts, if B is changed then A should be recompiled too, it should be possible since WebStorm IDE is able to do that using its Files Watchers)
I read something about fast-compile on https://github.com/TypeStrong/grunt-ts#fast but it doesn't seem like I could use it, but I'm confused about it. (see https://github.com/TypeStrong/grunt-ts/issues/293)
I'm looking for a solution, and also for advices because I think my setup can be improved. It's great to have server side TS files and even shared TS files across the server and the client, but it adds a lot of compilation workflow which is hard to understand and to maintain. Maybe using the recent feature tsconfig.json
would help? Any advice would be appreciated.
More details:
- serverCommonJs: The server uses TS files that are compiled before to start the application, like controllers and models for instance.
- clientCommonJs: Most of the client scripts are in CommonJs rather than in AMD because they're all concatened and minified and it's way easier to work with commonJS than AMD which requires a tons of setup.
- amd: Some files are compiled in AMD, whether they're used in the server or the client, or both.
On my computer it takes about 1.5s to 2.5s to compile one set of file. Once compiled they're all copied into a temporary folder which is served to the browser (assets). So it takes easily 5 up to 10 seconds and it could be much much faster if only the changed files were compiled and copied.
I also have a similar issue with LESS files, but that's another story and it should be much simpler to fix since I only have one set of LESS files.