Angular-cli: ng build --prod doesn't minified ngsw-worker.js

Created on 15 Mar 2018  路  7Comments  路  Source: angular/angular-cli

When building for production environment ngsw-worker/js file included in /DIST folder isn;y minified. We can save 75 KB and get better performance

Version 1.7.3

Angular CLI: 1.7.3
Node: 9.5.0
OS: win32 x64
Angular: 5.2.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

Repro steps

  • Step 1: run ng build --prod
  • Step 2 go to dist foled
  • Step 3 Open the ngsw-worker.js. You will see coment and a readeable js file

Observed behavior

The file contains 107KB of code

Desired behavior

The file is minified and contains less than 35KB of code

devkibuild-angular

Most helpful comment

Neither it is transpiled down to ES5. Service workers are supported in environments where async functions aren't (Chrome <= 54) so it fails.

All 7 comments

Neither it is transpiled down to ES5. Service workers are supported in environments where async functions aren't (Chrome <= 54) so it fails.

It seems to be transpiled down to ES2015 now, using generators instead of async/await. Still no minification though.

Just leaving a note here... Be very careful about fixing this bug as a lot of people are working around this issue https://github.com/angular/angular/issues/21191 by inserting specific code in this very file. See comment: https://github.com/angular/angular/issues/21191#issuecomment-360051276

Maybe issue https://github.com/angular/angular/issues/21191 should be addressed first

EDIT: I know that this issue _shouldn't_ depend on the other one. If a fix is possible to minify ngsw-worker.js, it should be addressed.

Heya, this issue is the same as https://github.com/angular/angular-cli/issues/11538. I'm closing this one in favor of that one because it has an answer from the team member responsible for service workers.

@filipesilva this one is #9970, I guess you mean another.

@awerlang sorry about that, fixed the link now.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purushottamjha picture purushottamjha  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

ericel picture ericel  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments