Some services are not tree-shaken when unused
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
#### Reproduction
The issue cannot be shown using StackBlitz, but the repository https://github.com/ranma42/treeshake-material can be used to reproduce it.
The steps to reproduce the issue are illustrated in the commit messages of the repository. Namely:
1. Create a new application with `ng new treeshake-material` with default settings (no routing, CSS style); it builds a 137 KB main.js.
2. Install `@angular/material` with default settings (indigo-pink theme, no typography styles, yes to browser animations); the main.js now is 207 KB.
3. Import several material modules in `AppModule` (without using any component or service); the main.js now is 271 KB.
It looks like some code is not being removed by the tree-shaking even if it is not being used.
#### Expected Behavior
The size of the build output does not grow unless components or services are actually used.
#### Actual Behavior
The size of the build output grows 2x just by installing and importing Angular Material modules, even if they are not being used.
#### Environment
- Angular: 9.1.0
- CDK/Material: 9.2.0
- Browser(s): -
- Operating System (e.g. Windows, macOS, Ubuntu): macOS
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par le dépôt de reproduction treeshake-material lié et ses messages de commit, puis recréez l’application Angular 9.1.0 et examinez les imports de AppModule ainsi que les tailles des main.js générés. Comparez les builds avant et après l’import de modules Angular Material inutilisés. Le travail est terminé lorsque les imports inutilisés n’entraînent plus l’augmentation de la sortie du build, tandis que les composants et services utilisés restent disponibles.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- build-system, frontend, performance
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100