[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports.default = void 0;
|
---|
| 5 | var _helperDefinePolyfillProvider = _interopRequireDefault(require("@babel/helper-define-polyfill-provider"));
|
---|
| 6 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 7 | const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
|
---|
| 8 | var _default = (0, _helperDefinePolyfillProvider.default)(({
|
---|
| 9 | debug,
|
---|
| 10 | targets,
|
---|
| 11 | babel
|
---|
| 12 | }, options) => {
|
---|
| 13 | if (!shallowEqual(targets, babel.targets())) {
|
---|
| 14 | throw new Error("This plugin does not use the targets option. Only preset-env's targets" + " or top-level targets need to be configured for this plugin to work." + " See https://github.com/babel/babel-polyfills/issues/36 for more" + " details.");
|
---|
| 15 | }
|
---|
| 16 | const {
|
---|
| 17 | [runtimeCompat]: {
|
---|
| 18 | moduleName = null,
|
---|
| 19 | useBabelRuntime = false
|
---|
| 20 | } = {}
|
---|
| 21 | } = options;
|
---|
| 22 | return {
|
---|
| 23 | name: "regenerator",
|
---|
| 24 | polyfills: ["regenerator-runtime"],
|
---|
| 25 | usageGlobal(meta, utils) {
|
---|
| 26 | if (isRegenerator(meta)) {
|
---|
| 27 | debug("regenerator-runtime");
|
---|
| 28 | utils.injectGlobalImport("regenerator-runtime/runtime.js");
|
---|
| 29 | }
|
---|
| 30 | },
|
---|
| 31 | usagePure(meta, utils, path) {
|
---|
| 32 | if (isRegenerator(meta)) {
|
---|
| 33 | let pureName = "regenerator-runtime";
|
---|
| 34 | if (useBabelRuntime) {
|
---|
| 35 | var _ref;
|
---|
| 36 | const runtimeName = (_ref = moduleName != null ? moduleName : path.hub.file.get("runtimeHelpersModuleName")) != null ? _ref : "@babel/runtime";
|
---|
| 37 | pureName = `${runtimeName}/regenerator`;
|
---|
| 38 | }
|
---|
| 39 | path.replaceWith(utils.injectDefaultImport(pureName, "regenerator-runtime"));
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 | };
|
---|
| 43 | });
|
---|
| 44 | exports.default = _default;
|
---|
| 45 | const isRegenerator = meta => meta.kind === "global" && meta.name === "regeneratorRuntime";
|
---|
| 46 | function shallowEqual(obj1, obj2) {
|
---|
| 47 | return JSON.stringify(obj1) === JSON.stringify(obj2);
|
---|
| 48 | } |
---|