Skip to content

Add ids to the included legacy tags #252

@edumudu

Description

@edumudu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions