Rather than repeating the original location when we exit a node, we need to restore the previous parent’s original line location, since the source map format denotes the start location.
babel-generator
Turns an AST into code.
Install
$ npm install babel-generator
Usage
import {parse} from 'babylon';
import generate from 'babel-generator';
const code = 'class Example {}';
const ast = parse(ast);
const output = generate(ast, { /* options */ }, code);