web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.8 KiB

  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 = _interopRequireWildcard(require("@babel/types"));
  9. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  10. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  11. function getImportSource({
  12. node
  13. }) {
  14. if (node.specifiers.length === 0) return node.source.value;
  15. }
  16. function getRequireSource({
  17. node
  18. }) {
  19. if (!t.isExpressionStatement(node)) return;
  20. const {
  21. expression
  22. } = node;
  23. const isRequire = t.isCallExpression(expression) && t.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t.isStringLiteral(expression.arguments[0]);
  24. if (isRequire) return expression.arguments[0].value;
  25. }
  26. function isPolyfillSource(source) {
  27. return source === "@babel/polyfill" || source === "core-js";
  28. }