1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = _default;
|
7 |
|
8 | var _utils = require("../../utils");
|
9 |
|
10 | function isRegeneratorSource(source) {
|
11 | return source === "regenerator-runtime/runtime";
|
12 | }
|
13 |
|
14 | function _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: "regenerator-entry",
|
35 | visitor,
|
36 |
|
37 | pre() {
|
38 | this.regeneratorImportExcluded = false;
|
39 | },
|
40 |
|
41 | post() {
|
42 | if (this.opts.debug && this.regeneratorImportExcluded) {
|
43 | console.log(`\n[${this.file.opts.filename}] Based on your targets, regenerator-runtime import excluded.`);
|
44 | }
|
45 | }
|
46 |
|
47 | };
|
48 | } |
\ | No newline at end of file |