index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _helperDefinePolyfillProvider = _interopRequireDefault(require("@babel/helper-define-polyfill-provider"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
  7. var _default = (0, _helperDefinePolyfillProvider.default)(({
  8. debug
  9. }, options) => {
  10. const {
  11. [runtimeCompat]: {
  12. useBabelRuntime
  13. } = {}
  14. } = options;
  15. const pureName = useBabelRuntime ? `${useBabelRuntime}/regenerator` : "regenerator-runtime";
  16. return {
  17. name: "regenerator",
  18. polyfills: ["regenerator-runtime"],
  19. usageGlobal(meta, utils) {
  20. if (isRegenerator(meta)) {
  21. debug("regenerator-runtime");
  22. utils.injectGlobalImport("regenerator-runtime/runtime.js");
  23. }
  24. },
  25. usagePure(meta, utils, path) {
  26. if (isRegenerator(meta)) {
  27. path.replaceWith(utils.injectDefaultImport(pureName, "regenerator-runtime"));
  28. }
  29. }
  30. };
  31. });
  32. exports.default = _default;
  33. const isRegenerator = meta => meta.kind === "global" && meta.name === "regeneratorRuntime";