Nx: Tree shaking issue

Created on 20 Nov 2018  路  2Comments  路  Source: nrwl/nx

Expected Behavior

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.

Current Behavior

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.

Failure Information (for bugs)

I suspect that tree shaking doesn't work. unusedFunction mentioned above should be tree shaked from build.

Steps to Reproduce

I created small repo to reproduce the issue here.

  1. Clone repo
  2. npm i
  3. npm run build:prod
  4. Check main js file in dist/apps/myapp - unusedFunction is in bundled file.

Context

Please provide any relevant information about your setup:

@nrwl/[email protected]
Angular CLI: 7.0.6

Other

I checked similar situation in project created with just ng cli (ng new) and unused function wasn't present in build.

bug

Most helpful comment

Good catch!

I am working on a fix. To manually fix, you can add "module": "es2015" to compilerOptions in tsconfig.json

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IonFoXx picture IonFoXx  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments

MichaelWarneke picture MichaelWarneke  路  3Comments

jon301 picture jon301  路  3Comments

jasedwards picture jasedwards  路  3Comments