Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] staticFileGlobs in sw-precache-config not process in build #2207

Closed
alimd opened this issue Aug 6, 2016 · 9 comments
Closed

[bug] staticFileGlobs in sw-precache-config not process in build #2207

alimd opened this issue Aug 6, 2016 · 9 comments

Comments

@alimd
Copy link

alimd commented Aug 6, 2016

Description

staticFileGlobs in sw-precache-config.js not process in build and compiled service-worker.js not contain these files!

Versions & Environment

  • Polymer CLI: 0.13.0
  • node: 6.3.1 and 4.4.7
  • Operating System: OS X 10.11.6

Steps to Reproduce

  1. edit sw-precache-config.js
module.exports = {
  staticFileGlobs: [
    '/index.html',
    '/src/manifest.json',
    '/bower_components/webcomponentsjs/webcomponents-lite.min.js',
    '/src/images/*'
  ]
};
  1. polymer build

Expected Results

compiled service-worker.js in PrecacheConfig array contain staticFileGlobs files
or in browser app work fully offline in second visit

Actual Results

app not work offline for staticFileGlobs files and images or manifest load every time from net or fail in offline mode!

Other auto detect files and components work offline

@VandeurenGlenn
Copy link

Same here, PrecacheConfig contains all items defined in polymer.json butt doesn't contain the files defined in sw-precache-config.js

@evtaranov
Copy link

+1 and it is very critical.
My bundled version does not work in Firefox and Safari anymore (

@perciag
Copy link

perciag commented Aug 20, 2016

i had copy to folder build/unbundled manually, that's very bad.

@veith
Copy link

veith commented Aug 23, 2016

Do not forget to copy the files before you run polymer build. Otherwise your service-worker.js will not contain the files, because sw-precache checks if the files exists.

@FredKSchott
Copy link
Contributor

Oh yea, jeeze look at this (output from when I run polymer build --verbose in the shop template):

{ staticFileGlobs: 
   [ 'build/bundled/build/unbundled/index.html',
     'build/bundled/build/unbundled/manifest.json',
     'build/bundled/build/unbundled/bower_components/webcomponentsjs/webcomponents-lite.min.js',
     'build/bundled/build/unbundled/images/*',
     'build/bundled/build/unbundled/src/shop-app.html',
     'build/bundled/build/unbundled/src/shop-list.html',
     'build/bundled/build/unbundled/src/shop-detail.html',
     'build/bundled/build/unbundled/src/shop-cart.html',
     'build/bundled/build/unbundled/src/shop-checkout.html',
     'build/bundled/build/unbundled/src/lazy-resources.html',
     'build/bundled/build/unbundled/index.html',
     'build/bundled/build/unbundled/bower_components/polymer/polymer.html',
     'build/bundled/build/unbundled/bower_components/polymer/polymer-mini.html',
     'build/bundled/build/unbundled/bower_components/polymer/polymer-micro.html',
     'build/bundled/build/unbundled/src/shop-button.html',
     'build/bundled/build/unbundled/src/shop-common-styles.html',
     'build/bundled/build/unbundled/bower_components/iron-flex-layout/iron-flex-layout.html',
     'build/bundled/build/unbundled/src/shop-form-styles.html',
     'build/bundled/build/unbundled/bower_components/app-route/app-route.html',
     'build/bundled/build/unbundled/src/shop-category-data.html',
     'build/bundled/build/unbundled/src/shop-image.html',
     'build/bundled/build/unbundled/src/shop-list-item.html',
     'build/bundled/build/unbundled/src/shop-select.html',
     'build/bundled/build/unbundled/src/shop-input.html',
     'build/bundled/build/unbundled/src/shop-checkbox.html',
     'build/bundled/build/unbundled/bower_components/app-layout/app-header/app-header.html',
     'build/bundled/build/unbundled/bower_components/iron-resizable-behavior/iron-resizable-behavior.html',
     'build/bundled/build/unbundled/bower_components/app-layout/app-scroll-effects/app-scroll-effects-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-scroll-target-behavior/iron-scroll-target-behavior.html',
     'build/bundled/build/unbundled/bower_components/app-layout/helpers/helpers.html',
     'build/bundled/build/unbundled/bower_components/app-layout/app-scroll-effects/effects/waterfall.html',
     'build/bundled/build/unbundled/bower_components/app-layout/app-toolbar/app-toolbar.html',
     'build/bundled/build/unbundled/bower_components/app-route/app-location.html',
     'build/bundled/build/unbundled/bower_components/iron-location/iron-location.html',
     'build/bundled/build/unbundled/bower_components/iron-location/iron-query-params.html',
     'build/bundled/build/unbundled/bower_components/app-route/app-route-converter-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-media-query/iron-media-query.html',
     'build/bundled/build/unbundled/bower_components/iron-pages/iron-pages.html',
     'build/bundled/build/unbundled/bower_components/iron-selector/iron-selectable.html',
     'build/bundled/build/unbundled/bower_components/iron-selector/iron-selection.html',
     'build/bundled/build/unbundled/bower_components/iron-selector/iron-selector.html',
     'build/bundled/build/unbundled/bower_components/iron-selector/iron-multi-selectable.html',
     'build/bundled/build/unbundled/src/shop-home.html',
     'build/bundled/build/unbundled/bower_components/app-layout/app-drawer/app-drawer.html',
     'build/bundled/build/unbundled/bower_components/paper-icon-button/paper-icon-button.html',
     'build/bundled/build/unbundled/bower_components/iron-icon/iron-icon.html',
     'build/bundled/build/unbundled/bower_components/iron-meta/iron-meta.html',
     'build/bundled/build/unbundled/bower_components/paper-behaviors/paper-inky-focus-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-behaviors/iron-button-state.html',
     'build/bundled/build/unbundled/bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-behaviors/iron-control-state.html',
     'build/bundled/build/unbundled/bower_components/paper-behaviors/paper-ripple-behavior.html',
     'build/bundled/build/unbundled/bower_components/paper-ripple/paper-ripple.html',
     'build/bundled/build/unbundled/bower_components/paper-styles/default-theme.html',
     'build/bundled/build/unbundled/bower_components/paper-styles/color.html',
     'build/bundled/build/unbundled/src/shop-analytics.html',
     'build/bundled/build/unbundled/src/shop-cart-data.html',
     'build/bundled/build/unbundled/bower_components/iron-localstorage/iron-localstorage.html',
     'build/bundled/build/unbundled/src/shop-cart-modal.html',
     'build/bundled/build/unbundled/bower_components/iron-overlay-behavior/iron-overlay-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-fit-behavior/iron-fit-behavior.html',
     'build/bundled/build/unbundled/bower_components/iron-overlay-behavior/iron-overlay-manager.html',
     'build/bundled/build/unbundled/bower_components/iron-overlay-behavior/iron-overlay-backdrop.html',
     'build/bundled/build/unbundled/src/shop-icons.html',
     'build/bundled/build/unbundled/bower_components/iron-iconset-svg/iron-iconset-svg.html',
     'build/bundled/build/unbundled/src/shop-snackbar.html',
     'build/bundled/build/unbundled/src/shop-tabs.html',
     'build/bundled/build/unbundled/src/shop-tabs-overlay.html',
     'build/bundled/build/unbundled/src/shop-tab.html',
     'build/bundled/build/unbundled/src/shop-ripple-container.html',
     'build/bundled/build/unbundled/src/shop-network-warning.html',
     'build/bundled/build/unbundled/src/shop-cart-item.html',
     'build/bundled/build/unbundled/bower_components/iron-form/iron-form.html',
     'build/bundled/build/unbundled/bower_components/iron-ajax/iron-ajax.html',
     'build/bundled/build/unbundled/bower_components/iron-ajax/iron-request.html',
     'build/bundled/build/unbundled/bower_components/promise-polyfill/promise-polyfill-lite.html',
     'build/bundled/build/unbundled/bower_components/paper-spinner/paper-spinner-lite.html',
     'build/bundled/build/unbundled/bower_components/paper-spinner/paper-spinner-behavior.html',
     'build/bundled/build/unbundled/bower_components/paper-spinner/paper-spinner-styles.html',
     'build/bundled/build/unbundled/bower_components/promise-polyfill/Promise.js',
     'build/bundled/src/shop-app.html',
     'build/bundled/src/shop-list.html',
     'build/bundled/src/shop-detail.html',
     'build/bundled/src/shop-cart.html',
     'build/bundled/src/shop-checkout.html',
     'build/bundled/src/lazy-resources.html',
     'build/bundled/index.html',
     'build/bundled/shared-bundle.html' ],
  navigateFallback: '/index.html',
  navigateFallbackWhitelist: [ /^(?!.*\.html$|\/data\/).*/ ],
  runtimeCaching: 
   [ { urlPattern: /\/data\/images\/.*/,
       handler: 'cacheFirst',
       options: { cache: { maxEntries: 200, name: 'items-cache' } } },
     { urlPattern: /\/data\/.*json/,
       handler: 'fastest',
       options: { cache: { maxEntries: 100, name: 'data-cache' } } } ],
  stripPrefix: 'build/bundled',
  logger: [Function: bound _log],
  cacheId: '',
  directoryIndex: 'index.html',
  dynamicUrlToDependencies: {},
  handleFetch: true,
  ignoreUrlParametersMatching: [ /^utm_/ ],
  importScripts: [],
  maximumFileSizeToCacheInBytes: 2097152,
  replacePrefix: '',
  templateFilePath: '/Users/fschott/Code/polytool/node_modules/sw-precache/service-worker.tmpl',
  verbose: false }

It looks like we're running into a problem where the same swConfig object is being sent to both builds (bundled & unbundled) and then the staticFileGlobs array is shared and modified between the two. No good.

I'll try to fix this ASAP so that we can get a fix out in the next release.

@FredKSchott
Copy link
Contributor

Thanks for reporting @alimd & all

@FredKSchott
Copy link
Contributor

PR to fix: Polymer/polymer-build#27

@FredKSchott
Copy link
Contributor

Fixed in v0.16.0 (just pushed out)

@veith
Copy link

veith commented Aug 25, 2016

Thanks a lot.

But i think this is not the expected behavior. When you make a clean build (or first build) the files from staticFileGlobs are not copied. Therefore they are not listed in service-worker.js.

@FredKSchott Please reopen this issue.

veith referenced this issue in veith/polymer-cli Aug 25, 2016
Copy the files defined in sw-precache-config.js (staticFileGlobs) to build/bundled and build/unbundled
@aomarks aomarks transferred this issue from Polymer/polymer-cli Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants