Skip to content

When watch is triggered build.js.dev displays lots of errors. #1145

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

Closed
sjiep opened this issue Jul 21, 2016 · 23 comments
Closed

When watch is triggered build.js.dev displays lots of errors. #1145

sjiep opened this issue Jul 21, 2016 · 23 comments

Comments

@sjiep
Copy link
Contributor

sjiep commented Jul 21, 2016

Since I merged the pull request of #1099 I get the following type error messages from the build.js.dev task, when I have npm start running and make a change in the code which triggers the watch to re-execute the given tasks.

Could not find input file ....\src\client\src\client\app\+home\home.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information: 
sourceRoot = "..../src/client/"
sources = ["src\\client\\app\\+home\\home.component.ts"]

(This errors shows up for basically every TS file it compiles.)

After a bit of debugging I found out this is happening because the projectFiles are not cached any more on the typed builds, see build.js.dev.ts#L30.

For now I have added the line projectFiles = projectFiles.pipe(plugins.cached()); to my typed builds as well such that the errors don't show up any more.

In my debugging I found out that on the first run of the npm start tasks there is no sourceRoot specified in the tsProject variable. However on every new 'watch execution' the tsProject contains a sourceRoot = APP_CLIENT entry, I believe this should actually be APP_BASE instead.

@brian428 any idea why this is happening? Can you replicate this behaviour?

@sjiep sjiep changed the title When watch is triggered 'tsProject' sourceRoot, displaying lots of errors. When watch is triggered build.js.dev displays lots of errors. Jul 21, 2016
@brian428
Copy link
Contributor

Hmm...have you changed the glob for the source files that is passed into the TS compiler? Because if it's including all of your source files and it's not cached, I don't see how it could be "missing" a file?

The reason that gulp-cached was removed is because it was actually hiding errors. gulp-cached only passes changed files downstream, so the "typed" compile wasn't actually checking things correctly. For example, if you changed a class name, that file might still compile fine, but any other (currently unchanged) files that depended on the old class name would fail to trigger compile errors (because they're unchanged and aren't passed downstream for recompilation).

The new setup ensures that errors like that would now be caught. The new TYPED_COMPILE_INTERVAL config option is meant to help with compile speed. Take a look at the wiki content I added and let me know if using that helps at all.

@brian428
Copy link
Contributor

Also not sure what you mean about APP_CLIENT or APP_BASE in this context. There's nothing in tsproject.ts or build.js.dev.ts that uses either of those values.

@sjiep
Copy link
Contributor Author

sjiep commented Jul 21, 2016

Thanks for your answer. I did take a look at the wiki, but sadly nothing really new for me there.

The reason I mentioned APP_CLIENT and APP_BASE is because if you look in the error of my initial post you can see sourceRoot ending in ../src/client (which is basically where APP_CLIENT is pointing at), and sources start at src\\client\\... (only missing the APP_BASE part).

It turns out, it might not have anything to do with that. I did find some new information, I only get this long list of error messages when I change a SASS file and not when I change a TS file. So it is somehow related to the SASS files and only when the watch gets triggered.

Tomorrow morning I will check if I can reproduce this with a clean checkout from the seed.

@sjiep
Copy link
Contributor Author

sjiep commented Jul 22, 2016

Well, I made a fresh clone from the seed, but sadly can't reproduce the problem then.
It is still weird that these errors show up when I change an SASS file and not TS file.

@brian428
Copy link
Contributor

Could there be some difference between your larger project and the master seed? Something you changed or tweaked that makes it diverge from master? Beyond that, I guess just keep us posted. If you find the cause and it is actually due to the changes I made to the TS compile task, let me know.

@sjiep
Copy link
Contributor Author

sjiep commented Jul 22, 2016

I've kept the changes to the master seed as little as possible (in order to hopefully prevent these kind of differences). I made some minor changes here and there and extended it, but can't think of anything that would affect this.

Anyway, thanks for your help! For now I will just keep using the cached version, I can live with that. If I find the cause + solution in the future you will hear from me.

@sjiep sjiep closed this as completed Jul 22, 2016
brian428 referenced this issue Jul 27, 2016
@jvitor83
Copy link
Contributor

@brian428 I got the same issue @sjiep have.

And found out the same thing:

In my debugging I found out that on the first run of the npm start tasks there is no sourceRoot specified in the tsProject variable.

Like @sjiep, i could not reproduce with the original seed.
In my project, i have SASS enabled too, but have realized that those problem happen when i change some html file as well.

If i found out the cause i will bring here too.

@brian428
Copy link
Contributor

Yeah, still no idea how this could have anything to do with SASS. The glob used for the TS source only includes *.ts files (https://github.com/mgechev/angular2-seed/blob/master/tools/tasks/seed/build.js.dev.ts#L24), so this isn't even including HTML or SASS files.

@jvitor83
Copy link
Contributor

@brian428, i guessing that the previouly task called by the gulp "build.html_css.ts" (in the watch task) is changing something that the projectFiles = projectFiles.pipe(plugins.cached()); is solving.
Still, have not figured out what it is.

@brian428
Copy link
Contributor

brian428 commented Jul 27, 2016

Hmm, I don't see how. build.html_css.ts specifies only .html/.css/.scss extensions in it's globs.

If you specify a cache key in build.js.dev.ts, does that matter? e.g.:

if (typedBuildCounter < TYPED_COMPILE_INTERVAL) {
    isFullCompile = false;
    tsProject = makeTsProject({isolatedModules: true});
    projectFiles = projectFiles.pipe(plugins.cached('build-js-dev'));
    util.log('Performing typeless TypeScript compile.');
  } else {

I don't think it should, but the empty cache key is about the only thing I can think of that could affect anything.

@jvitor83
Copy link
Contributor

To solve the issue, between lines 30 and 43 i put the following:

  let projectFiles = gulp.src(src).pipe(plugins.cached());
  let result: any;
  let isFullCompile = true;

  // Only do a typed build every X builds, otherwise do a typeless build to speed things up
  if (typedBuildCounter < TYPED_COMPILE_INTERVAL) {
    isFullCompile = false;
    tsProject = makeTsProject({isolatedModules: true});
    util.log('Performing typeless TypeScript compile.');
  } else {
    tsProject = makeTsProject();
    projectFiles = merge(typings, projectFiles);
  }

Basically is:

This way the problem is solved. But i don't know if it has any side-effects.

@brian428
Copy link
Contributor

Yeah the whole problem is that we don't want the typed compile to be cached, because gulp-cached only forwards changed files downstream. Meaning a change in one file could result errors in other (currently unchanged) files that are not caught because the unchanged files aren't recompiled.

What about putting it back the way it was, but removing the use of cached from the untyped build (so that cached is basically not used at all in build.js.dev.ts)?

@sjiep
Copy link
Contributor Author

sjiep commented Jul 28, 2016

@jvitor83 your change is what the code used to do before the pull request by @brian428 got merged.

For now I've done a similar thing to 'supress' the error message (strangely even though they are error message, the build just runs fine and does its thing, it's just very annoying that a billion error messages are displayed in the console on every file change).

Still am clueless why this is happening, as @brian428 mentioned, SASS has nothing to do with the TS compiler.

@brian428
Copy link
Contributor

To be clear: does this only occur when using SASS?

Everyone who's tried things using a fresh pull of the seed says the problem doesn't manifest (even with SASS enabled, as far as I can tell), so it seems like it's got to be something specific to the projects that are seeing this problem. But what it could be I have no idea. It doesn't seem to make any sense. :-/

@sjiep
Copy link
Contributor Author

sjiep commented Jul 29, 2016

I indeed can't replicate the problem on a fresh pull of the seed with SASS enabled.

For me errors show up when the watch is running and I change a SASS file, not when I change a TS file. I'm not sure if this only happens when using SASS though. I've only used the seed in one project which has SASS enabled.

@brian428
Copy link
Contributor

brian428 commented Jul 29, 2016

Does removing the use of gulp-cached from the isolated module compile (so that gulp-cached isn't used at all in build.js.dev.ts), or adding a cache key to the gulp-cache call in the isolated module compile (e.g. plugins.cached('build-js-dev')) affect things at all?

@sjiep
Copy link
Contributor Author

sjiep commented Aug 2, 2016

Does removing the use of gulp-cached from the isolated module compile (so that gulp-cached isn't used at all in build.js.dev.ts), or adding a cache key to the gulp-cache call in the isolated module compile (e.g. plugins.cached('build-js-dev')) affect things at all?

My TYPED_COMPILE_INTERVAL variable is 0 (default value) so without my edit of adding gulp-cached to the projectFiles pipe, it isn't using gulp-cached at all when the errors appear. Also regarding the key, my code doesn't execute the typedBuild if statement, so adding a cache key there shouldn't have any affect.

@brian428
Copy link
Contributor

brian428 commented Aug 2, 2016

Understood, it was just an idea. I guess all we can hope for is a reproducible case then. Use of gulp-cached in the TS compile was going to come out anyway (for the reasons already mentioned), so it sounds like this would have affected you no matter what. But I'm still totally baffled as to how anything in the TS compile task could be affecting (or be affected by) the SASS task...

@spali
Copy link

spali commented Aug 16, 2016

Not sure if this is the same, but I got similar error messages. Just found this issue because I noticed the "double" path \src\client\src\client and searched for it.
It started to happen after adding a third party npm module and added it as a service in the AppModule.
I could reproduce it without all the hassle of my project, just adding the third party module and add it as service to AppModule.
Probably this could help to find the reason.

  1. git clone https://github.com/mgechev/angular2-seed.git
  2. cd .\angular2-seed
  3. npm install
  4. npm start -> no errors
  5. touched file app.module.ts without changes -> reloaded without errors
  6. killed npm process
  7. npm install angular2-busy --save
  8. modified app.module.ts (adding import of service and added to providers):
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { APP_BASE_HREF } from '@angular/common';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { routes } from './app.routes';

import { AboutModule } from './+about/about.module';
import { HomeModule } from './+home/home.module';
import { SharedModule } from './shared/shared.module';
import { BusyService } from 'angular2-busy';

@NgModule({
  imports: [BrowserModule, HttpModule, RouterModule.forRoot(routes), AboutModule, HomeModule, SharedModule.forRoot()],
  declarations: [AppComponent],
  providers: [{
    provide: APP_BASE_HREF,
    useValue: '<%= APP_BASE %>'
  },
  BusyService],
  bootstrap: [AppComponent]

})

export class AppModule { }
  1. npm start -> no errors
  2. touched file app.module.ts without changes -> reloaded with errors:
[13:33:29] Starting 'build.js.dev'...
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\name-list\name-list.service.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\name-list\\name-list.service.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\name-list\index.ts. This is probably an issue of gulp-typescript.

Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\name-list\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\navbar\navbar.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\navbar\\navbar.component.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\navbar\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\navbar\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\toolbar\toolbar.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\toolbar\\toolbar.component.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\toolbar\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\toolbar\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\config\env.config.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\config\\env.config.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\app.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\app.component.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+about\about.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+about\\about.component.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+about\about.routes.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+about\\about.routes.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+about\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+about\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+home\home.component.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+home\\home.component.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+home\home.routes.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+home\\home.routes.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+home\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+home\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\app.routes.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\app.routes.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+about\about.module.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+about\\about.module.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\shared\shared.module.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\shared\\shared.module.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\+home\home.module.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\+home\\home.module.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\node_modules\angular2-busy\index.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["node_modules\\angular2-busy\\index.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\app.module.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\app.module.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\hot_loader_main.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\hot_loader_main.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\app\main.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\app\\main.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\testing\router\mock-location-strategy.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\testing\\router\\mock-location-strategy.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\testing\router\router-testing-providers.ts. This is probably an issue of gulp-typescript.
Please report it at https://github.com/ivogabe/gulp-typescript/issues
Debug information:
sourceRoot = "C:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\testing\\router\\router-testing-providers.ts"]
Could not find input file C:\Data\_git\irt-web\test\angular2-seed\src\client\src\client\________________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:/Data/_git/irt-web/test/angular2-seed/src/client/"
sources = ["src\\client\\________________empty.ts"]
[13:33:29] Finished 'build.js.dev' after 80 ms

@brian428
Copy link
Contributor

Sounds like a separate issue. Check out #1157 and ivogabe/gulp-typescript#307.

@sjiep
Copy link
Contributor Author

sjiep commented Aug 30, 2016

@brian428 Recently I merged the latest changes from the seed into my project.

Out of curiosity I removed my line that cached the project files on a typed build to see if the warning/error messages still appeared. And behold, they didn't show up any more!

So from my side, I can't reproduce my error any more.

@brian428
Copy link
Contributor

Great, sounds like this can be closed then. Given what you said, it sounds like the issue was likely with one of the dependent libraries rather than the seed itself.

@hoangnguyenba
Copy link

hoangnguyenba commented Sep 12, 2016

I am having this issue after angular2-seed update rc6.
But It only happens when I change html file.
When I change something in ts file, it's still working.

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

No branches or pull requests

5 participants