Socket
Socket
Sign inDemoInstall

@babel/helper-module-transforms

Package Overview
Dependencies
Maintainers
4
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-module-transforms - npm Package Compare versions

Comparing version 7.20.7 to 7.20.11

34

lib/dynamic-import.js

@@ -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;

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc