angular-query-experimental: `import * as ng` in pending-tasks-compat pulls all of @angular/core into the initial bundle
Mantenedores costumam responder em até 1 dia
@benjavicente já está trabalhando nisso.
Desde 25/10/2026.
- #12386 de @mixelburg — fechado sem integrar
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 52/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- angular, typescript
- Domínio
- frontend, performance
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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)
- Linguagem predominante
- TypeScript
- Estrelas
- 50.5k
- Forks
- 4.2k
- Merge médio
- 8h 14min
- PRs com merge (30d)
- 632
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Talvez livre de novo @LeonxLJX assumiu há 53 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/query#11358 · 2 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
useBaseQuery fetches the old query key when an <Activity> tree is revealedTalvez já em andamento @lazerg assumiu há 6 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
[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 stateTalvez já em andamento @lazerg assumiu há 7 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 1 dia
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingTalvez já em andamento @UzumakiODZ assumiu há 12 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 28/100
TanStack/query#12031 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryTalvez já em andamento @AdzerKI assumiu há 13 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
TanStack/query#12025 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/query
Issues semelhantes
-
backend refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
NIAEFEUP/tts#927 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
callstackincubator/react-native-harness#296 ·
Mantenedores costumam responder em até 1 dia
-
status:in-linear
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
n8n-io/n8n#42293 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
verified
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
Mantenedores costumam responder em até 5 dias
-
Add inputmode attribute support (forwarded to the inner input)Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertaenhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Neovici/cosmoz-input#467 ·
Mantenedores costumam responder em até 1 dia