-
Notifications
You must be signed in to change notification settings - Fork 830
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
Revamp the runtime caching option conversion. #1160
Conversation
Changes Unknown when pulling 7e21126 on runtime-caching-options-changes into ** on v3**. |
}), | ||
broadcastCacheUpdate: joi.object().keys({ | ||
channelName: joi.string().required(), | ||
options: joi.object(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the broadcast cache update object needs a channel name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup—that requirement is enforced one line up, on line 46.
maxAgeSeconds: joi.number().min(1), | ||
}).or('maxEntries', 'maxAgeSeconds'), | ||
networkTimeoutSeconds: joi.number().min(1), | ||
plugins: joi.array().items(joi.object()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work? I.e. how does code in the node space get into the service worker? My main consideration here is that if this works, why support one way in the build process and a different way in the service worker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code that converts whatever is configured in the node
build tools into a string representation that could be inserted into a service worker file is
and the string is used in the template at
<% if (runtimeCaching) { runtimeCaching.forEach(runtimeCachingString => {%><%= runtimeCachingString %><% });} %>`; |
(None of that has changed recently.)
The syntax used to generate the service worker code is not exactly the same as the syntax used when executing the service worker runtime. Service worker execution implies that we're inside of the ServiceWorkerGlobalScope
with the various definitions in the workbox
namespace available. When the build configuration is used, we're inside of the node
runtime environment, and we maintain a mapping of the keys in the config that correspond to the resulting runtime code.
I think in this PR the mapping between configuration supplied to node
and resulting Workbox v3 service worker runtime code gets much closer to being 1:1, as we removed some differences that were mainly around to match sw-precache
's config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks fine to me - comments are more just calling out concerns, but they aren't actionable.
Based on the approval, I'm going to merge. Matt, if you've got any larger concerns about the way the |
R: @philipwalton @addyosmani @gauntface
Fixes #1096, which also contains an explanation of what's changing and why.