workbox is not defined inside js passed in importScripts

127 views Asked by At

Library Affected: workbox-webpack-plugin

Browser & Platform: all browsers

Issue or Feature Request Description: I am using workbox-webpack-plugin to setup my service worker. I added the GenerateSW in my webpack config that also has an importScripts as follows:

importScripts: ["./test/new.js"],

however, when I load the webpage I get an error saying "workbox is not defined".

Uncaught (in promise) ReferenceError: workbox is not defined
    at new.js:1:790

This is because the new.js file has no reference to the workbox object. My service worker js gets loaded first and it then initiates request for workbox.js.

The docs claim that the workbox object will get auto injected during build, but this does not seem like the case (or am I totally wrong?); Is the new.js running before the workbox.js could be downloaded? Could someone please point me what I am doing wrong here?

0

There are 0 answers