Skip to content

ng app-shell and SSR pre-renders app-root and not just app-shell #12310

Closed
@jot-hub

Description

@jot-hub

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [X] build
- [ ] serve
- [ ] test
- [ ] e2e
- [X] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [X] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

~> node --version
v8.11.1
~> npm --version
6.4.1-next.0
~> ng --version

Angular CLI: 6.0.8
Node: 8.11.1
OS: win32 x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.3.2
typescript                        2.7.2
webpack                           4.8.3

Repro steps

Following the tutorial app shell with ssr:

  1. ng new my-app-shell --routing

  2. ng generate universal ngu-app-shell --client-project my-app-shell
    ===> did not add a new application as mentioned in the tutorial, but did add a new server section under architect section in angular.json with following values

"server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist/my-app-shell-server",
            "main": "src/main.server.ts",
            "tsConfig": "src/tsconfig.server.json"
          }
        }
  1. ng generate app-shell my-loading-shell --universal-project=ngu-app-shell --route=app-shell-path --client-project=my-app-shell
    this added app-shell section in angular.json with below options
"options": {
            "browserTarget": "my-app-shell:build", <== I changed it to `my-app-shell:build:production`
            "serverTarget": "my-app-shell:server",
            "route": "app-shell-path"
          }
  1. ng run my-app-shell:app-shell
    ===> This pre-rendered app-root including app-my-loading-shell. The expectation is that it pre-renders only app-my-loading-shell and once the DOM is fully loaded at the browser, the pre-rendered content is replaced by the actual angular app.

  2. npm install http-server --global

  3. http-server -c-1 ./dist/my-app-shell

Observed behavior:
After step 6 mentioned above
a) localhost:8080 loads the index.html from ./dist/my-app-shell that contains both the app-root and app-my-loading-shell fully rendered
b) After the DOM is fully loaded (after downloading the whole app), there is no visible change in the browser.

Expected behavior:
a) localhost:8080 loads the index.html from ./dist/my-app-shell that contains only the app-my-loading-shell fully rendered
b) After the DOM is fully loaded (after downloading the whole app), the contents of app-my-loading-shell are replaced by the actual angular app app-root.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions