vite_ruby
vite_ruby copied to clipboard
Backport code from @vitejs/plugin-legacy to vite_plugin_legacy
Description 📖
Backport most of the logic from @vitejs/plugin-legacy to vite_plugin_legacy
This is currently used in production for over a year to support a wide variety of legacy browsers.
Background 📜
@vitejs/plugin-legacy does a lot of magic to support legacy browsers by rewriting index.html,
we're mostly interested in:
- Safari 10
nomodulefix - A workaround for browsers that support modules, but do not support dynamic import:
- script has type module, so only browsers which support modules would load it
- if the dynamic import works - nothing happens
- if the dynamic import fails - loads polyfills legacy
- when polyfills legacy is loaded - it will then execute the entrypoint
@ElMassimo Can we review and merge this?