Production stripping misses plugin factory imports, leaving unused Hotkeys font assets
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript, vite
Piste de recherche
Commencez dans packages/devtools-bundler-core/src/remove-devtools.ts, en particulier dans getPluginReferences, et exécutez la reproduction autonome de removeDevtools issue du ticket. Vérifiez comment les expressions d’appel direct dans le tableau plugins sont traitées et recherchez des tests associés dans le package bundler-core. Le travail est terminé lorsque l’importation de la factory est supprimée si elle est utilisée uniquement dans l’élément retiré, mais conservée si elle est utilisée ailleurs.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
TanStack Devtools version
@tanstack/react-devtools:0.10.14@tanstack/devtools-vite:0.8.6@tanstack/devtools-bundler-core:0.1.4@tanstack/react-hotkeys-devtools:0.14.1- Transitive
@tanstack/devtools-ui:0.7.2
Framework/Library version
React 19.3.1; TanStack Start 1.169.4; Vite 8.3.5 / Rolldown 1.2.7 through Vite+ 1.4.0; Node.js 26.13.0.
Describe the bug
The production transform removes <TanStackDevtools> but leaves a plugin factory's import when the factory is used directly in the plugins array:
import { TanStackDevtools } from '@tanstack/react-devtools';
import { hotkeysDevtoolsPlugin } from '@tanstack/react-hotkeys-devtools';
export const App = () => (
<TanStackDevtools plugins={[hotkeysDevtoolsPlugin()]} />
);
hotkeysDevtoolsPlugin is used only inside the removed element, but its import survives. The equivalent inline { name: 'Hotkeys', render: <HotkeysDevtoolsPanel /> } form removes both the element and the plugin import.
This occurs with devtools() first in the Vite plugins array and the default production removal enabled.
Minimal reproduction
The following isolates the stripping bug without a browser, app configuration, or access to the downstream repository. The React imports are source text passed to the parser, so only the bundler-core package needs to be installed.
Run in an empty directory:
npm init -y
npm install --save-exact @tanstack/[email protected]
node --input-type=module <<'NODE'
import { removeDevtools } from '@tanstack/devtools-bundler-core';
const factory = `import { TanStackDevtools } from '@tanstack/react-devtools';
import { hotkeysDevtoolsPlugin } from '@tanstack/react-hotkeys-devtools';
export const App = () => <TanStackDevtools plugins={[hotkeysDevtoolsPlugin()]} />;`;
const panel = `import { TanStackDevtools } from '@tanstack/react-devtools';
import { HotkeysDevtoolsPanel } from '@tanstack/react-hotkeys-devtools';
export const App = () => <TanStackDevtools plugins={[{name: 'Hotkeys', render: <HotkeysDevtoolsPanel/>}]} />;`;
for (const [name, source] of Object.entries({ factory, panel })) {
console.log(`${name}:\n${removeDevtools(source, 'App.tsx')?.code}`);
}
NODE
Actual output, reproduced against the installed package:
factory:
import { hotkeysDevtoolsPlugin } from '@tanstack/react-hotkeys-devtools';
export const App = () => null;
panel:
export const App = () => null;
Expected behavior
Both examples should produce export const App = () => null;, with no plugin import left behind. A factory import used elsewhere should of course be preserved.
Source investigation
In getPluginReferences, each array element is skipped unless it is an ObjectExpression:
if (!el || el.type !== 'ObjectExpression') continue
A direct hotkeysDevtoolsPlugin() entry is a CallExpression, so its identifier is never collected for the subsequent plugin-import cleanup. The logic handles calls inside an object's render property, but not calls directly inside the plugins array.
Associated production-build impact
Our production client build contains no retained devtools modules, but emits these unreferenced fonts from @tanstack/devtools-ui:
| Asset | Uncompressed bytes |
|---|---|
BricolageGrotesque-Bold-BIJrwikb.BIJrwikb.ttf |
82,204 |
Inter-latin-BwkfbSeq.BwkfbSeq.woff2 |
72,920 |
| Total | 155,124 (151.49 KiB) |
Neither filename is referenced by the generated client JS, CSS, HTML, or JSON. This increases emitted-output measurements; it is not evidence of an additional browser download.
The surviving static import appears to expose Vite's related unused-asset retention behavior (vitejs/vite#9073). The transform reproduction above establishes the import-cleanup gap independently of that bundler behavior.
Downstream tracking
Found while investigating mykiary/caniplay.today#293. That repository is private; the standalone reproduction above does not require access.
No upstream fix PR yet.
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- Langage dominant
- TypeScript
- Étoiles
- 510
- Forks
- 103
- Merge moyen
- 15 h 31 min
- PR mergées (30 j)
- 4
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/devtools
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
devtools-vite: four transform hooks have no filter, and inject-plugin parses pre-bundled dependency chunksPeut-être pris @shkumbinhasani l’a pris il y a 16 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 38/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 52/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
Toutes les issues de TanStack/devtools
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
caprover/caprover-frontend#273 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ai-driven-dev/framework#1147 ·
Les mainteneurs répondent en général sous 1 jour
-
agent-ui bug p2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
amd/gaia#6580 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
cybersemics/em#6232 ·
Les mainteneurs répondent en général sous 1 jour