workbox icon indicating copy to clipboard operation
workbox copied to clipboard

workbox is not defined inside importScripts js

Open VishalGulati opened this issue 2 years ago • 1 comments

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?

VishalGulati avatar Sep 04 '23 16:09 VishalGulati

I'm having the same issue. (This was code that was working before)

Uncaught (in promise) ReferenceError: workbox is not defined at IndexedDB-Redirect.js:127:47

image

jhobbs919 avatar Nov 10 '23 03:11 jhobbs919

Hi there,

Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:

Thanks, and we hope for your understanding! The Workbox team

tomayac avatar Apr 25 '24 08:04 tomayac