-
Notifications
You must be signed in to change notification settings - Fork 823
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
workbox-strategies will "auto" import cachable-response and broadcast-cache-update #1071
Comments
To be specific, these are the versions: Today, developers can do: workbox.strategies.staleWhileRevalidate({
cacheName: 'hello-world',
cacheExpiration: {
...
},
broadcastCacheUpdate: {
...
},
cacheableResponse: {
...
}
}); Regardless of the configuration, this will pull in the I'd like to undo this and instead require explicit plugins: workbox.strategies.staleWhileRevalidate({
cacheName: 'example',
plugins: [
new workbox.expiration.CacheExpirationPlugin({ ... }),
new workbox.broadcastUpdate.BroadcastCacheUpdatePlugin({ ... }),
new workbox.cacheableResponse.CacheableResponsePlugin({ ... }),
]
}); This removes the dependency between strategies and the three other modules and makes it more explicit on the developer. We can do more to naming if we felt it would make the API more pallet-able: workbox.strategies.staleWhileRevalidate({
cacheName: 'example',
plugins: [
new workbox.expiration.Plugin({ ... }),
new workbox.broadcastUpdate.Plugin({ ... }),
new workbox.cacheableResponse.Plugin({ ... }),
]
}); or: workbox.strategies.staleWhileRevalidate({
cacheName: 'example',
plugins: [
workbox.expiration.plugin({ ... }),
workbox.broadcastUpdate.plugin({ ... }),
workbox.cacheableResponse.plugin({ ... }),
]
}); |
Thanks for investigating the options. I am on board with the second proposal, workbox.strategies.staleWhileRevalidate({
cacheName: 'example',
plugins: [
new workbox.cacheExpiration.Plugin({ ... }),
new workbox.broadcastUpdate.Plugin({ ... }),
new workbox.cacheableResponse.Plugin({ ... }),
]
}); being the runtime syntax. On a positive note, folks using the |
Due to the way strategies will attempt to convert configuration into a plugin and how Rollup builds the final bundle, using a strategy will auto import the workbox plugins regardless of whether they are used or not.
Only way around this is to require developers to use the plugins directly, which would unless make it a bit clearer that Workbox has some notion of plugin support.
Thoughts?
The text was updated successfully, but these errors were encountered: