remove babel.parse and encourage use of babylon directly

This commit is contained in:
Sebastian McKenzie 2015-10-05 16:44:14 +01:00
parent 64d5ec090b
commit d108d799bf
2 changed files with 0 additions and 48 deletions

View File

@ -57,26 +57,3 @@ export function transformFileSync(filename: string, opts?: Object = {}): string
opts.filename = filename;
return transform(fs.readFileSync(filename, "utf8"), opts);
}
export function parse(code, opts = {}) {
opts.allowHashBang = true;
opts.sourceType = "module";
opts.ecmaVersion = Infinity;
opts.plugins = {
jsx: true,
flow: true
};
opts.features = {};
let ast = babylon.parse(code, opts);
if (opts.onToken) {
opts.onToken.push(...ast.tokens);
}
if (opts.onComment) {
opts.onComment.push(...ast.comments);
}
return ast.program;
}

View File

@ -1,25 +0,0 @@
/* @flow */
import * as babylon from "babylon";
/**
* Parse `code` with normalized options, collecting tokens and comments.
*/
export default function (code: string, opts: BabelParserOptions = {}) {
let parseOpts = {
allowImportExportEverywhere: opts.looseModules,
allowReturnOutsideFunction: opts.looseModules,
strictMode: opts.strictMode,
sourceType: opts.sourceType,
features: opts.features || {},
plugins: opts.plugins || {}
};
if (opts.nonStandard) {
parseOpts.plugins.jsx = true;
parseOpts.plugins.flow = true;
}
return babylon.parse(code, parseOpts);
}