remaxjs / remax
1 1
import { declare } from '@babel/helper-plugin-utils';
2 1
import * as t from '@babel/types';
3
import { NodePath } from '@babel/traverse';
4

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

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

Read our documentation on viewing source code .

Loading