-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Description
Web workers are broken on legacy mode, althought caiuseit shows it can be used on legacy browsers(IE10+ supports for example non-shared web workers). Not even a warning is displayed to the user.
This could have been filed as a bug request, but I think it's better as a feature.
Suggested solution
I saw the code of the Vite worker plugin, and the initial impression is that plugin-legacy can use a regular expressions on renderChunk to find the locations the expression "new Worker" is defined, find the right worker file it reference, and transform it to legacy using Babel. But:
- That's seems much more complicated than it needs to.
- Does not work with worker inline import(i.e.
inlineas a query param in import).
Can we somehow overcome this, maybe by replace the worker constructions with some tokens on transform(), and resolves them later in the renderChunk phase?
This way:
- Vite
workerplugin will check if the current format isn'tsystem, and only then will emit the workers assets and replace the URL/inlined-code there. - Vite plugin-legacy will do the same only for the
systemformat, and will transform the worker code via Babel to support legacy.
Alternative
No response
Additional context
No response
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