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

Angular SPA SSR Template compile error with Angular 6 #6306

Closed
speige opened this issue Jan 2, 2019 · 2 comments
Closed

Angular SPA SSR Template compile error with Angular 6 #6306

speige opened this issue Jan 2, 2019 · 2 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-spa

Comments

@speige
Copy link
Contributor

speige commented Jan 2, 2019

@SteveSandersonMS
Migrated from aspnet/JavaScriptServices#1619

Describe the bug

Angular SPA SSR Template compiler error with Angular 6+

To Reproduce

Steps to reproduce the behavior:
Clone https://github.com/speige/Angular6DotNetCoreSpaTemplateBug
The "master" branch is the original angular 5 template. The "Angular6Working" branch is an straight upgrade to v6 with the @angular-devkit/build-angular npm package on 0.5.5. The "Angular6broken" branch is identical except with @angular-devkit/build-angular on 0.5.6

Expected behavior

Website builds & runs

Screenshots

image

Additional context

Although this looks like an Angular bug, it's actually a bug in SPA AspNetCore code. The output of the Angular compiler changed slightly between v5 & v6 which made this previously masked bug in AspNetCore appear. Essentially EventedStreamReader.cs doesn't send last line's contents to listener, so it doesn't know that AngularCliBuilder is complete.

On a side note, for Angular6 upgrade, a change should be done in
https://github.com/aspnet/JavaScriptServices/blob/dev/src/Microsoft.AspNetCore.SpaServices.Extensions/AngularCli/AngularCliBuilder.cs

            var npmScriptRunner = new NpmScriptRunner(
                sourcePath,
                _npmScriptName,
                "--watch",
                null);

The "--watch" is no longer a valid command line argument in Angular 6 CLI. If you do "ng serve" it automatically does --watch, if you do "ng build" it doesn't.

I worked around this issue by changing the "build:ssr" command in my package.json from

 "build:ssr": "ng build --configuration=production --project=ssr"

to

    "build:ssr_ignore_dash_dash_watch_from_AngularCliBuilderDotCS": "ng build --configuration=production --project=ssr ",
    "build:ssr": "npm run build:ssr_ignore_dash_dash_watch_from_AngularCliBuilderDotCS"

which basically causes the extra command line argument to be discarded before "ng build" is called. Otherwise Angular throws an error about an invalid command line argument.

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jan 3, 2019
@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. PRI: 2 - Preferred labels Jul 1, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview9 milestone Jul 1, 2019
@mkArtakMSFT
Copy link
Member

@ryanbrandenburg have a look and see whether this still makes sense. If yes, review the PR and merge as necessary.

@mkArtakMSFT
Copy link
Member

We're closing this as per announcement #12890

mkArtakMSFT pushed a commit that referenced this issue Sep 11, 2019
… otherwise AngularCliBuilder doesn't know when build:ssr is complete (#13485)

Thanks for your effort.
@mkArtakMSFT mkArtakMSFT added the Done This issue has been fixed label Sep 11, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: 3.1.0, 5.0.0-preview1 Sep 11, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-spa
Projects
None yet
Development

No branches or pull requests

4 participants