vite_ruby icon indicating copy to clipboard operation
vite_ruby copied to clipboard

Add ids to the included legacy tags

Open edumudu opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. This gem vite_plugin_legacy does not insert all the scripts generated by the @vitejs/plugin-legacy

Describe the solution you'd like Also Insert the inline scripts inserted by the vite plugin

These are inserted in the head to load legacy build in esm browsers that not support dynamic-import

<script type="module">try{import("_").catch(()=>1);}catch(e){}window.__vite_is_dynamic_import_support=true;</script>
<script type="module">!function(){if(window.__vite_is_dynamic_import_support)return;console.warn("vite: loading legacy build because dynamic import is unsupported, syntax error above should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>

Describe alternatives you've considered Automatically add the ids that the plugin add for the scripts, or allow pass an id to the tag helpers, this will allow add the missing scripts manualy

<script nomodule id="vite-legacy-polyfill"
<script nomodule id="vite-legacy-entry"

Note: this ids are used in the scripts in the head, they are also needed for the first solution, but I think that only add the ids will be easer

edumudu avatar Sep 06 '22 20:09 edumudu

Hi Eduardo!

Pull requests are welcome!

ElMassimo avatar Sep 06 '22 23:09 ElMassimo

Is this PR related?

alexookah avatar Dec 15 '23 09:12 alexookah

I believe so

edumudu avatar Dec 15 '23 12:12 edumudu