Workbox 5 | regeneratorRuntime is not defined

373 views Asked by At

I am trying to integrate workbox with webpack + React project using workbox-webpack-plugin

npm list workbox-webpack-plugin

+-- [email protected]
| `-- [email protected]

I want to add some custom code to service worker , hence using WorkboxPlugin.InjectManifest. As per my understanding, since i am using webpack InjectManifest plugin it will take care of bundling and compiling by itself after workbox 5 .As per google docs : The InjectManifest plugin handles both bundling and also injecting the precache manifest for you

My problem is when i am running local dev server, i am getting the below error :

Scenario 1 : If i am using only workbox.precaching.precacheAndRoute(self.__WB_MANIFEST); inside sw, i am getting below error

Error : Uncaught ReferenceError: workbox is not defined at Object../src/sw.js (sw.js:1) at __webpack_require__ (bootstrap:19) at bootstrap:83 at bootstrap:83

Scenario 2 : If i am using

import {precacheAndRoute} from 'workbox-precaching'
precacheAndRoute(self.__WB_MANIFEST);

in sw, i am getting below error: Error : cacheWrapper.mjs:36 Uncaught ReferenceError: regeneratorRuntime is not defined at cacheWrapper.mjs:36 at Module../node_modules/workbox-core/_private/cacheWrapper.mjs (cacheWrapper.mjs:36) at __webpack_require__ (bootstrap:19) at Module../node_modules/workbox-precaching/PrecacheController.mjs (pluginUtils.mjs:11) at __webpack_require__ (bootstrap:19) at Module../node_modules/workbox-precaching/utils/getOrCreatePrecacheController.mjs (getOrCreatePrecacheController.mjs:1) at __webpack_require__ (bootstrap:19) at Module../node_modules/workbox-precaching/utils/getCacheKeyForURL.mjs (generateURLVariations.mjs:23) at __webpack_require__ (bootstrap:19) at Module../node_modules/workbox-precaching/utils/addFetchListener.mjs (addFetchListener.mjs:1)

I have searched many articles regarding these and but nothing solves my pbm: Searched article : https://github.com/GoogleChrome/workbox/issues/2493

webpack.config.dev.js

const WorkboxPlugin = require('workbox-webpack-plugin');
new WorkboxPlugin.InjectManifest({
      swSrc: './src/sw.js',
      swDest: "sw.js"

    }),

Can any one help here!

0

There are 0 answers