Skip to content
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

grunt-ts' watch doesn't perform like tsc's watch #363

Open
fcamblor opened this issue Jun 22, 2016 · 3 comments
Open

grunt-ts' watch doesn't perform like tsc's watch #363

fcamblor opened this issue Jun 22, 2016 · 3 comments

Comments

@fcamblor
Copy link

fcamblor commented Jun 22, 2016

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 .ts file
  • Compilation is not triggered when I change a .js file (despite the allowJs flag in tsconfig.json

However, when I run tsc --project app/scripts/ -w :

  • Compilation is triggered each time I change a .ts file
  • Compilation is triggered as well each time I change a .js file, denoting we have currently a different behaviour between grunt-ts and tsc

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
    }
}
@nycdotnet
Copy link
Contributor

This is a good report. We implemented the grunt-ts watch feature well before tsc supported watch itself. How would you propose fixing it?

@fcamblor
Copy link
Author

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 :-))

@nycdotnet
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants