79317825

Date: 2024-12-30 14:16:32
Score: 0.5
Natty:
Report link

Cause: the issue is caused by "isolatedModules": true flag in tsconfig.json.

Explanation: when isolateModules is set to true, it applies some typescript restrictions to ensure that each file can be independently transpiled. This flag prevents typescript from doing the full code analysis needed to generate metadata for tree-shaking and causes all @Injectable() services to be included in the result bundle. It's because the compiler cannot tell whether the service is used or not.

Fix: remove isolateModules from tsconfig.json or set it to false.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Sasha