Description
Which @angular/* package(s) are the source of the bug?
platform-server
Is this a regression?
No
Description
When using <app-root />
in index.html in an SSR-enabled app, with the application builder, instead of <app-root></app-root>
, then the scripts are not added to the generated page on the server.
When SSR is disabled, the self-closing tag works fine.
Even though one might argue that index.html is not a component template and that <app-root />
is not valid HTML, since it works without SSR but fails with it, the problem is not trivial to identify.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-9sgq9l?file=ssrbug%2Fsrc%2Findex.html
Please provide the exception or error you saw
Execute the following commands:
cd ssrbug
npm install
npm run start
See that the button increments the counter as expected.
Edit the index.html file and replace <app-root></app-root>
with <app-root />
.
Run npm run start
again. See that the button click doesn't work anymore. The JS scripts are not present in the generated HTML page anymore.
Edit the angular .json file and remove those properties, to disable SSR:
"server": "src/main.server.ts",
"prerender": true,
"ssr": {
"entry": "server.ts"
}
Run npm run start
again. See that the button works fine even with a self-closing tag when SSR is disabled.
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 17.0.0
Node: 18.18.0
Package Manager: npm 9.4.2
OS: linux x64
Angular: 17.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.0
@angular-devkit/build-angular 17.0.0
@angular-devkit/core 17.0.0
@angular-devkit/schematics 17.0.0
@angular/cli 17.0.0
@angular/ssr 17.0.0
@schematics/angular 17.0.0
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
This bug has been discovered by helping someone on the Angular discord. So it happened in a real-life scenario.