-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby-plugin-offline): Upgrade workbox to v6 #31542
base: master
Are you sure you want to change the base?
fix(gatsby-plugin-offline): Upgrade workbox to v6 #31542
Conversation
…jectManifest & webpack-plugin / refactored serviceworker content to a somewhat modular structure
… old cache versions on service worker update
…tsby-plugin-offline
I'm not quite sure what the issue with the 2 remaining failing e2e tests is. Seems somewhat unrelated to the changes in this PR? |
Yes, those two e2e tests are failing on every PR atm. |
…7-update-workbox-gatsby-plugin-offline
So I think this PR is ready to be reviewed if someone wants to review it. Happy to work on any feedback 👍 |
…tsby-plugin-offline
was hoping this will be added in current release, I guess I have to wait for next release now :) |
@LekoArts nto sure if you are the right person to mention, but you were the one who replied to my initial issue and suggested I should create a PR. Will this PR still get reviewed? |
@kije could you please confirm if below mentioned problem is solved with this release reference 1 : https://stackoverflow.com/a/67377906 problem with current version offline plugin: I wanted to setup the offline page functionality to overcome this error page. so when user tries to browse the page which is not cached yet he can at least see offline page. I found two above resources to achieve this. I implemented this but still results weren't as expected so when I dig further and I found that current offline plugin is based on workbox v4.3.1 so this cannot be implemented out of the box. so for the time being I have commented out the code and added reference to this PR to keep track on this. I am hoping we can implement offline.html page functionality with above two references with this PR . Please confirm. also if there is any alternate ways to implement offline.html page add them in release notes too. this will be nice feature to have Thank you in advance |
@jangam I'd have too look deeper into the issue you mentioned to comment on if it is solved or improved with this PR or not. I primarely focused on upgrading to the latest workbox version while preserving as much of the behaviour and functionality of the existing gatsby-plugin-offline as possible (with the exeption of also solving/improving the issues mentioned here: However, a year ago I also tried to implement the offline page functionality you described in a project of mine, and also didn't get reliable/satisfactory results. If I remember correctly I had a diffrent approach than the one you linked, but I don't exactly remember the details. In any case, I agree that this would be a nice feature, and to be honnest I think many user would even expect that feature out of the box from this plugin. I'll look into this, and see how one could implement this, and if we could add this feature within this PR or if, IMHO, it makes sense to add this feature via a seperate issue/PR after this PR has been accepted |
…tsby-plugin-offline
…7-update-workbox-gatsby-plugin-offline
Note for users who come across this PR and want to use the new plugin with an upgraded workbox version. I published a fork of this plugin here: |
@LekoArts any progress on this? Is there more review needed or changes to be made? |
@wardpeet Any chance of rerunning the tests since it looks like it's just e2e issue on circleci that may be fixed now? |
If you can fix conflicts I'm happy to re-run them if necessary :) |
Thanks, I actually missed that, how silly. @kije do you have a quick fix or want some help? |
…7-update-workbox-gatsby-plugin-offline
…xt back to official gatsby-plugin-offline
Awesome to see interest in this PR again! Sorry I was a bit busy the past few days, just now got to have a look at it again. @westhouseit @wardpeet I've merged upstream changes and fixed merge conflicts + backported changes I made in the meantime to my fork gatsby-plugin-offline-next |
Looks like these two e2e test are failing: But I have no idea what exactly they are supposed to test or what causes them to fail |
any update on this @kije ? |
Subscribing to this PR! I would love to get this merged into Gatsby; right now, on the Node.js org, we're using this PR as Workbox v6 has several improvements over the v4 version. |
Unfortunately I don't have enough time at the moment to work on this. If anyone wants to help out in the meantime and take a look at the failing test cases it would be much appreciated. Otherwise I'll try to fix the failures once I have time again |
@kije I could give an eyes, but, I can't guarantee much 😅 (As I'm also kinda busy with stuff, but let me see what I can do!) |
Thks for that, i was looking for I personaly commented directoryIndex as the documentation said if it s null the precache is disactivated..
|
Hi, any update on this ? |
Description
This PR upgrades the quite outdated workbox from v4.x to v6.0. The previously used approach using
workbox-build
/generateSW
can no longer be used with workbox v6, since workbox started with v5 to transpile and bundle the generated Service worker, and access to the workbox library was no longer possible in the appended code (this wasn't an officially supported/recommended approach anyways). The new version now uses theInjectManifest
webpack plugin, which provides the benefit of transpiling/bundling the service worker with webpack. However, sinceInjectManifest
does not provide convenient features like declaring route handlers via theruntimeCaching
option.Users who previously have used this option to add custom handlers or modify the default handlers will need to change their configuration and implement the custom/modified handlers via a custom
swSrc
file using workbox directly (migration path described in the README).Thus, these changes are a major, breaking change.
Notable changes:
workbox-build
/generateSW
. public/sw.js is now generated during thebuild-javascript
stage via the workbox-webpack-pluginimportScripts
in the service worker. The file name contains a content hash to ensure that a service worker update is triggered it it's content changesdeletePreviousCacheVersionsOnUpdate
for cleaning up old cache versions in casecacheId
changesRelated Issues
Fixes #28287
Fixes #28289
Fixes #32497
Fixes #29407
Fixes #29448