-
Notifications
You must be signed in to change notification settings - Fork 816
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
Define WorkboxGlobalScope in workbox-precaching #2119
Conversation
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.
Yeah, In think it would be cleaner to add this to workbox-core/types
(and possibly more future-friendly, as you say).
BTW, I spent a bit of time trying to make this work without the user having to import anything, and I couldn't make it work (without referencing self.__WB_MANIFEST
in the source, which I don't think we want). I think it could work if the SW global was properly set by TypeScript, but I guess we'll have to wait and see.
E.g. |
Thanks for the tip regarding With this latest commit, it looks like it just adds in support for the Given that this approach works, I'm thinking it makes more sense to keep it scoped tightly to the actual modules in which the additional properties will actually be used, rather than in |
I see, so you're thinking of doing this but still expecting users to have to do this in their own code, correct? declare var self: ServiceWorkerGlobalScope; That seems fine to me, but note it's probably the case that many Workbox users wouldn't otherwise have to do Given that I wonder if it makes sense to also extend |
I've switched to extending |
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin3.49KB gzip'ed (23% of limit) |
R: @philipwalton
I'm not 100% sure that this is the right way to do things, so please review this with skepticism, but this definition is the cleanest way I could come up with to support using
self.__WB_MANIFEST
inside of a TypeScriptswSrc
file.The usage ends up looking like:
Maybe we should have a separate
WorkboxGlobalScope
declaration inside ofworkbox-core
instead, which would presumably make it cleaner if we ever added in custom global properties that weren't related toworkbox-precaching
?