feat: serviceworker
See original GitHub issueClear and concise description of the problem
With vite 2.8 we got better worker support with a custom build pipeline.
I propose the same for serviceworker so the following should be transformed:
navigator.serviceWorker.register(new URL('./sw.js', import.meta.url), {/**/})
Suggested solution
This could be a copy of the current worker implementation with the difference that service worker can’t be modules so it allways has to get compiled to an iife. This is also true while in development.
So options should be something like:
export declare interface UserConfig {
//...
/**
* ServiceWorker bundle options
*/
serviceWorker?: {
/**
* Vite plugins that apply to serviceWorker bundle
*/
plugins?: (PluginOption | PluginOption[])[];
/**
* Rollup options to build worker bundle
*/
rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
/**
* Filename of ServiceWorker in bundle as this should NEVER change
* @default sw.js
*/
filename?: string
};
}
This has some open questions:
- What happens when using multiple serviceWorker (with different scope) [how determan filename]
Alternative
No response
Additional context
The same might be usable for Worklets. (Audio, Paint, Animation, Layout)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Service Workers | Can I use... Support tables for ... - CanIUse
Service Workers. - CR. Method that enables applications to take advantage of persistent background processing, including hooks to enable bootstrapping of ...
Read more >API Simulator feat. Service Worker - Paul Bakaus' blog
API Simulator allows you to setup any number of static routes (URLs) on the host it runs on, allowing you to test a...
Read more >Removing buggy service workers - Chrome Developers
How to fix a service worker that is causing problems. ... Accomplishing this feat depends on the web server and backend stack used, ......
Read more >Service Worker API - MDN Web Docs
Service workers essentially act as proxy servers that sit between web applications, the browser, and the network (when available).
Read more >UHS FOOD SERVICE WORKER (FT Varied) Summerlin ...
The average salary for FOOD SERVICE WORKER (FT Varied) Summerlin Hospital at companies like UHS in the United States is $37402 as of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I want full control over the SW so not what I need…
That isn’t true, it can be modules if you use the right option.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register