Solvedworkbox [v5.0.0-beta.1] Can't find self.__WB_MANIFEST in your SW source
✔️Accepted Answer
Your swSrc
shows:
precacheAndRoute(__WB_MANIFEST)
By default, you need to use self.__WB_MANIFEST
:
precacheAndRoute(self.__WB_MANIFEST)
(Unless you set injectionPoint: '__WB_MANIFEST'
, like you said.)
Apologies if this specific requirement caught you out while testing the beta releases, especially since we don't have the documentation in place yet. That's the default injectionPoint
that we're going with in v5 across all the build tools.
And again, the second error you encountered, once you got the injectionPoint
configuration resolved, should be addressed by #2251.
Other Answers:
I have encountered the same error whilst using webpack-workbox-plugin with the InjectManifest
function.
Adding literally just self.__WB_MANIFEST
to the bottom of my Service Worker file seems to have fixed it. I guess the plugin code expects to find this variable in the file and doesn't like it when it isn't there. It seems odd that I need to add this (seemingly useless, since I'm not interested in precaching) piece of boilerplate code into my service worker. Is the plugin really not able to do this? It also isn't in the documentation anywhere that I'd expect it to be. e.g. https://developers.google.com/web/tools/workbox/guides/precache-files/webpack
Library Affected:
workbox-webpack-plugin
Browser & Platform:
all browsers
Issue or Feature Request Description:
The issue has been introduced in v5.0.0-beta.1
During compilation:
if I set the
injectionPoint
explicitly with the default value (injectionPoint: '__WB_MANIFEST'
), the error is different