angular/angular-cli

Script tags are not added to the child pages when build SSR project

chekit opened this issue · 2 comments

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

In certain scenarios when we build an SSR project the child pages are not getting script tags injected, thus any interactions on that pages are impossible.

The only page the gets references to the main scripts is index.html.


If the app's root tag specified as a self-closing tag, then after building the project the app's root tag will wrap the script tags. Internal pages won't get main script tags injected.

src/index.html:

<body>
  <app-performance-root />
</body>

dist/<project-name>/browser/index.html:

<body>
  <app-performance-root>
    <script src="polyfills.js" type="module"></script>
    <script src="main.js" type="module"></script>
  </app-performance-root>
</body>

If the app's root tag specified as a "normal" html tag, then everythings builds in order. Internal pages will get main script tags injected.

src/index.html:

<body>
  <app-performance-root></app-performance-root>
</body>

dist/<project-name>/browser/index.html:

<body>
  <app-performance-root></app-performance-root>
  <script src="polyfills.js" type="module"></script>
  <script src="main.js" type="module"></script>
</body>

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

n/a

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.5
Node: 20.11.1
Package Manager: yarn 1.22.19
OS: macOS Sonoma 14.4.1 (23E224)

Angular: 17.3.5
... animations, cdk, cli, common, compiler, compiler-cli, core, forms, material
... platform-browser, platform-browser-dynamic, router, platform-server, ssr

Package                         Version
---------------------------------------------------------
rxjs                            7.8.1
typescript                      5.4.2

Anything else?

No response

Duplicate of #27528

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.