Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from May 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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