Unused code should be tree shaked with ng build --prod.
In example repo:
unusedFunction from apps/myapp/src/app/myFile.ts:8 shouldn't be present in bundled file.
Unused code isn't tree shaked with ng build --prod.
In example repo:
unusedFunction from apps/myapp/src/app/myFile.ts:8 is present in bundled file.
I suspect that tree shaking doesn't work. unusedFunction mentioned above should be tree shaked from build.
I created small repo to reproduce the issue here.
npm inpm run build:prodmain js file in dist/apps/myapp - unusedFunction is in bundled file. Please provide any relevant information about your setup:
@nrwl/[email protected]
Angular CLI: 7.0.6
I checked similar situation in project created with just ng cli (ng new) and unused function wasn't present in build.
Good catch!
I am working on a fix. To manually fix, you can add "module": "es2015" to compilerOptions in tsconfig.json
Thank You for quick response!
Most helpful comment
Good catch!
I am working on a fix. To manually fix, you can add
"module": "es2015"tocompilerOptionsintsconfig.json