Support data-type="module" to generate <script type="module"> (#11466)

This commit is contained in:
dfabulich 2020-05-24 13:31:30 -07:00 committed by GitHub
parent a33f0d83be
commit 8fce3717a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,9 @@ function buildBabelOptions(script, filename) {
*/
function run(transformFn, script) {
const scriptEl = document.createElement("script");
if (typeof script.type !== "undefined") {
scriptEl.setAttribute("type", script.type);
}
scriptEl.text = transformCode(transformFn, script);
headEl.appendChild(scriptEl);
}
@ -129,6 +132,7 @@ function loadScripts(transformFn, scripts) {
const scriptData = {
// script.async is always true for non-JavaScript script tags
async: script.hasAttribute("async"),
type: script.getAttribute("data-type"),
error: false,
executed: false,
plugins: getPluginsOrPresetsFromScript(script, "data-plugins"),