angular / angular/angular-cli

feat: add option to disable route extraction feature

Offen
#31,340 14 Kommentare 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: @angular/ssr feature feature: insufficient votes
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

### Command

build

### Description

When migrating apps to SSR, route extraction basically gets in the way and makes it harder to understand where the issue/error is coming from, as it tries to run before everything else either during build or server.

Instead of fixing other SSR related errors, I have to go and fix route extraction issues.

Also, there is no way to know if route extraction is happening. But even if it was possible the code would be full of checks on what mode is Angular running, and having to deal with all the states instead of just handling a normal case of -> open the url -> render angular -> serve html.

### Describe the solution you'd like

Add a flag to disable route extraction during build or serve totally, at least just for development purposes.
When routes are dynamically loaded based on config, having the extraction happen before the config can be loaded breaks the dynamic apps. If I build my app with a config that has 3 routes, and then on runtime I want to use another config.json file to load other routes (that also include the first three but with different configs), would cause my app to misbehave because of the initial extracted routes.

---

`NG_BUILD_PARTIAL_SSR=1` partially solves this by skipping the route extraction and doing it initial request.

### Repo
Comment out line 9 to better understand that serving or building the app is painful, even though on normal conditions opening localhost:4200/config.json loads fine.

https://github.com/eneajaho/dx-issue/blob/main/src/main.server.ts#L9

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Build-Befehl und dem bestehenden Verhalten von NG_BUILD_PARTIAL_SSR=1 und reproduziere dann das Problem anhand von Zeile 9 in src/main.server.ts im verlinkten Beispiel-Repository. Als erledigt gilt, wenn ein Flag die Routenermittlung während des Builds oder des Servens deaktivieren kann, während Anwendungen mit dynamisch geladenen Routen weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
build-system, web-dev
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.