grunt-ts
grunt-ts copied to clipboard
grunt-ts' watch doesn't perform like tsc's watch
I have a tsconfig.json file with allowJs:true
In my grunt-ts configuration, I'm referencing it and using the passThrough:true option :
module.exports = {
options: {
verbose: true
},
dist: {
tsconfig: {
tsconfig: 'app/scripts/',
passThrough: true
}
}
};
Anyway, when I run grunt ts:dist :
- Compilation is triggered each time I change a
.tsfile - Compilation is not triggered when I change a
.jsfile (despite theallowJsflag intsconfig.json
However, when I run tsc --project app/scripts/ -w :
- Compilation is triggered each time I change a
.tsfile - Compilation is triggered as well each time I change a
.jsfile, denoting we have currently a different behaviour betweengrunt-tsandtsc
Does it sound normal to you ?
I would have expected grunt-ts to rely on tsc rather than re-implement his own watching mechanism.
FYI, my whole tsconfig.json file :
{
"compilerOptions": {
"module": "amd",
"target": "ES5",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "../../.tmp/scripts/app.js",
"sourceMap": true,
"inlineSourceMap": false,
"allowJs": true,
"inlineSources": true
}
}
This is a good report. We implemented the grunt-ts watch feature well before tsc supported watch itself. How would you propose fixing it?
Currently, I worked around it by removing my use of grunt-ts and using grunt-exec instead, and calling tsc --project app/scripts/ -w by hand
Afterall, since I exported my whole config into the tsconfig.json file, I don't need any grunt-ts addition to my build, tsc is enough for my case.
(not sure if it is what you expected to hear, but I need to keep it simple stupid here :-))
It's certainly fine. Grunt is designed around "Do thing, stop, do next thing, stop" so watch has always been a bit awkward. At some point in the future I would like to consolidate watch and fast to work with the TypeScript language service, but this will take a lot of time. In the meantime, it may be sufficient to add tracking of .js files to the watch if allowJs is passed-in. I know our best use case is as part of a whole pipeline (build/minify/test/etc.) rather than watch.
ToDo: Add .js files (possibly .jsx/.tsx) to handleFileEvent in ts.ts.