Files
babel/packages/babel-core/src/parse.js
2018-02-08 00:22:50 -08:00

23 lines
515 B
JavaScript

// @flow
import loadConfig, { type InputOptions } from "./config";
import normalizeFile from "./transformation/normalize-file";
import normalizeOptions from "./transformation/normalize-opts";
type AstRoot = BabelNodeFile | BabelNodeProgram;
export default function parse(
code: string,
opts: InputOptions,
): AstRoot | null {
const config = loadConfig(opts);
if (config === null) {
return null;
}
const file = normalizeFile(config.passes, normalizeOptions(config), code);
return file.ast;
}