angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Service Worker ng build --prod build fails with CLI 1.5.3

Open mavogel opened this issue 9 years ago • 7 comments

Versions

_                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
|___/

Angular CLI: 1.5.3
Node: 8.9.1
OS: darwin x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.5.3
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

Repro steps

  • ng new myApp --service-worker=true
  • cd myApp
  • ng build --prod

Observed behavior

The installed version of @angular/service-worker is 5.0.2. This version of the CLI
requires the @angular/service-worker version to satisfy >= 1.0.0-beta.5 < 2.0.0. Please upgrade
your service worker version.

Desired behavior

prod build works without this error because its the modern sw

Mention any other details that might be useful (optional)

  • Similar to 8322
  • Checked PR-8080 and I guess isModernSw flag is not detected correctly.

mavogel avatar Nov 21 '17 19:11 mavogel

Same problem here

ghost avatar Nov 21 '17 22:11 ghost

As far as I know the new Service Worker is not implemented in angular-cli yet. Maybe it will come with angular-cli 1.6, but the new service worker comes with a cli tool on itself you can use.

wambowams avatar Nov 22 '17 10:11 wambowams

@wambowams yes I heard that as well, but then it confuses me that the offer the --service-worker flag already. Like @webmaxru explains in his angularconnect-slides that the feature comes with angular-cli 1.6 The steps from slide26 don't work either then with angular-cli 1.5.3

Hence any suggestions how to use it or just wait until the release @hansl ?

mavogel avatar Nov 22 '17 10:11 mavogel

I tried this tutorial: https://medium.com/google-developer-experts/a-new-angular-service-worker-creating-automatic-progressive-web-apps-part-2-practice-3221471269a1 But some other errors occurred regarding the caching functionality.

wambowams avatar Nov 22 '17 10:11 wambowams

Please run:

npm install -g @angular/cli@next

if you have it installed local run

npm install @angular/cli@next

and then make sure to move your ngsw-config.json to the root folder @wambowams I also used that tutorial and coupled with this I got it up and running

kenisteward avatar Nov 23 '17 01:11 kenisteward

@kenisteward thanks a lot 👍 Fortunately the 1.6.0-rc0 was released 2 hours ago. No more copying of the ngsw-config.json is needed. The new cli does it out of the box

This works for me:

# make sure you have 1.6
npm i -g @angular/cli@next
ng new myApp --service-worker=true
ng build --prod

Versions

_                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
/ ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
|___/

Angular CLI: 1.6.0-rc.0
Node: 8.9.1
OS: darwin x64
Angular: 5.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.6.0-rc.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0-rc.0
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: 3.8.1

mavogel avatar Nov 23 '17 08:11 mavogel

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.