1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.babelRemoveFunction = void 0;
|
4 | function babelRemoveFunction(options) {
|
5 | if (!options || typeof options.name !== 'string') {
|
6 | throw new Error('Please provide a function name in the options.');
|
7 | }
|
8 | return function babelRemoveFunctionInstance({ types: t }) {
|
9 | return {
|
10 | visitor: {
|
11 |
|
12 | Function(path) {
|
13 | if (path.node.id && path.node.id.name === 'debugClassName') {
|
14 | path.remove();
|
15 | }
|
16 | },
|
17 |
|
18 | ImportDeclaration(path) {
|
19 | const hasDebugName = path.node.specifiers.findIndex((s) => { var _a; return ((_a = s.imported) === null || _a === void 0 ? void 0 : _a.name) === 'debugClassName'; });
|
20 | if (hasDebugName >= 0) {
|
21 | if (path.node.specifiers.length === 1) {
|
22 |
|
23 | path.remove();
|
24 | }
|
25 | else {
|
26 |
|
27 | path.node.specifiers.splice(hasDebugName, 1);
|
28 | }
|
29 | }
|
30 | },
|
31 |
|
32 | CallExpression(path) {
|
33 | if (path.node.callee.name === 'debugClassName') {
|
34 | if (t.isCallExpression(path.parent) && path.parent.callee.name === 'style') {
|
35 | path.parent.arguments.shift();
|
36 | }
|
37 | else {
|
38 | path.replaceWith(t.StringLiteral(''));
|
39 | }
|
40 | }
|
41 | }
|
42 | }
|
43 | };
|
44 | };
|
45 | }
|
46 | exports.babelRemoveFunction = babelRemoveFunction;
|