@babel/helper-module-transforms
Advanced tools
Comparing version 7.20.7 to 7.20.11
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.buildDynamicImport = buildDynamicImport; | ||
exports.getDynamicImportSource = getDynamicImportSource; | ||
@@ -15,3 +16,36 @@ var t = require("@babel/types"); | ||
} | ||
function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) { | ||
const [specifier] = node.arguments; | ||
if (t.isStringLiteral(specifier) || t.isTemplateLiteral(specifier) && specifier.quasis.length === 0) { | ||
if (deferToThen) { | ||
return _template.default.expression.ast` | ||
Promise.resolve().then(() => ${builder(specifier)}) | ||
`; | ||
} else return builder(specifier); | ||
} | ||
const specifierToString = t.isTemplateLiteral(specifier) ? t.identifier("specifier") : t.templateLiteral([t.templateElement({ | ||
raw: "" | ||
}), t.templateElement({ | ||
raw: "" | ||
})], [t.identifier("specifier")]); | ||
if (deferToThen) { | ||
return _template.default.expression.ast` | ||
(specifier => | ||
new Promise(r => r(${specifierToString})) | ||
.then(s => ${builder(t.identifier("s"))}) | ||
)(${specifier}) | ||
`; | ||
} else if (wrapWithPromise) { | ||
return _template.default.expression.ast` | ||
(specifier => | ||
new Promise(r => r(${builder(specifierToString)})) | ||
)(${specifier}) | ||
`; | ||
} else { | ||
return _template.default.expression.ast` | ||
(specifier => ${builder(specifierToString)})(${specifier}) | ||
`; | ||
} | ||
} | ||
//# sourceMappingURL=dynamic-import.js.map |
@@ -6,2 +6,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "buildDynamicImport", { | ||
enumerable: true, | ||
get: function () { | ||
return _dynamicImport.buildDynamicImport; | ||
} | ||
}); | ||
exports.buildNamespaceInitStatements = buildNamespaceInitStatements; | ||
@@ -8,0 +14,0 @@ exports.ensureStatementsHoisted = ensureStatementsHoisted; |
{ | ||
"name": "@babel/helper-module-transforms", | ||
"version": "7.20.7", | ||
"version": "7.20.11", | ||
"description": "Babel helper functions for implementing ES6 module transformations", | ||
@@ -24,3 +24,3 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"@babel/template": "^7.20.7", | ||
"@babel/traverse": "^7.20.7", | ||
"@babel/traverse": "^7.20.10", | ||
"@babel/types": "^7.20.7" | ||
@@ -27,0 +27,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145390
1191
Updated@babel/traverse@^7.20.10