-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed as not planned
Description
Clear 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.
Reactions are currently unavailable