Support data-type="module" to generate <script type="module"> (#11466)
This commit is contained in:
parent
a33f0d83be
commit
8fce3717a3
@ -53,6 +53,9 @@ function buildBabelOptions(script, filename) {
|
|||||||
*/
|
*/
|
||||||
function run(transformFn, script) {
|
function run(transformFn, script) {
|
||||||
const scriptEl = document.createElement("script");
|
const scriptEl = document.createElement("script");
|
||||||
|
if (typeof script.type !== "undefined") {
|
||||||
|
scriptEl.setAttribute("type", script.type);
|
||||||
|
}
|
||||||
scriptEl.text = transformCode(transformFn, script);
|
scriptEl.text = transformCode(transformFn, script);
|
||||||
headEl.appendChild(scriptEl);
|
headEl.appendChild(scriptEl);
|
||||||
}
|
}
|
||||||
@ -129,6 +132,7 @@ function loadScripts(transformFn, scripts) {
|
|||||||
const scriptData = {
|
const scriptData = {
|
||||||
// script.async is always true for non-JavaScript script tags
|
// script.async is always true for non-JavaScript script tags
|
||||||
async: script.hasAttribute("async"),
|
async: script.hasAttribute("async"),
|
||||||
|
type: script.getAttribute("data-type"),
|
||||||
error: false,
|
error: false,
|
||||||
executed: false,
|
executed: false,
|
||||||
plugins: getPluginsOrPresetsFromScript(script, "data-plugins"),
|
plugins: getPluginsOrPresetsFromScript(script, "data-plugins"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user