angular-query-experimental: `import * as ng` in pending-tasks-compat pulls all of @angular/core into the initial bundle
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 52/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- angular, typescript
- Domaine
- frontend, performance
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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)
- Langage dominant
- TypeScript
- Étoiles
- 50.5k
- Forks
- 4.2k
- Merge moyen
- 8 h 21 min
- PR mergées (30 j)
- 621
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Peut-être à nouveau libre @LeonxLJX l’a pris il y a 53 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
TanStack/query#11358 · 2 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
useBaseQuery fetches the old query key when an <Activity> tree is revealedPeut-être pris @lazerg l’a pris il y a 6 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
Les mainteneurs répondent en général sous 1 jour
-
[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 statePeut-être pris @lazerg l’a pris il y a 7 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
Les mainteneurs répondent en général sous 1 jour
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingPeut-être pris @UzumakiODZ l’a pris il y a 12 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 28/100
TanStack/query#12031 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryPeut-être pris @AdzerKI l’a pris il y a 13 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
TanStack/query#12025 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/query
Issues similaires
-
New icon: `filter-clear`Ouvertecalcite-ui-icons enhancement impact - p3 - not time sensitive needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
Esri/calcite-design-system#15467 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
diegosouzapw/OmniRoute#18390 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Difficulté 1/5 1-3 heures Accessibilité débutants 86/100
guilhermerodz/input-otp#157 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
davidjerleke/embla-carousel#1414 ·
Les mainteneurs répondent en général sous 4 jours