utils.js 944 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getImportSource = getImportSource;
  6. exports.getRequireSource = getRequireSource;
  7. exports.isPolyfillSource = isPolyfillSource;
  8. var _t = require("@babel/types");
  9. const {
  10. isCallExpression,
  11. isExpressionStatement,
  12. isIdentifier,
  13. isStringLiteral
  14. } = _t;
  15. function getImportSource({
  16. node
  17. }) {
  18. if (node.specifiers.length === 0) return node.source.value;
  19. }
  20. function getRequireSource({
  21. node
  22. }) {
  23. if (!isExpressionStatement(node)) return;
  24. const {
  25. expression
  26. } = node;
  27. if (isCallExpression(expression) && isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && isStringLiteral(expression.arguments[0])) {
  28. return expression.arguments[0].value;
  29. }
  30. }
  31. function isPolyfillSource(source) {
  32. return source === "@babel/polyfill" || source === "core-js";
  33. }
  34. //# sourceMappingURL=utils.js.map