Giter VIP home page Giter VIP logo

Comments (14)

bsr203 avatar bsr203 commented on June 14, 2024

see the details at https://github.com/gruntjs/grunt-contrib-watch#compiling-files-as-needed

you need to set spawn : false in watch options too.

also, not sure how to do this with grunt-ts watch functionality.

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

not sure how to do this with grunt-ts watch functionality.

grunt-ts runs in parallel now thanks to work by @Bartvds so simply using the passed file in https://github.com/grunt-ts/grunt-ts/blob/master/tasks/ts.ts#L984-L1002 would work.

from grunt-ts.

bsr203 avatar bsr203 commented on June 14, 2024

um, I have an issue. When use partial compilation, say if it detects one file changed, reference.ts is maintained wrongly. It always remove previous entries between

//grunt-start
//grunt-end

and enters currently changed file. If I change another file, it again clears previous and enter current. Is there a way to prevent removing previous reference, and do so only if physically remove a file?

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

@bsr203 I didn't know you were going to start working on this :) . Here was my plan:

add a new flag fastcompile to the target options (not the task options). If it is truthy we :

  1. compile only the changed files (either local watch or grunt watch)
  2. do not do any custom code generation. If a custom code generation option is specified in the target we warn the user.

To disable code generation we need to flag out https://github.com/grunt-ts/grunt-ts/blob/master/tasks/ts.ts#L907-L924 and https://github.com/grunt-ts/grunt-ts/blob/master/tasks/ts.ts#L946-L953

This was going to the the increment towards : #34

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

@bsr203 I was going to work on this after I sorted #69 out over the weekend

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

I misunderstood the feature:

//Only recompile the ts files that have actually changed.
    var onChange = grunt.util._.debounce(function () {
        grunt.config('ts.base.src', Object.keys(changedFiles));
        changedFiles = Object.create(null);
    }, 200);
    grunt.event.on('watch', function (action, filepath) {
        changedFiles[filepath] = action;
        onChange();
    });

Belongs in your gruntfile. I thought it was going to be a part of grunt-ts. We need a way inside grunt-ts to find out if base target src i.e. base.src has been tampered with by grunt-watch. If so we should disable code generation.

I don't know how we can detect this, any ideas @bsr203 ?

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

@bsr203 you might want to see : #76

from grunt-ts.

bsr203 avatar bsr203 commented on June 14, 2024

thanks for the feature. I am not an expert on grunt and not sure how you detect the changes. cant wait to try this out. thanks.

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

@bsr203 if you update to grunt-ts 1.8.0 all you need to do is specify fast:true https://github.com/basarat/demo-fullstack/blob/fe562a9378a240765b0dafa4b5d696416fc9a108/src/Gruntfile.js#L29

And it will work with grunt-contrib-watch or any other tool you want to use for watching :)

from grunt-ts.

bsr203 avatar bsr203 commented on June 14, 2024

thanks basarat. I have been using it from [email protected], but didn't test it thoroughly. still converting stuff from js -> ts. thanks for this feature and your hard work.

from grunt-ts.

bsr203 avatar bsr203 commented on June 14, 2024

@basarat can you please add info about the file which has been compiled.

Running "ts:app" (ts) task
Compiling...
Using tsc v1.0.0

Success: 4.99s for 1 typescript files

Done, without errors.

I always get the message, 1 typescript files, even if I change multiple files. I use out option so it compiles to one file. Is it because of that?.

from grunt-ts.

basarat avatar basarat commented on June 14, 2024

I use out option

fast compile will not work with --out since tsc will need to compile all the files. I should have shown you this message : https://github.com/grunt-ts/grunt-ts/blob/master/tasks/modules/compile.ts#L68

I always get the message, 1 typescript files

I'd like to see the repo if possible to see what's happening.

an you please add info about the file which has been compiled.

You should have seen this message : https://github.com/grunt-ts/grunt-ts/blob/master/tasks/modules/compile.ts#L195 for all of the files that changed.

Again : I'd like to see the repo to reproduce. Thanks for your time :)

from grunt-ts.

pksorensen avatar pksorensen commented on June 14, 2024

I think myissue here , http://stackoverflow.com/questions/33080502/grunt-ts-watch-not-working-when-file-changed, is related to this. The problem for me with the build in watch could be that my needed type definitions, "typings/vendors.d.ts","typings/tsd.d.ts", "!libs/*/.ts" in .src is not included when it compiles the changed filse (from reading this issue i concluded that the src of the task is updated to only changed files)

from grunt-ts.

pksorensen avatar pksorensen commented on June 14, 2024

my problem (using external watch) was that i missed:

options: {
                    spawn: false,
                },

from grunt-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.