Recast bug

node v10.24.1
version: master
endpointsharetweet
const recast = require('recast') const types = recast.types const builders = recast.types.builders const scope = builders.identifier('scope') const expression = `({ complete: onComplete,translateX: 100 })` const ast = recast.parse(expression, { sourceFileName: 'test.js', }) // replace the scope of the identifiers found types.visit(ast, { visitIdentifier(path) { path.replace(builders.memberExpression( scope, path.node, false )) return false } }) // crate a function const result = builders.functionExpression( null, [scope], builders.blockStatement([builders.returnStatement( ast.program.body[0].expression )]) ) // generate the output const output = recast.print(result, { sourceMapName: `source.map` }) return output
Loading…

no comments

    sign in to comment