angular-query-experimental: `import * as ng` in pending-tasks-compat pulls all of @angular/core into the initial bundle
Maintainer antworten meist innerhalb von 1 Tag
@benjavicente arbeitet bereits daran.
Seit 25.10.2026.
- #12386 von @mixelburg — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- angular, typescript
- Bereich
- frontend, performance
Rechercherichtung
Start with packages/angular-query-experimental/src/pending-tasks-compat.ts, then trace how create-base-query and inject-mutation import it. Compare production bundle output for the Angular 22 lazy route described in the issue, with and without the compat module. Done means injectQuery and injectMutation no longer prevent tree shaking of @angular/core, while builds remain compatible with Angular 16–18.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
packages/angular-query-experimental/src/pending-tasks-compat.ts reads PendingTasks through a namespace import:
import * as ng from '@angular/core'
// …
const token = Reflect.get(ng, 'PendingTasks')
Because the namespace object is accessed dynamically, esbuild (Angular's application builder) can't tree-shake @angular/core. create-base-query (injectQuery, injectInfiniteQuery) and inject-mutation import this module, so using them, even only in a lazy-loaded route, puts most of @angular/core into the initial chunk.
This was reported before in #11614. Its author closed it a few minutes later because they were working around it locally. It still reproduces on the latest release (5.104.5, same dist/pending-tasks-compat.mjs), so I'm opening a new issue to track it.
How to reproduce
Angular 22 app with the application builder (esbuild), production build:
provideTanStackQuery(new QueryClient())inapp.config.ts.- A lazy route (
loadComponent) whose component callsinjectQuery(...). ng buildand compare the initial bundle with and without step 2.
Numbers (our admin app, @tanstack/angular-query-experimental 5.104.1, Angular 22.2)
main-*.js |
Initial total | |
|---|---|---|
| As published | 512.14 kB | 515.56 kB |
pending-tasks-compat.mjs patched to a named import |
327.05 kB | 330.46 kB |
Almost all of the difference is @angular/core (raw, from esbuild stats: 140 kB → 409 kB in main). The app code is ~4 kB in both builds.
Expected behavior
Using injectQuery/injectMutation shouldn't stop @angular/core from being tree-shaken.
Notes / possible directions
We know the namespace access is there because the peer range is @angular/core >=16 and PendingTasks only exists from v19, so a plain import { PendingTasks } would break builds on 16–18. Some options:
- Drop the compat shim when the minimum supported Angular becomes 19 (named import, no
Reflect.get). - Until then, keep the shim behind a separate entry point or build condition, so apps on ≥19 get the named import.
Workaround we use for now (Angular 22): a pnpm patch that replaces the namespace import with import { InjectionToken, PendingTasks, inject } from "@angular/core" and inject(PendingTasks, { optional: true }).
Versions
- @tanstack/angular-query-experimental: 5.104.1 (also checked 5.104.5)
- @angular/core: 22.2.3, application builder (esbuild)
- Vorherrschende Sprache
- TypeScript
- Sterne
- 50.5k
- Forks
- 4.2k
- Ø Merge
- 8 Std. 14 Min.
- Gemergte PRs (30 T.)
- 632
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Evtl. wieder frei @LeonxLJX hat das vor 52 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/query#11358 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
useBaseQuery fetches the old query key when an <Activity> tree is revealedEvtl. vergeben @lazerg hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
[query-broadcast-client-experimental] broadcastQueryClient: an `added` event overwrites a receiving query that has no data (e.g. in error) with the sender's empty stateEvtl. vergeben @lazerg hat das vor 6 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingEvtl. vergeben @UzumakiODZ hat das vor 11 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 28/100
TanStack/query#12031 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryEvtl. vergeben @AdzerKI hat das vor 12 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
TanStack/query#12025 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
ajv-validator/ajv#2689 ·
-
[Bug]: IME confirmation Enter can submit the SSH port-forward dialogEvtl. vergeben @seijikohara hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
home-assistant/frontend#55323 ·
Maintainer antworten meist innerhalb von 1 Tag
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
lingdojo/kana-dojo#33188 · 1 Kommentar · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
self-driving
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag