Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 1x 1x 1x | const babel = require("@babel/core"); const { USE_RENDER_MACRO } = require("../constants"); const defineMacro = require("../define-macro"); const t = babel.types; const useRenderMacro = defineMacro(USE_RENDER_MACRO, (path) => { const renderFunction = path.node.arguments[0]; if (!renderFunction) { return false; } /** @type {babel.types.Identifier} */ let renderFunctionId; const blockPath = path.scope.getBlockParent().path; console.log(blockPath.parentPath?.node); // if (t.isIdentifier(defaultProps)) { // defaultsId = defaultProps; // } else { // const statement = path.findParent((path) => path.isStatement()); // defaultsId = path.scope.generateUidIdentifier(); // statement?.insertBefore( // t.variableDeclaration("const", [ // t.variableDeclarator(defaultsId, defaultProps), // ]) // ); // } return true; // const parsed = parse(path); // if (!parsed) { // return false; // } // const component = renderComponent(parsed.pathToReplace, parsed.options); // if (!component) { // return false; // } // parsed.pathToReplace.replaceWith(component); // return true; }); module.exports = useRenderMacro; |