Skip to content

Service Worker with ng build --prod error #8763

@KoldBrewEd

Description

@KoldBrewEd
> ng build --prod
Date: 2017-12-06T21:13:24.157Z
Hash: 3fb405a90a2041f6cbd3
Time: 116738ms
chunk {0} main.ff8fe03a5f3f52a1a90b.bundle.js (main) 1.47 MB [initial] [rendered]
chunk {1} polyfills.17a4fcb6e694c489ccd3.bundle.js (polyfills) 136 kB [initial] [rendered]
chunk {2} styles.5d12b9488551c2f2986e.bundle.css (styles) 31 kB [initial] [rendered]
chunk {3} inline.af36f1bf44c2ee9116c0.bundle.js (inline) 1.45 kB [entry] [rendered]

An error occured during the build:
TypeError: Cannot read property 'files' of undefined
    at Generator.<anonymous> (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:255:85)
    at step (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:71:23)
    at Object.next (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:52:53)
    at myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:45:71
    at new Promise (<anonymous>)
    at __awaiter (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:41:12)
    at myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:249:108
    at Array.map (<anonymous>)
    at Generator.<anonymous> (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:249:78)
    at step (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:71:23)
    at Object.next (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:52:53)
    at myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:45:71
    at new Promise (<anonymous>)
    at __awaiter (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:41:12)
    at Generator.processAssetGroups (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:244:16)
    at Generator.<anonymous> (myapp/node_modules/@angular/service-worker/bundles/service-worker-config.umd.js:224:51)
Cannot read property 'files' of undefined

> ng -v

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

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

@angular/cli: 1.6.0-rc.2
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.39
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0-rc.2
@schematics/angular: 0.1.9
typescript: 2.6.2
webpack: 3.10.0


If I set "serviceWorker": true in angular-cli.json I get the error above.

If I run "ng build" without --prod it works fine however my bundle size goes to 13Mb. If I set the serviceWorker to false it builds OK and my bundle is only 3Mb, however I have no PWA capability. It'd be great to have a small bundle + PWA goodness.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulseverity3: broken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions