-
Notifications
You must be signed in to change notification settings - Fork 851
Description
Library Affected:
workbox-build 3.0.0-alpha.5
Browser & Platform:
tested on Google Chrome 63.0.3239.132
Issue or Feature Request Description:
This is the error I get (configuration and resulting sw.js below):
Uncaught TypeError: Class constructor Plugin cannot be invoked without 'new'
(anonymous) @ sw.js:50
Manually adding new
before workbox.cacheableResponse.Plugin
yields:
TypeError: Failed to execute 'put' on 'Cache': parameter 2 is not of type 'Response'
in workbox-core.dev.js:836 (yield cache.put(request, responseToCache);
) but only on the first page refresh after installing the service worker. The image is served when offline, but isn't listed in Application > Cache Storage > workbox-runtime-...
.
configuation: (similar to https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build.html#.Configuration - Section runtimeCaching
)
workbox.generateSW({
"globDirectory": "somedir/",
"globPatterns": [
"**/*.{html,js,css,jpg,png}"
],
"swDest": "somedir/dist/sw.js",
"navigateFallback": "dist/index.html",
"clientsClaim": true,
"skipWaiting": true,
"runtimeCaching": [
{
"urlPattern": "https://cdn.rawgit.com/parcel-bundler/website/01a1f7dd/src/assets/parcel%403x.png",
"handler": "cacheFirst",
"options": {
"cacheableResponse": {
"statuses": [0]
}
}
}
]
})
sw.js
importScripts(
"https://storage.googleapis.com/workbox-cdn/releases/3.0.0-alpha.5/workbox-sw.js"
);
workbox.skipWaiting();
workbox.clientsClaim();
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = [
...
].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
workbox.routing.registerNavigationRoute("dist/index.html");
workbox.routing.registerRoute("https://cdn.rawgit.com/parcel-bundler/website/01a1f7dd/src/assets/parcel%403x.png", workbox.strategies.cacheFirst({ plugins: [workbox.cacheableResponse.Plugin({"statuses":[0]})] }), 'GET');