1 4
import * as t from '@babel/types';
2
import { NodePath } from '@babel/traverse';
3

4 4
export default function fixRegeneratorRuntime() {
5 4
  return {
6
    visitor: {
7 4
      CallExpression: (path: NodePath<t.CallExpression>) => {
8 4
        const node = path.node;
9 4
        const arg0 = node.arguments[0];
10 4
        const arg1 = node.arguments[1];
11

12 4
        if (
13 4
          t.isIdentifier(node.callee) &&
14 4
          node.callee.name === 'Function' &&
15 0
          node.arguments.length === 2 &&
16 0
          t.isStringLiteral(arg0) &&
17 0
          arg0.value === 'r' &&
18 0
          t.isStringLiteral(arg1) &&
19 0
          arg1.value === 'regeneratorRuntime = r'
20
        ) {
21 0
          path.parentPath.remove();
22 0
          path.stop();
23
        }
24
      },
25
    },
26
  };
27
}

Read our documentation on viewing source code .

Loading