Skip to content

Commit

Permalink
Support data-type="module" to generate <script type="module"> (#11466)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfabulich committed May 24, 2020
1 parent a33f0d8 commit 8fce371
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/babel-standalone/src/transformScriptTags.js
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 8fce371

Please sign in to comment.