source: trip-planner-front/node_modules/@babel/preset-env/lib/polyfills/regenerator.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7
8var _utils = require("./utils");
9
10function isRegeneratorSource(source) {
11 return source === "regenerator-runtime/runtime" || source === "regenerator-runtime/runtime.js";
12}
13
14function _default() {
15 const visitor = {
16 ImportDeclaration(path) {
17 if (isRegeneratorSource((0, _utils.getImportSource)(path))) {
18 this.regeneratorImportExcluded = true;
19 path.remove();
20 }
21 },
22
23 Program(path) {
24 path.get("body").forEach(bodyPath => {
25 if (isRegeneratorSource((0, _utils.getRequireSource)(bodyPath))) {
26 this.regeneratorImportExcluded = true;
27 bodyPath.remove();
28 }
29 });
30 }
31
32 };
33 return {
34 name: "preset-env/remove-regenerator",
35 visitor,
36
37 pre() {
38 this.regeneratorImportExcluded = false;
39 },
40
41 post() {
42 if (this.opts.debug && this.regeneratorImportExcluded) {
43 let filename = this.file.opts.filename;
44
45 if (process.env.BABEL_ENV === "test") {
46 filename = filename.replace(/\\/g, "/");
47 }
48
49 console.log(`\n[${filename}] Based on your targets, regenerator-runtime import excluded.`);
50 }
51 }
52
53 };
54}
Note: See TracBrowser for help on using the repository browser.