As a follow up from #3145 we agreed to add a new format that is a superset of the compact format option. Do things that are considered dangerous. e.g. not printing semicolons, or print literal values as opposed to raw values.
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);