ivogabe / gulp-typescript

A TypeScript compiler for gulp with incremental compilation support.
MIT License
839 stars 129 forks source link

"This is probably an issue of gulp-typescript" : Could not find input file #157

Closed Hesquibet closed 9 years ago

Hesquibet commented 9 years ago

Hello,

I'm trying to build my project using this task

gulp.task('Compile-CoreModule', ['Compile-InfrastructureModule'], function() {
    var tsResult = gulp.src(['CoreModule/CoreModule.ts', 'release/definitions/Libs/**.ts', 'release/definitions/**.ts'])
        .pipe(ts(tsProject));

    return merge([
// Merge the two output streams, so this task is finished when the IO of both operations are done. 
        tsResult.dts
        .pipe(gulp.dest('release/definitions')),
        tsResult.js.pipe(gulp.dest('release/js'))
    ]);
});

When i try to compile i get the following error

Could not find input file C:\TFS\NumeArc.Vigoo\Vigoo_0.1-branch\Vigoo.Web.FrontE nd\CoreModule\InfrastructureModule\InfrastructureModule.ts. This is probably an Issue of gulp-typescript. Please report it at https://github.com/ivogabe/gulp-typescript/issues Debug information: SourceRoot = "C:/TFS/NumeArc.Vigoo/Vigoo_0.1-branch/Vigoo.Web.FrontEnd/CoreModul /e" Sources = ["InfrastructureModule/InfrastructureModule.ts"] Could not find input file C:\TFS\NumeArc.Vigoo\Vigoo_0.1-branch\Vigoo.Web.FrontE nd\CoreModule\CoreModule\CoreModule.ts. This is probably an issue of gulp-typesc ript. Please report it at https://github.com/ivogabe/gulp-typescript/issues Debug information: SourceRoot = "C:/TFS/NumeArc.Vigoo/Vigoo_0.1-branch/Vigoo.Web.FrontEnd/CoreModul e/" Sources = ["CoreModule/CoreModule.ts"] Could not find input file C:\TFS\NumeArc.Vigoo\Vigoo_0.1-branch\Vigoo.Web.FrontE nd\CoreModule\CoreModule____empty.ts. This is probably an issue of gulp-typescript. Please report it at https://github.com/ivogabe/gulp-typescript/issues Debug information: SourceRoot = "C:/TFS/NumeArc.Vigoo/Vigoo_0.1-branch/Vigoo.Web.FrontEnd/CoreModul e/" Sources = ["CoreModule/____empty.ts"]

for extra info my project has 2 TS files in two folders:

both are external module compiled using amd, and command line compile with TSC works.

CoreModule requries Infrastructure Module as such :

import Infrastructure = require("../InfrastructureModule/InfrastructureModule");

Moreover i noticed that in the "Debug Information" it could not find the file at

C:\TFS\NumeArc.Vigoo\Vigoo_0.1-branch\Vigoo.Web.FrontE nd\CoreModule\InfrastructureModule\InfrastructureModule.ts.

which is normal as the real path is

C:\TFS\NumeArc.Vigoo\Vigoo_0.1-branch\Vigoo.Web.FrontE nd\InfrastructureModule\InfrastructureModule.ts.

I hope i gave enough informations,

Thank you in advance for your answer.

ivogabe commented 9 years ago

Thanks for reporting, I'll take a look

ivogabe commented 9 years ago

Sorry for the long delay. I've tried to reproduce your problem. Have you tried using version 2.8.0? With that version I can't reproduce your issue. Did updating solve your issue?

Hesquibet commented 9 years ago

Hello Ivogabe, Thank you for taking time to answer me. I have followed your advices, but i still have the problem with the 2.8.0 version. I have published my repo so that it can help reproduce https://github.com/Hesquibet/Vigoo

ivogabe commented 9 years ago

Thanks for the repo. You're using the same project in multiple tasks. That's not supported (see #169). I'll add a better error message soon as the current is more confusing than helpful.

A fix for you would be to either create multiple tsProjects or compile all sources in one task. I recommend the second. When compiling the sources in multiple tasks, some files are parsed multiple times (because they are referenced from other modules). If you want to lower compilation times when a part of your program needs to be recompiled, I'd suggest using incremental compilation (see the readme).

Did this solve your problem?

Hesquibet commented 9 years ago

Ok thanks a lot of the detailed explanations & advices. I couldn't make it work on the same task (as i want one file per directory i had to use merge2), but it did make it work with multiple projects. Anyways, problem fixed, thanks again !

DmitryEfimenko commented 8 years ago

+1 for clearer message. I think this is still an issue.

ivogabe commented 8 years ago

@DmitryEfimenko Added in dead53940fdf704f809bacaec61df9337bae2c07

jods4 commented 8 years ago

@ivogabe Now I get compilation errors from my watch tasks.

If more than one .ts file gets modified in a short interval of time, the watch task kicks in more than once and because of the new error the second one (which is the one I'm most interested in) fails because the ts project is already in use...

What is the proper way?

ivogabe commented 8 years ago

@jods4 I cannot reproduce that. Do you return the stream in your compile task? If not, gulp doesn't know when the task is finished. Otherwise, can you post your gulpfile?

jods4 commented 8 years ago

Sure, here you have the relevant part (Gulp 4)

var ts = require("gulp-typescript");
var tsProject = ts.createProject('App/tsconfig.json', { typescript: require('typescript'), noExternalResolve: true });

// Bundle all App/**/*.ts files into main.js
function buildApp() {
  var babel = require("gulp-babel");
  var gulpif = require("gulp-if");

  return gulp.src(['App/**/*.ts', 'App/.d.ts/**/*.d.ts', 'App/*.js'])
             .pipe(ts(tsProject))
             .js
             .pipe(babel({ presets: ['es2015-loose'], compact: true }))
             .pipe(gulpif(options.minify, uglify()))
             .pipe(gulp.dest('wwwroot/dist'));
}

gulp.task("watch", function () {
  gulp.watch("App/**/*.ts", buildApp);
  gulp.watch("Icons/*", buildIcons);
  gulp.watch("Less/**/*.less", buildLess);
  gulp.watch("Views/**/*.html", buildViews);
});

I think the problem is simply that there are concurrent buildApp running because watch triggers on each change. Or am I doing something wrong?

EDIT I need to point out that this happens only when I have multiple changes in rapid succession (i.e. faster than the compilation time). Then in the console I see two appBuild and the second fails because the ts project is already in use (by the first one obvisouly). If I wait until they all complete and do a single change, the watch picks it up and appBuild completes fine.