Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update the way a navigation route is registered #319

Closed
delawski opened this issue Aug 17, 2020 · 0 comments · Fixed by #320
Closed

Update the way a navigation route is registered #319

delawski opened this issue Aug 17, 2020 · 0 comments · Fixed by #320

Comments

@delawski
Copy link
Contributor

After updating PWA plugin from version 0.3 to 0.4 or 0.5, the following error is thrown in the console during a SW installation:

wp_service_worker=1:411 Uncaught TypeError: wp.serviceWorker.routing.registerNavigationRoute is not a function
    at ?wp_service_worker=1:411
    at ?wp_service_worker=1:477

It seems that the way the navigation route is registered is no longer supported in Workbox 5.

The SW is successfully installed with the following change:

- wp.serviceWorker.routing.registerNavigationRoute(
-   navigationRouteEntry.url,
-   {
-     denylist,
-   }
- );
+ wp.serviceWorker.routing.registerRoute(
+   new wp.serviceWorker.routing.NavigationRoute(
+     wp.serviceWorker.precaching.createHandlerBoundToURL(
+      navigationRouteEntry.url
+     ),
+     {
+       denylist,
+     }
+   )
+ );
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants