-
Notifications
You must be signed in to change notification settings - Fork 12k
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
SSR/SSG: scripts not added to generated page if self-closing tag used for root component in index.html #27528
Comments
I would exactly make this argument. We expect I can see an argument that CSR and SSR should probably align their behavior, but I'd probably lean towards not working in both cases. That said, we could probably do better with an error message here. The exact semantics of |
Agreed. That was the point: an error message that would make things clearer. |
This is a Domino/platform-server issue. |
Being someone myself who recently spent a solid days worth of work narrowing down an issue to this exact issue, an error message would have been helpful. Not exactly sure how that error message should be presented, but wondering if leaving just an HTML comment in the |
Spent good chunk of the day understanding what the hell was going wrong with my application. So the app works fine if you do not use SSR, but if you use, you lose all the events! Some sort of message would be very helpful, but would be way better if this was supported, and the point is not only about the self closing tags, but also the bootstrap component having attribute selector(the case that I had). I, for example, do not like extra tag in HTML. So having a |
…ndex HTML When an invalid self-closing HTML element is used in the index.html file, the build proceeds without raising an error, potentially leading to runtime issues. Now, when an invalid self-closing element is encountered in the index.html file, the build process issues an error, providing developers with immediate feedback to correct the issue. Closes: angular#27528
…ndex HTML When an invalid self-closing HTML element is used in the index.html file, the build proceeds without raising an error, potentially leading to runtime issues. Now, when an invalid self-closing element is encountered in the index.html file, the build process issues an error, providing developers with immediate feedback to correct the issue. Closes: angular#27528
…ndex HTML When an invalid self-closing HTML element is used in the index.html file, the build proceeds without raising an error, potentially leading to runtime issues. Now, when an invalid self-closing element is encountered in the index.html file, the build process issues an error, providing developers with immediate feedback to correct the issue. Closes: angular#27528
We came across this issue when we were refactoring our codebase to use self-closing tags for all NG components. This mindset led us to set the root component in the Only finding this issue when we rebuilt and deployed to a hosted environment meant that we had a large feature PR of changes to pick through. A build error is needed to highlight the invalid index.html otherwise it is very time-consuming to look for an unknown cause of the failure. |
…ndex HTML When an invalid self-closing HTML element is used in the index.html file, the build proceeds without raising an error, potentially leading to runtime issues. Now, when an invalid self-closing element is encountered in the index.html file, the build process issues an error, providing developers with immediate feedback to correct the issue. Closes: angular#27528
…ndex HTML When an invalid self-closing HTML element is used in the index.html file, the build proceeds without raising an error, potentially leading to runtime issues. Now, when an invalid self-closing element is encountered in the index.html file, the build process issues an error, providing developers with immediate feedback to correct the issue. Closes: #27528
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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:
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:
Run
npm run start
again. See that the button works fine even with a self-closing tag when SSR is disabled.Anything else?
This bug has been discovered by helping someone on the Angular discord. So it happened in a real-life scenario.
The text was updated successfully, but these errors were encountered: