Skip to content

unused classes got added in build, tree-shaking not working propely #15396

@Saranya13

Description

@Saranya13

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes

Description

Tree-shaking not working as expected

🔬 Reproducing steps

  1. download below sample

tree-shake.zip

  1. run "npm i"

  2. then give "ng build --prod"

check build source-
In that, "main-es5.js" and "main-es2015.js" has all modules, no tree shaking.

check string [getModuleName=function()] in bundle file , you can find it 61 times which means all other modules are imported even if they are not used. This shows unused classes are not getting tree-shaken.

🔥 Exception or Error

While using GridAllModule , build size is 1.8mb

Screenshot (27)

While using GridModule which has less no of imported class, build size is same.

Screenshot (29)

🌍 Your Environment


"@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
"@angular-devkit/build-angular": "~0.802.0",
    "@angular/cli": "~8.2.0",
    "@angular/compiler-cli": "~8.2.0",
    "@angular/language-service": "~8.2.0",
@angular-devkit/[email protected]

Anything else relevant?
#14585
#14577

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions