Some services are not tree-shaken when unused
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 91
Mô tả
#### 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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với repository tái hiện treeshake-material được liên kết và các commit message của nó, sau đó tạo lại ứng dụng Angular 9.1.0 và kiểm tra các import trong AppModule cùng kích thước của các main.js được tạo. So sánh các build trước và sau khi import các module Angular Material không được sử dụng. Được xem là hoàn tất khi các import không được sử dụng không còn khiến build output tăng lên, trong khi các component và service được sử dụng vẫn khả dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript
- Lĩnh vực
- build-system, frontend, performance
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100