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

[1.5.0-rc.5] Failed to load templateUrl path when enabling hmr #8234

Closed
aitboudad opened this issue Oct 28, 2017 · 24 comments · Fixed by #8215
Closed

[1.5.0-rc.5] Failed to load templateUrl path when enabling hmr #8234

aitboudad opened this issue Oct 28, 2017 · 24 comments · Fixed by #8215
Assignees
Labels
needs: more info Reporter must clarify the issue P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Milestone

Comments

@aitboudad
Copy link
Contributor

aitboudad commented Oct 28, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0-rc.6
Node: 8.6.0
OS: linux x64
Angular: 5.0.0-rc.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0-rc.6
@angular-devkit/build-optimizer: 0.0.31
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.6
@schematics/angular: 0.0.48
typescript: 2.5.3
webpack: 3.8.1

Repro steps.

The log given by the failure.

selection_103

@filipesilva filipesilva self-assigned this Oct 28, 2017
@filipesilva filipesilva added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix labels Oct 28, 2017
@filipesilva
Copy link
Contributor

@aitboudad heya, can you try doing ng serve --hmr -e=hmr --no-aot? With Angular 5 + CLI 1.5 serve defaults to AOT, and I suspect HMR doesn't work with AOT.

@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Oct 28, 2017
@aitboudad
Copy link
Contributor Author

aitboudad commented Oct 28, 2017

@filipesilva it's work with --no-aot when using hmr, I suggest to turn off aot

@aitboudad
Copy link
Contributor Author

@filipesilva for the build part ng build --prod --build-optimizer -sm produce a large bundle size that contains @angular/compiler!!

@filipesilva
Copy link
Contributor

I'll make a PR to add this information to the HMR docs.

I think you're getting @angular/compiler in your production bundle because of the import { createNewHosts } from '@angularclass/hmr'; import. To compile updated components on the fly it must be using the compiler.

@aitboudad
Copy link
Contributor Author

another issue I've got when using lazy load route:

ERROR in ./src/app/child/child.module.ts
Module build failed: Error: ..../child/child.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:693:23)
    at plugin.done.then (node_modules/@ngtools/webpack/src/loader.js:467:39)
    at <anonymous>
 @ ./src/$$_lazy_route_resource lazy
 @ ./node_modules/@angular/core/esm5/core.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://127.0.0.1:9096/ webpack/hot/dev-server ./src/main.ts

@filipesilva
Copy link
Contributor

That one seems very similar to what's reported in #8207, but I haven't been able to reproduce it yet. Can you tell me exactly how to reproduce it please? Also would like to know if it only happens with HMR on.

@aitboudad
Copy link
Contributor Author

added a simple example ng-cli-19994#5c2e355f and I also I checked several scenario

cmd status
ng serve work
ng serve --hmr -e=hmr --no-aot not working
ng serve --no-aot not working

if I removed the hmr code in the main.js script with ng serve --no-aot the error appear but the build continue to work

@aitboudad
Copy link
Contributor Author

I think you're getting @angular/compiler in your production bundle because of the import { createNewHosts } from '@angularclass/hmr'; import. To compile updated components on the fly it must be using the compiler.

It's not hmr but on how we call bootstrapModule try with:

const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);
bootstrap();

and you'll noticed that the @angular/compiler is part of main bundle.

@filipesilva
Copy link
Contributor

Thanks a lot for setting up that repro, it really helps to debug what's going on 👍

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 28, 2017
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 28, 2017
@filipesilva
Copy link
Contributor

filipesilva commented Oct 28, 2017

I'm trying your repo and this is what I get:

  • ng serve --aot: builds correctly but fails at runtime with the following error:
GET http://localhost:4200/ui-select/ui-select.html 404 (Not Found)
Unhandled Promise rejection: Failed to load ../ui-select/ui-select.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load ../ui-select/ui-select.html undefined
  • ng serve --no-aot: fails to build with the following error:
ERROR in ./src/app/home/home.module.ts
Module build failed: Error: D:\sandbox\ng-cli-19994\src\app\home\home.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (D:\sandbox\ng-cli-19994\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:693:23)
    at plugin.done.then (D:\sandbox\ng-cli-19994\node_modules\@ngtools\webpack\src\loader.js:467:39)
 @ ./src/$$_lazy_route_resource lazy
 @ ./node_modules/@angular/core/esm5/core.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
  • ng serve --hmr -e=hmr --no-aot: same as ng serve --no-aot

Investigating further.

@filipesilva
Copy link
Contributor

filipesilva commented Oct 28, 2017

I also tried your repro but with CLI 1.4.9, Angular packages at 4.4.6 and TypeScript at 2.3.2:

  • ng serve --aot: builds correctly and does not fail at runtime
  • ng serve --no-aot: same as above
  • ng serve --hmr -e=hmr --aot: same as above
  • ng serve --hmr -e=hmr --no-aot: same as above

So all of these worked before, but are not working with 1.5. This is a bug and will be fixed.

@filipesilva
Copy link
Contributor

I'm working on these errors (and others) in #8215.

It looks like there's some problem in the bootstrap replacement as you mentioned.

// doesn't work
const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);

// works
function bootstrap () {
  return platformBrowserDynamic().bootstrapModule(AppModule);
}

@asadsahi
Copy link

@filipesilva related to your comments here #8207 (comment) and in this issue, what is the issue? I have tried, with or without aot and with or without hmr. no option works for me.

Is it a cli issue or angular's?

@filipesilva
Copy link
Contributor

@asadsahi it is a CLI issue. Have you tried #8234 (comment)? (replacing the bootstrap)

@asadsahi
Copy link

asadsahi commented Oct 28, 2017

@filipesilva with angular 5.0.0-rc.8 & angular-cli 1.5.0-rc.6 tried following:

aot + hmr = doesn't work
no aot + no hmr = doesn't work

I have tried with both bootstrap options:

const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);

OR

function bootstrap () {
return platformBrowserDynamic().bootstrapModule(AppModule);
}

getting these errors:


[0]  @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
[0] ERROR in ./src/app/+profile/profile.module.ts
[0] Module build failed: Error: c:\Users\Asad\ngnode-fullstack\src\app\+profile\profile.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
[0]     at AngularCompilerPlugin.getCompiledFile (c:\Users\Asad\ngnode-fullstack\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:693:23)
[0]     at plugin.done.then (c:\Users\Asad\ngnode-fullstack\node_modules\@ngtools\webpack\src\loader.js:467:39)
[0]     at <anonymous>
[0]  @ ./src/$$_lazy_route_resource lazy
[0]  @ ./node_modules/@angular/core/esm5/core.js
[0]  @ ./src/main.ts
[0]  @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
[0] ERROR in ./src/app/+register/register.module.ts
[0] Module build failed: Error: c:\Users\Asad\ngnode-fullstack\src\app\+register\register.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

Do you want me to try any other option?

@filipesilva
Copy link
Contributor

I can confirm that (locally) the fixes I have in #8215 together with changing the bootstrap as I mention in #8234 (comment) make all the scenarios that previously worked in 1.4.9 also work in 1.5.0 (#8234 (comment)).

I'm still working out the kinks out of that PR but it should be good to go for the next release. Thanks for bearing with me while I debug this.

@filipesilva
Copy link
Contributor

Heya, pushed a new commit into #8215 that should take care of the bootstrap problem.

@asadsahi the problems you're seeing should also be fixed in that PR.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2017
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Oct 30, 2017
@asadsahi
Copy link

@filipesilva should the fix be in angular-cli v1.5.0-rc.7 ? can't see any difference.

Also with cli v1.5.0+ is following bootstrap a permanent change?
function bootstrap() {
return platformBrowserDynamic().bootstrapModule(AppModule);
}

@filipesilva
Copy link
Contributor

@asadsahi it's not merged yet, but should be merged for the next release. You should be able to use const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule); when that PR is merged.

@filipesilva
Copy link
Contributor

@aitboudad @asadsahi the fix for this is coming out as @angular/[email protected]. Please try it together with @angular/[email protected] (and other Angular packages) and let me know if you're still seeing this.

@elvisbegovic
Copy link
Contributor

elvisbegovic commented Oct 31, 2017

@filipesilva initial step seems to be faster I build initial step "ng s --sm=false" in 65seconds.

BUT unfortunatly when I edit file the recompilation takes still:
on 0% = 30 seconds like before then the rest in 10seconds

Angular CLI: 1.5.0-rc.8
Node: 6.11.0
OS: win32 x64
Angular: 5.0.0-rc.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0-rc.8
@angular-devkit/build-optimizer: 0.0.31
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.8
@schematics/angular: 0.0.49
typescript: 2.5.3
webpack: 3.8.1

otherwise for your information now I can build with --no-aot in 21seconds without this error:
bail.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

@aitboudad
Copy link
Contributor Author

@filipesilva I can confirm that everything is working now 👍 , the only remark I have is the incremental update is a little bit slow for AOT mode

@filipesilva
Copy link
Contributor

@istiti @aitboudad with CLI 1.5 and Angular 5, ng serve will default to using AOT. It should be much faster than before, but it seems it still isn't very fast in your projects. You can turn it off with --no-aot but I would also like to make it faster if I can.

Would you be interested in submitting a CPU profile showing where the time is spent on your rebuilds? I can use that to figure out bottlenecks. I put detailed instructions on how you can do that here: #8259

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants